Skip to content

Commit 6c9f819

Browse files
committed
Option to perform test on stdin
1 parent e423fe8 commit 6c9f819

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

tsptest.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import json
1+
import json, sys
22

33
with open("distances.json", "r") as f:
44
distances = json.load(f)
@@ -21,7 +21,7 @@ def test(func):
2121
visited = set(route)
2222
for pub in names:
2323
if pub not in visited:
24-
print("ERR: Did not visit {}".visit(pub))
24+
print("ERR: Did not visit {}".format(pub))
2525
return
2626

2727
# Check time
@@ -34,3 +34,12 @@ def test(func):
3434
speed / 1.05 # gets 5% slower at each pub
3535
last = pub
3636
print(t)
37+
38+
def read_from_stdin(distances, names, drunk_factor):
39+
lines = []
40+
for line in sys.stdin:
41+
lines.append(line.strip())
42+
return lines
43+
44+
if __name__ == "__main__":
45+
test(read_from_stdin)

0 commit comments

Comments
 (0)