Instantly share code, notes, and snippets.

🌴
On vacation

t k tahia-khan

🌴
On vacation
• Sort options
Created May 26, 2016
 class AvoidRoads: def badDict(self, bad): bd = {} for b in bad: bd[b] = True return bd def numWays(self, width, height, bad):
Created May 25, 2016
View ZigZag.py
 class State: def __init__(self, longest_sequence, next_diff): """ next_diff = 1 means the next expected difference in the zigzag sequence is positive next_diff = 0 means the next expected difference in the zigzag sequence is negative """ self.longest = longest_sequence self.next_diff = next_diff
Created May 23, 2016
View CaptureThemAll.py
 from collections import deque class Square: def __init__(self, col, row, prev=None, moves=9999): self.col = col self.row = row self.prev = prev self.moves = moves def set_moves(self, moves):
View SmartWordToy.py
 class Vertex: def __init__(self, word, dist=9999): self.word = word self.dist = dist def gen_all_neighbours(v, forbidden): """ Generate all neighbours for a vertex, i.e. all words that are one letter off. Uses ascii values and excludes any words in list(forbidden). """
Last active May 15, 2016
View tc_ab.py
 def swap(S, i1, i2): l = list(S) l[i1], l[i2] = l[i2], l[i1] S = ''.join(l) return S def prependBs(S, N): nBs = N - len(S) return "B"*nBs + S
Created Mar 26, 2016
View PassingCars.py
 # you can write to stdout for debugging purposes, e.g. # print "this is a debug message" def solution(A): # write your code in Python 2.7 L = len(A) n = 0 if L == 1: return 0
Created Mar 26, 2016
View MaxCounters.py
 # you can write to stdout for debugging purposes, e.g. # print "this is a debug message" def solution(N, A): # write your code in Python 2.7 rmin = 0 rmax = 0 C =  * N M = len(A)
Created Mar 15, 2016
View MissingInteger.py
 # you can write to stdout for debugging purposes, e.g. # print "this is a debug message" def solution(A): # write your code in Python 2.7 N = len(A) C =  * N res = 0 for i in A:
Created Mar 14, 2016
View PermCheck.py
 # you can write to stdout for debugging purposes, e.g. # print "this is a debug message" def solution(A): N = len(A) if not N: return 0 count = N
Created Mar 11, 2016
View FrogRiverOne.py
 # you can write to stdout for debugging purposes, e.g. # print "this is a debug message" def solution(X, A): # write your code in Python 2.7 L = len(A) P = [-1]*X min = 0 for i in range(0, L):
You can’t perform that action at this time.