コード例 #1
0
# Input: The adjacency list of a directed graph that has an Eulerian path.
# Output: An Eulerian path in this graph.

# Sample Input:
#      CTT -> TTA
#      ACC -> CCA
#      TAC -> ACC
#      GGC -> GCT
#      GCT -> CTT
#      TTA -> TAC

# Sample Output:
#      GGCTTACCA

import inout
import common

edge_strs = map(str.strip, inout.infilelines)

graph = common.parse_graph_edges(edge_strs)
path = common.find_eulerian_path(graph)

inout.output(common.assemble_path(path))
コード例 #2
0
ファイル: Stepic-57-6.py プロジェクト: chungtseng/rosalind
# Input: The adjacency list of a directed graph that has an Eulerian path.
# Output: An Eulerian path in this graph.

# Sample Input:
#      CTT -> TTA
#      ACC -> CCA
#      TAC -> ACC
#      GGC -> GCT
#      GCT -> CTT
#      TTA -> TAC

# Sample Output:
#      GGCTTACCA           

import inout
import common

edge_strs = map(str.strip, inout.infilelines)

graph = common.parse_graph_edges(edge_strs)
path = common.find_eulerian_path(graph)

inout.output(common.assemble_path(path))
コード例 #3
0
# Input: An integer k.
# Output: A k-universal circular string.

# Sample Input:
#      4

# Sample Output:
#      0000110010111101

import inout
import common

k = int(inout.infilelines[0])

graph = common.k_universal_graph(k)
cycle = common.find_eulerian_cycle(graph)

inout.output(common.assemble_path(cycle[:-1])[:2**k])