Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathmain.py
More file actions
Latest commit
27 lines (18 loc) · 562 Bytes
/
Copy pathmain.py
File metadata and controls
27 lines (18 loc) · 562 Bytes
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
fromjsonschemaimportvalidate
importjson
importsys
# We have a JSON schema to validate our input
frominputimportSCHEMA
# We have an A* pathfinder defined in pathfind.py
frompathfindimportpathfind
defmain():
# Read input from stdin
input=json.load(sys.stdin)
# Validate our input against our JSON schema
validate(instance=input, schema=SCHEMA)
# Find a path from start to end in our world
result=pathfind(**input)
# Print result to stdout
json.dump(result, sys.stdout)
if__name__=='__main__':
main()