Skip to content

Instantly share code, notes, and snippets.

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))
@AvocadosConstant
AvocadosConstant / utopia-snack-gen.py
Created August 4, 2017 14:43
Spread the knowledge of snacks around the Bloomberg offices to the Utopia - Food Alerts p-chat!
from random import choice
brands = [
"Wonka",
"Hershey's",
"Reese's",
"Nestle",
"Kelloggs",
"Keebler",
"Mars"
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]
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))
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):
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
"""
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.