21
jmegner
5 22 34
2593/ 2695
Last seen 4 years ago
Member for 8 years, 11 months, 8 days
Difficulty Normal
I keep a repo of my solutions at: https://github.com/jmegner/CheckioPuzzles

Missions (127) / Solutions (129)
Best solutions / Newest solutions
Home
list comprehension
Non-unique Elements
count
if-comprehension
list-comp
comprehension
16
10
used zip and slices for easy word triplets
Three Words
all
zip
isalpha
False
True
make set of pawn locations
Pawn Brotherhood
add
ord
set
or
in
make grid, check protected left or right
Pawn Brotherhood
ord
enumerate
or
False
and
used datetime.date
Days Between
date
datetime.date
datetime
abs
str.join, list comprehension, and str.replace
Right to Left
replace
join
list-comp
comprehension
len check then sum over conditional list comprehension
Even the Last
enumerate
not
sum
if-comprehension
comprehension
Electronic Station
check if point on any polygon segment; check num intersections of polygon with ray shooting out
Inside Block
hash
class
collections.namedtuple
namedtuple
staticmethod
simple location stack and set of visited locactions
Can You Pass?
class
collections.namedtuple
namedtuple
add
collections
used Counter and conditional generator comprehension
Verify Anagrams
collections.Counter
Counter
collections
isalpha
lower
dict with lambdas
Boolean Algebra
not
lambda
or
and
used horizontal and vertical multipliers
Find Sequence
break
or
False
True
range
functools.reduce and a multiplying lambda
Digits Multiplication
functools.reduce
reduce
functools
lambda
if-comprehension
used stack of brackets for main work; used dict to match end-brackets to begin-brackets
Brackets
values
pop
not
or
in
Scientific Expedition
collections.Counter and creative sort key
The Most Wanted Letter
collections.Counter
Counter
items
collections
isalpha
simple concept means simple code
I Love Python!
used: re, zip
Striped Words
findall
re.findall
r-string
upper
zip
2
no tricks
Call to Home
split
int
for
if
yay for bin, replace, and rjust
Morse Clock
rjust
bin
enumerate
replace
split
sorted(nums, key = abs)
Absolute Sorting
abs
sorted
str.join and conditional list comprehension
Secret Message
isupper
join
if-comprehension
comprehension
First
Letter Queue
collections.deque
deque
collections
join
append
First
Bird Language
while
in
elif
else
len
used: set, conditional list comprehension, str.lower and str.isalpha
Pangram
isalpha
set
lower
if-comprehension
comprehension
used: set, conditional list comprehension, str.join, sorted
Common Words
set
sorted
join
if-comprehension
split
First
Striped Words
findall
re.findall
r-string
upper
continue
used counter; wish I had better tie-breaker
The Most Wanted Letter
collections.Counter
Counter
items
collections
isalpha
O'Reilly
two solutions: flattened iterative and natural recursive
Cipher Crossword
setdefault
itertools.permutations
permutations
itertools
zip
used dicts to hold less-than relations
Determine the Order
cmp_to_key
functools.cmp_to_key
setdefault
copy
functools
use itertools.product((0,1), repeat=n) to produce all possible assignments of weights into two loads
Loading Cargo
itertools.product
product
itertools
zip
min
used enumerate and array slice
Count Inversions
enumerate
for
recursion, probably heavily improvable
Flatten a List
isinstance
not
inline-if
int
ternary operator would have been less readable
Index Power
len
if
simple for rows, zip for cols, by-hand for diags
Xs and Os Referee
extend
all
zip
map
lambda
second, zip for cols, by-hand for diags
Xs and Os Referee
extend
all
zip
map
lambda
First
Median
sorted
len
if
Incinerator
self.connections is a list, but lots of uses of set
Friends
class
discard
remove
set
in
First
Building Base
class
format
Mine
First
Moore Neighbourhood
min
max
range
len
for
17
1
relationsToPersons, mergePartialPersons, fillInMissingTraits
The Einstein Problem-Lite
OrderedDict
collections.OrderedDict
discard
copy.deepcopy
deepcopy
extract adjacency sets, then depth-first recursive search of colors
Color Map
class
OrderedDict
collections.OrderedDict
collections.namedtuple
namedtuple
Laplace expansion and double recursion
Determinant
sum
if-comprehension
list-comp
range
comprehension
recursive depth first search
Disposable Teleports
collections.defaultdict
defaultdict
copy
add
collections
simple algebra
Achilles and the Tortoise
return functools.reduce(fractions.gcd, args)
The Greatest Common Divisor
fractions.gcd
gcd
fractions
functools.reduce
reduce
three ifs, four returns
Fizz Buzz
and
str
if
return bin(number).count('1')
Binary Count
bin
count
Ice Base
iterate over quadrant-within-circle
Counting Tiles
math.ceil
ceil
math.sqrt
sqrt
math
2
direct simulation
Feed Pigeons
max
while
else
if
use Fraction; subtract if pos, multiply if neg
Oil Pie
Fraction
fractions.Fraction
fractions
abs
sum
handle each power of ten independently; look-up tables for within power of ten
Roman Numerals
reversed
is
enumerate
None
print
3
dicts for edges, simple recursion that remembers not to re-visit drones
How to Find Friends
setdefault
add
set
in
False
return len of foundWords set; also used split, strip, lower, and string.punctuation
Monkey Typing
punctuation
string.punctuation
strip
string
add
after args len check, max(args) - min(args)
The Most Numbers
min
max
not
if
Alice In Wonderland
simple breadth first search
The Shortest Knight's Path
add
ord
continue
set
or
commented explanation of "return [list(row) for row in zip(*data)]"
Transposed Matrix
zip
list-comp
list
comprehension
GitHub
First
Solution for Anything
class
lambda
True
9
simple A* algo implementation
Open Labyrinth
class
collections.namedtuple
namedtuple
reversed
add
reused Point and LineSegment classes, yay
Shooting Range
math.hypot
hypot
class
collections.namedtuple
namedtuple
for each new span, remove overlapping existing spans and add new merged span
Painting Wall
class
collections.namedtuple
namedtuple
add
collections
choose master point; sum area of consecutive triangles using cross product
Area of a Convex Polygon
zip
abs
for
str.rfind must match len difference of words
The End of Other
rfind
False
and
True
len
Dropbox
two different solutions: one efficient, one simple
Place Queens
class
collections.namedtuple
namedtuple
staticmethod
decorator
reduce to 2 linear equations, then use Cramer's rule
Three Points Circle
class
collections.namedtuple
namedtuple
rstrip
math.sqrt
First
Simple Hashlib
hashlib.new
new
hashlib
update
find prime digit factors and up-convert to bigger digit factors if possible
Numbers Factory
divmod
collections.Counter
Counter
collections
not
decimal.Decimal for precision
Friendly Number
Decimal
decimal.Decimal
decimal
format
abs
2
First
Speech Module
format
elif
if
PyCon TW
based on each metal is implicitly double-counted
How Much Gold
sum
in
append
else
for
8
2
sort by dist to south wall, then repeatedly split farthest wall into visible pieces
Building Visibility
attrgetter
operator.attrgetter
class
collections.namedtuple
namedtuple
a cell is only as good as itself plus the better of the two children
Golden Pyramid
reversed
enumerate
max
list-comp
list
simple recursive "path finding" that keeps track of best distance/time to each node; answer is greatest distance
Network Attack
max
and
range
len
for
used list for value stack
Digit Stack
raise
ValueError
pop
elif
append
simple recursive touch
Calculate Islands
itertools.product
product
itertools
enumerate
not
Heron's formula for triangle
Simple Areas
raise
math.pi
pi
math.sqrt
sqrt
used "any" and "map"
House Password
islower
any
map
isupper
isdigit
Storage
encode and decode basically the same
Playfair Cipher
isalnum
raise
ValueError
zip
enumerate
10
get cycles of mind-needs-to-get-to-next-body, then use two helpers to "rotate" the cycle
Mind Switcher
keys
remove
pop
break
set
list.extend is your friend
English to Braille Translator
zfill
isnumeric
extend
bin
ord
top left corner always an odd square; compute coords directly
Square Spiral
class
collections.namedtuple
namedtuple
math.ceil
ceil
A* path algo with land heavily weighted
Digging a Canal
class
collections.namedtuple
namedtuple
extend
add
used: bin, string.rjust, join, map, lambda
Word Pattern
rjust
bin
map
isalpha
lambda
straightforward string methods, set operations, and list comprehensions
Moria Doors
punctuation
string.punctuation
reversed
strip
string
used min with custom key; also used zip(*matrix) to get column view of matrix
Weak Point
zip
enumerate
min
sum
First
Skew-symmetric Matrix
enumerate
False
True
for
if
HubSpot
depth first search, make sure you don't block others, don't "bunch up" on your own path
Supply Stations
functools.total_ordering
total_ordering
class
collections.namedtuple
namedtuple
5
1
try: int(numberStr, radix); except: return -1
Number Base
except
try
int
basically: [xor, bin, slice, int, map, sum]
The Hamming Distance
bin
map
sum
int
recursion: sum is first elem plus sum of rest
Restricted Sum
if
Blizzard
iterative brute force
Sudoku Solver
copy.deepcopy
deepcopy
itertools.product
product
divmod
brute force of all possible rectangles
Spaceship Landing Strip
enumerate
max
False
True
range
recursive infection of danger
Safe Coasts
itertools.product
product
itertools
zip
enumerate
copy and one pass with max
Stair Steps
copy
max
range
len
for
recursive touch/infect
Radiation Search
enumerate
or
sorted
append
len
2
do not forget timedelta
Weekend Counter
datetime.timedelta
timedelta
datetime
while
if
law of cosines; angleForC = acos((a**2+b**2-c**2)/(2*a*b)
The Angles of a Triangle
math.degrees
degrees
math.acos
acos
round
1
used lambdas
Min and Max
is
get
None
lambda
or
Rock
two ways: new=set&counter, old=grid
Life Counter
class
collections.namedtuple
namedtuple
chain
itertools.chain
12
3 solutions: efficient iterative BFS, inefficient recursive DFS, fun nonminimal guy
Water Jars
class
collections.namedtuple
namedtuple
itertools.permutations
permutations
anybody else think the prompt was confusing?
CheckSum
isalnum
divmod
reversed
upper
ord
1
for each tick, resize and recenter grid to allow growth
Life Counter
chain
itertools.chain
itertools.product
product
reversed
recursive depth first search and helper Loc class
Berserk Rook
class
collections.namedtuple
namedtuple
collections
ord
binary search
Super Root
abs
while
elif
True
else
Shelter
each lantern follows right-hand wall and builds up wall as it goes
The Lantern Festival
raise
ValueError
add
zip
break
20
Fleury's algo with simple connectedness checks to make Euler path
One line Drawing
class
collections.namedtuple
namedtuple
raise
iter
1
please comment if there is better way to "double use" an iterable
Pattern Recognition
itertools.tee
tee
itertools.product
product
itertools
First
Ghosts Age
while
and
append
else
if
Codeship
slow recursive DFS and redo of bunnychai
Magic Domino
itertools.permutations
permutations
chain
itertools.chain
itertools.product
5
one function handles all of the multiple-of-rank hands; I think I did okay job with straight and flush stuff
Texas Referee
functools.partial
partial
class
collections.namedtuple
namedtuple
2
recursion to brute force all sorted sequences of correct sum
Unfair Dice
itertools.product
product
is
itertools
None
each cell neighborhood analyzed independently
Minesweeper
class
collections.namedtuple
namedtuple
itertools.product
product
keep sets of which (r,c) points have right-segments and down-segments
The Square Chest
add
set
or
sorted
False
2
Hermit
eval the expression with 'x' as a Polynomial object that overloads math operators
Simplification
class
eval
update
copy
reversed
14
start in north-west, go probe-dist south, then go probe-dest east, then find compatible location with probe-dists
Ore In The Desert
class
collections.namedtuple
namedtuple
raise
math.sqrt
3
use builtin int() with 2 args; skip over ValueErrors
The Good Radix
ValueError
continue
except
try
range
recursive depth-first search
Network Loops
collections.defaultdict
defaultdict
add
collections
set
always go to location that would give most information in the worst case
Colder-Warmer
math.hypot
hypot
class
collections.namedtuple
namedtuple
brute force loop over all possible break combinations
Break Rings
union
combinations
itertools.combinations
functools.reduce
reduce
Watchtower
reject first n/e gifts, then accept first gift better than first n/e gifts
Bag of Santa Claus
math.exp
exp
math
max
False
4
2d grid of accumulated best sequences using letters up to each point in the two words
DNA Common Sequence
iter
itertools.product
product
next
is
18
recursive depth first search
Magic Square
discard
copy.deepcopy
deepcopy
itertools.product
product
negative cross product means you've found a better next-hull-point
Convex Hull
math.hypot
hypot
class
collections.namedtuple
namedtuple
looking for consecutive full rings followed by empty ring
Bacteria Colonies
all
any
add
enumerate
break
simple sieve approach, and recognizing redundancy in divisors
Number Guess
discard
index
max
False
True
even works when key is ABABC
Vigenere Cipher
chr
ord
zip
enumerate
break
simple nested loop
Rotate Hole
insert
pop
break
not
False
first chip stays in same location; chips must share values with neighbors; some canonical form skipping
Numbered Triangles
isdisjoint
itertools.permutations
permutations
raise
itertools.product
return sum(data)
Funny Addition
sum