repl.it
@anonymous/

ImperturbableDisfiguredMonads

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import tqdm

edges = ['15', '53', '34', '45', '52', '21', '13', '32']

def is_solution(x):
    # convert to string so we can iterate over the elements
    x = str(x)
    
    # check if all edges are visited
    for e in edges:
        if e in x or e[::-1] in x:  # also check for reverse direction
            continue
        else:
            return False
    
    return True

possible_solutions = range(111111111, 155555555)

solutions = []
for i, s in enumerate(tqdm.tqdm(possible_solutions)):
  if is_solution(s):
    solutions.append(s)

print(solutions)
print(len(solutions))