-
-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathmain.py
More file actions
27 lines (18 loc) · 562 Bytes
/
main.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
from jsonschema import validate
import json
import sys
# We have a JSON schema to validate our input
from input import SCHEMA
# We have an A* pathfinder defined in pathfind.py
from pathfind import pathfind
def main():
# 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()