Add one solution of a competition
(id)
| 5 | |
| 6 | |
| 7 | def addSolutionInfo(id): |
| 8 | """ |
| 9 | Add one solution of a competition |
| 10 | """ |
| 11 | with codecs.open('solutions.json', 'r', encoding='utf-8') as f: |
| 12 | solutions = json.load(f) |
| 13 | if str(id) in solutions.keys(): |
| 14 | print("ID exsited, please try again") |
| 15 | return |
| 16 | algo = input("Enter algorithm: ") |
| 17 | code = input("Enter code: ") |
| 18 | s = {"algorithm": algo, "code": code} |
| 19 | solutions[id] = s |
| 20 | with codecs.open("solutions.json", 'w', encoding='utf-8') as f: |
| 21 | json.dump(solutions, f, indent=4, ensure_ascii=False) |
| 22 | |
| 23 | |
| 24 | def addCompe(): |