コード例 #1
0
from Solution import solution1, solution2


def parseFile(filename: str) -> [int]:
    numbers = []
    with open(filename, 'r') as f:
        line = f.readline()
        numbers = line.split(',')
    numbers = [int(n.strip()) for n in numbers]
    return numbers


## TEST

# print(solution1([1,0,0,0,99]))
# print(solution1([2,3,0,3,99]))
# print(solution1([2,4,4,5,99,0]))
# print(solution1([1,1,1,4,99,5,6,0,99]))

input1 = parseFile('input.txt')
print(solution1(input1[:]))
print(solution2(input1[:]))
コード例 #2
0
from Solution import solution1, solution2
import sys


def expect(a, b):
    msg = "Expected {} and obtained {}".format(a, b)

    if a == b:
        print("[ OK  ]", msg)
    else:
        print("[Error]", msg)


def allLines():
    lines = []
    for line in sys.stdin:
        lines.append(line.strip())

    return lines


lines = allLines()

expect(4, solution1(lines))
expect(32, solution2(lines))
コード例 #3
0
def parseFile( filename: str ) -> [int]:
	numbers = []
	with open( filename, 'r') as f:
		line = f.readline()
		numbers = line.split(',')
	numbers = [ int(n.strip()) for n in numbers]
	return numbers
	
## TEST

# input_test = parseFile('input_test.txt')
# input_test = [1002,4,3,4,33]
# print(solution1(input_test))
# print(input_test)
# print(solution1([2,3,0,3,99]))
# print(solution1([2,4,4,5,99,0]))
# print(solution1([1,1,1,4,99,5,6,0,99]))

input1 = parseFile('input.txt')
solution1(input1[:])
solution2(input1[:], 5)
#
# solution2([3,9,8,9,10,9,4,9,99,-1,8], 8)
# solution2([3,9,8,9,10,9,4,9,99,-1,8], 9)
# solution2([3,9,7,9,10,9,4,9,99,-1,8], 7)
# solution2([3,9,7,9,10,9,4,9,99,-1,8], 8)
# solution2([3,3,1108,-1,8,3,4,3,99], 8)
# solution2([3,3,1108,-1,8,3,4,3,99], 7)
# solution2([3,3,1107,-1,8,3,4,3,99], 5)
# solution2([3,3,1107,-1,8,3,4,3,99], 8)
コード例 #4
0
            positions.append(parsePosition(line))

    return positions


TEST = True
REAL = True
if TEST:
    """ TEST GIVEN #1 """
    test1 = [
        "R75,D30,R83,U83,L12,D49,R71,U7,L72", "U62,R66,U55,R34,D71,R55,D58,R83"
    ]
    positions = []
    positions.append(parsePosition(test1[0]))
    positions.append(parsePosition(test1[1]))
    print(solution1(positions))
    print(solution2(positions))
    """ TEST GIVEN #2 """
    test2 = [
        "R98,U47,R26,D63,R33,U87,L62,D20,R33,U53,R51",
        "U98,R91,D20,R16,D67,R40,U7,R15,U6,R7"
    ]
    positions = []
    positions.append(parsePosition(test2[0]))
    positions.append(parsePosition(test2[1]))
    print(solution1(positions))
    print(solution2(positions))
if REAL:
    testcase1 = parseFile("input.txt")
    print(solution1(testcase1))
    print(solution2(testcase1))
コード例 #5
0
from Solution import solution1, solution2


def parseFile(filename: str) -> [int]:
    with open(filename, 'r') as f:
        lines = f.readlines()
    return [0]


TEST = True
REAL = False
## TESTS
if TEST:
    input1 = parseFile('input_test.txt')
    print(solution1(input1))
    print(solution2(input1))

## REAL
if REAL:
    input1 = parseFile('input.txt')
    print(solution1(input1))
    print(solution2(input1))
コード例 #6
0
from Solution import solution1, solution2, checkNr, checkNr2


def parseFile(filename: str) -> [int]:
    with open(filename, 'r') as f:
        lines = f.readlines()
    return [0]


TEST = True
REAL = False
## TESTS
if TEST:
    print(checkNr(111111))
    print(checkNr(223450))
    print(checkNr(123789))
    print(checkNr2(112233))
    print(checkNr2(123444))
    print(checkNr2(111122))
if REAL:
    print(solution1(109165, 576723))
    print(solution2(109165, 576723))
コード例 #7
0
from Solution import solution1, solution2
import sys


def allLines():
    lines = []
    for line in sys.stdin:
        lines.append(line.strip())

    return lines


lines = allLines()

print(solution1(lines))
print(solution2(lines))
コード例 #8
0
        lines = f.readlines()
        for l in lines:
            l = l.strip()
            limitX = len(l)
            for x, v in enumerate(l):
                if v == '#':
                    entries.append((x, limitY))
            limitY += 1
            # print(l)

    # print(entries, limitX, limitY-1)
    return entries, limitX, limitY - 1


TEST = True
REAL = False
## TESTS
if TEST:
    input1, limX, limY = parseFile('input_test.txt')
    maxHits, pos = solution1(input1, limX, limY)
    print(maxHits, pos)

    solution2(input1, limX, limY, pos)
    # print(solution2(input1))

## REAL
if REAL:
    input1, limX, limY = parseFile('input.txt')
    print(solution1(input1, limX, limY))
    # print(solution2(input1))