This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
""" | |
Solution to http://100.70.19.162:8000/contest/32/13 | |
Note that the instructions say that (x, y) means column x, row y; | |
however, the sample cases show the opposite. | |
This solution is based on the sample cases therefore (x, y) | |
means column y, row x. Which is dumb. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from math import factorial | |
from collections import Counter | |
from functools import reduce | |
""" | |
Solution to http://100.70.19.162:8000/contest/32/9 | |
""" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
""" | |
Solution to http://100.70.19.162:8000/contest/32/11 | |
""" | |
def check_friendly(s, l): | |
if (len(s) == len(l) and sum(s[i] != l[i] for i in range(len(s))) <= 1 | |
or len(s) == len(l) - 1 and s == l[:-1] | |
or len(s) == len(l) + 1 and s[:-1] == l): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
""" | |
Solution to http://100.70.19.162:8000/contest/32/12 | |
""" | |
# input handling | |
maze = sys.stdin.read().splitlines() | |
height, width = int(maze.pop(0)), int(maze.pop(0)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
""" | |
Solution to http://100.70.19.162:8000/contest/32/7 | |
""" | |
stack = list(map(int, sys.stdin.read().splitlines())) | |
del stack[0] | |
stack = [(i, True) for i in stack] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import choice | |
brands = [ | |
"Wonka", | |
"Hershey's", | |
"Reese's", | |
"Nestle", | |
"Kelloggs", | |
"Keebler", | |
"Mars" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution(object): | |
def exist(self, board, word): | |
""" | |
:type board: List[List[str]] | |
:type word: str | |
:rtype: bool | |
""" | |
return any(char == word[0] and self.search(board, word, x, y, set()) | |
for y, row in enumerate(board) for x, char in enumerate(row)) |