Skip to content

Instantly share code, notes, and snippets.

@xtoss
xtoss / ry4an_D-small-attempt4_output.txt
Created April 14, 2013 02:04
This is ry4an's result by applying my 5th attempt data against his code. #7 is suspicious here. I believe it is solvable. UPDATE: Turns out #7 is correct while my code was treating TOTAL_KEY_NUMBER as KEY... After code fixing and regenerate my output, the suspicious case becomes #14, which is solvable.
Case #1: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Case #2: 1 2 7 3 9 10 4 12 14 5 11 15 6 8 13
Case #3: 1 2 3 4 5
Case #4: 2 1 3 7 6 12 4 5 8 13 9 10 11 14 15 16 17 18 19 20
Case #5: 2 1
Case #6: 1
Case #7: IMPOSSIBLE
Case #8: IMPOSSIBLE
Case #9: 1 2 3 4 5
Case #10: 1 2 5 3 7 8 9 10 11 12 4 13 14 16 17 18 19 6 20 15
@xtoss
xtoss / D-small-attempt4_output.txt
Created April 14, 2013 02:02
This is my output for attempt #4, but it was wrong. Clearly I did not get Case #10 right after comparing with Ry4an's result.
Case #1: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Case #2: 1 2 7 3 4 9 10 5 11 12 14 6 8 13 15
Case #3: 1 2 3 4 5
Case #4: 2 1 3 6 7 4 5 8 12 9 10 11 13 14 15 16 17 18 19 20
Case #5: 2 1
Case #6: 1
Case #7: 1 2 3 4 5 6 9 11 12 7 8 13 10
Case #8: IMPOSSIBLE
Case #9: 1 2 3 4 5
Case #10: 1 2 5 7 11 12 14 17 19 20 3 4 6 8 9 10 13 15 16 18
@xtoss
xtoss / D-small-attempt4.in
Created April 14, 2013 02:00
I made 5 attempts... I wish I could got the penalty which means I at least got it right.
25
20 15
2 4 4 5 1 1 5 5 5 3 5 3 4 4 2 4 1 3 2 1
4 1 1
1 2 5 3
1 4 4 3 2 4
4 1 3
5 0
5 0
1 1 1
@xtoss
xtoss / Treasure.py
Created April 14, 2013 01:15
Google Code Jam 2013 - Problem D
import collections
# set to False if any of the chest contains no keys at all
could_check_deadlock = False
def treasure():
"""
used to solve google code jam 2013 - Problem D
"""
in_f = open('D-small-attempt4.in', 'r')
@xtoss
xtoss / FairAndSquare.py
Created April 14, 2013 01:14
Google Code Jam 2013 - Problem C
import math
def fair_and_square():
"""
used to solve google code jam 2013 - Problem C
"""
in_f = open('C-large-1.in', 'r')
out_f = open('C-large-1.in_output.txt', 'w')
num_of_case = int(in_f.readline().rstrip('\n'))
print "num of cases:{}".format(num_of_case)
@xtoss
xtoss / Lawnmower.py
Created April 14, 2013 01:14
Google Code Jam 2013 - Problem B
def lawnmower():
"""
used to solve google code jam 2013 - Problem B
"""
in_f = open('B-large.in', 'r')
out_f = open('B-large_output.txt', 'w')
num_of_case = int(in_f.readline().rstrip('\n'))
print "num of cases:{}".format(num_of_case)
for i in range(1, num_of_case+1):
@xtoss
xtoss / TTT.py
Created April 14, 2013 01:13
Google Code Jam 2013 - Problem A
win_patterns = ["XXXX", "OOOO", "XXX", "OOO"]
def tttt():
"""
name is short for "Tic-Tac-Toe-Tomek"
"""
in_f = open('A-large.in', 'r')
out_f = open('A-large_output.txt', 'w')