else: count = 0 break else: passed = False if passed: peeps.append(f.split('.')[0]) passs += 1 else: no_pass += 1 end = time.time() print("\n\n\n") for i in wrong: print(i) print("\n\n\nresults:\n") for i in peeps: print(i) print(f"\npassed {passs}\nnot passed {no_pass}") print(f"Computation time: {end-start} seconds") usr = input("\n\nUpdate leaderboard? [Y/n] ") if usr.lower() != "n": file = os.path.join( Path(os.path.dirname(os.path.realpath(__file__))).parent, "data.json") for i in peeps: update_board.won(file, i, 5) for i in wrong: update_board.lost(file, i.split(',')[0], 5) print("leaderboard updated") else: print("leaderboard stays as is")
chars = len(sol[0]) shortest = sol[1] short = [] while len(short) < len(solutions): for sol in solutions: if len(sol[0]) == chars: short.append([len(sol[0]), sol[1]]) chars += 1 print(f"\nsorted by code length:") for i in short: print(i[0], i[1].split('.')[0].split('\\')[1]) compTime = end - start min = f"{compTime//60:.0f}" sec = f"{compTime%60:.0f}" print(f"\nComputation time: {min}:{sec if len(sec)==2 else '0'+sec}") usr = input("\n\nUpdate leaderboard? [Y/n] ") if usr.lower() != "n": file = os.path.join( Path(os.path.dirname(os.path.realpath(__file__))).parent, "data.json") for i in winners: update_board.won(file, i[1], 18) for i in wrong: i = i.split("\n")[1] update_board.lost(file, i, 18) print("leaderboard updated") else: print("leaderboard stays as is")
if len(sol[0]) < chars: chars = len(sol[0]) shortest = sol[1] short = [] for i, sol in enumerate(solutions): if len(sol[0]) == chars and shortest != sol[1]: if short == []: short.append(shortest) short.append(sol[1]) if short == []: print(f"\nshortest solution: {shortest.split('.')[0]}") else: print(f"\nshortest solutions:") for i in short: print(i.split('.')[0]) print(f"\nComputation time: {end-start:.3f} seconds") usr = input("\n\nUpdate leaderboard? [Y/n] ") if usr.lower() != "n": file = os.path.join( Path(os.path.dirname(os.path.realpath(__file__))).parent, "data.json") for i in winners: update_board.won(file, i[1], 6) for i in wrong: i = i.split("\n")[1] update_board.lost(file, i, 6) print("leaderboard updated") else: print("leaderboard stays as is")