def test_solve_6_9(): position = Position([6, 9]) assert solve(position, verbose=verbose) == "P" position = Position([6, 9], length=100) assert solve(position, verbose=verbose) == "P" # def test_solve_8_12(): # position = Position([8, 12]) # assert solve(position, verbose=verbose) == "?" # position = Position([8, 12], length=1000) # assert solve(position, verbose=verbose) == "P" # def test_solve_8_12_18(): # """Test that short position is N.""" # position = Position([8, 12, 18]) # assert solve(position, verbose=verbose) == "N" # position = Position([8, 12, 18], length=1000) # assert solve(position, verbose=verbose) == "N"
"-d", "--deep", action="store_true", help="Solve deeply, i.e. don't stop traverse when P position found.") parser.add_argument( "-r", "--reverse", action="store_true", help="Traverse gaps in reverse (i.e. descending) order.") args = parser.parse_args() if args.backend == "redis": from sylver.backend.redis import RedisBackend backend = RedisBackend(host="localhost", port=6379) elif args.backend == "postgres": from sylver.backend.postgres import PostgresBackend backend = PostgresBackend( "postgres://*****:*****@localhost:5432/sylver") else: backend = None pos = position.Position(args.seeds, length=args.length) print(f"Solving position: {pos.to_dict()}") sol = solve.solve(pos, verbose=args.verbose, backend=backend, deep=args.deep, reverse=args.reverse) print(f"Solution: {sol}")
def solve(self, pos): solve.solve(pos, verbose=False, backend=backend, deep=False, reverse=False)
def test_8_12_18_22_41(): """This position exposed a irreducible bug in a previous version.""" position = Position([8, 12, 18, 22, 41]) assert solve(position, verbose=verbose) == "N" position = Position([8, 12, 18, 22, 41], length=100) assert solve(position, verbose=verbose) == "N"
def test_solve_10(): position = Position([10]) assert solve(position, verbose=verbose) == "N" position = Position([10], length=100) assert solve(position, verbose=verbose) == "N"
def test_solve_7(): position = Position([7]) assert solve(position, verbose=verbose) == "P" position = Position([7], length=100) assert solve(position, verbose=verbose) == "P"
def test_solve_2_3(): position = Position([2, 3]) assert solve(position, verbose=verbose) == "P" position = Position([2, 3], length=100) assert solve(position, verbose=verbose) == "P"