Skip to content

Instantly share code, notes, and snippets.

🌴
On vacation

t k tahia-khan

🌴
On vacation
Block or report user

Report or block tahia-khan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View AvoidRoads.py
class AvoidRoads:
def badDict(self, bad):
bd = {}
for b in bad:
bd[b] = True
return bd
def numWays(self, width, height, bad):
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
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).
"""
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
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
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 = [0] * N
M = len(A)
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 = [0] * N
res = 0
for i in A:
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
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.