46
flpo
19 42 54 Leader of the month
17128/ 18890
Last seen 11 months ago
Member for 9 years, 4 months, 19 days
Difficulty Normal
Missions (427) / Solutions (527)
Best solutions / Newest solutions
Initiation
Prime Factors
Easy Unpack
bytearray
hex
exec
2
5
Composition of Functions
Max Digit
reversed
functools.reduce
reduce
functools
max
2
3
lambda password:
Acceptable Password I
lambda
len
3
2
most_frequent = lambda seq: max(seq, key=seq.count)
The Most Frequent
max
lambda
count
3
Composition of Functions
Backward String
reversed
lambda
join
6
1
compose((6).__lt__, len)
Acceptable Password I
lambda
len
6
2
sum(x for _ in range(y))
Multiply (Intro)
lambda
sum
range
comprehension
7
2
Composition of Functions
Easy Unpack
functools.partial
partial
cycle
itertools.cycle
itemgetter
7
3
log10(a or 1)
Number Length
math.log10
log10
math
or
int
8
4
Second Composition of Functions
Correct Sentence
endswith
upper
lambda
or
and
8
2
all(the_same)
All the Same
all
except
try
True
comprehension
12
4
zip
All the Same
all
zip
comprehension
13
number % 10**(n+1) // 10**n
Max Digit
math.log10
log10
math.floor
floor
math
13
2
all_the_same = compose(all, the, same)
All the Same
reversed
functools.reduce
reduce
functools
set
18
3
compose(partial(and_, 1), inv)
Is Even
operator.inv
inv
and_
operator.and_
functools.partial
1
all, starmap, eq, zip
All the Same
eq
operator.eq
itertools.starmap
starmap
operator
Composition of Functions
Count Digits
functools.partial
partial
isnumeric
functools
map
import
Multiply (Intro)
as
1
Composition of Functions
All the Same
reversed
functools.reduce
reduce
functools
set
items[items.index(border):]
Remove All Before
ValueError
index
except
try
grouper as Itertools Recipe
Split Pairs
itertools.zip_longest
zip_longest
iter
itertools
map
1
empty-string-safe
Correct Sentence
endswith
upper
str
collections.Counter
The Most Frequent
collections.Counter
Counter
collections
s := str(num)
End Zeros
rstrip
str
len
not c.isalpha() or c.isupper()
All Upper I
all
isupper
isalpha
or
comprehension
abs(one - x), x - one
Nearest Value
min
abs
set
lambda
int
3
i: i[1:] + i[:1]
Replace First
lambda
Composition of Functions
First Word (simplified)
methodcaller
operator.methodcaller
itemgetter
operator.itemgetter
operator
int, max, str
Max Digit
max
int
str
''.join(reversed(val))
Backward String
reversed
join
border.__ne__
Remove All Before
dropwhile
itertools.dropwhile
itertools
or
list
w.isnumeric() and int(w)
Sum Numbers
isnumeric
sum
and
split
comprehension
1
All the Same
All the Same
all
not
or
comprehension
'0' <= c <= '9'
Count Digits
sum
comprehension
m := re.match('(^0+)', number)
Beginning Zeros
match
re.match
re
or
and
if number[n] != '0': return n
Beginning Zeros
range
len
for
if
next
Beginning Zeros
next
if-comprehension
range
comprehension
len
not num & 1
Is Even
not
lambda
~num & 1
Is Even
lambda
max_digit = compose(int, max, str)
Max Digit
max
lambda
int
str
max(digits(number))
Max Digit
yield
max
while
First
Easy Unpack
backward_string = itemgetter
Backward String
slice
itemgetter
operator.itemgetter
operator
None
(i:=text.index(begin)+1)
Between Markers (simplified)
index
str
text[begin:end]
Between Markers (simplified)
index
str
lte
All the Same
set
len
2
Home
(-items.count(x), items.index(x))
Sort Array by Element Frequency
index
lambda
count
sorted
1
42
text.lower().split().count
Popular Words
dict-comp
lower
count
split
comprehension
1
20
str(p & f)time
Date and Time Converter
datetime.strptime
strptime
f-string
datetime.datetime
datetime
1
11
one liner
Popular Words
dict
zip
map
lower
lambda
1
3
The Art of the Metaobject Pluralization
Date and Time Converter
getattr
datetime.strptime
strptime
f-string
datetime.datetime
3
3
Composition of Functions
First Word
methodcaller
operator.methodcaller
operator
re.compile
compile
3
2
Composition of Functions
Backward Each Word
methodcaller
operator.methodcaller
slice
functools.partial
partial
5
C({}.fromkeys(ws, 0)).u(C)
Popular Words
collections.u
u
fromkeys
update
as
6
1
With itertools batteries: chain, repeat, starmap
Sort Array by Element Frequency
itertools.repeat
repeat
itertools.starmap
starmap
from_iterable
7
7
Composition of Functions
Bigger Price
slice
itertools.starmap
starmap
functools.partial
partial
9
3
Suppressing
Between Markers
contextlib.suppress
suppress
contextlib
with
operator.add
10
f(f() + 1)
Second Index
contextlib.suppress
suppress
contextlib
with
functools.partial
1
clear
Sun Angle
map
inline-if
split
int
1
Composition of Functions
Days Between
attrgetter
operator.attrgetter
operator.sub
itertools.starmap
starmap
1
yield from [d] * (1 + (d==0))
Duplicate Zeros
iter
list
for
up = next(it) <= (last := next(it))
Changing direction
groupby
itertools.groupby
next
itertools
not
enumerate(pairwise(items))
Missing Number
itertools.pairwise
pairwise
next
itertools
sort
len(items)/2 + len(items)%2
Split List
list
int
len
1
yield from repeat(item, count)
Sort Array by Element Frequency
itertools.repeat
repeat
collections.Counter
Counter
itertools
2
Composition of Functions
Sort Array by Element Frequency
methodcaller
operator.methodcaller
itertools.repeat
repeat
itertools.starmap
Morse decoder
Morse Decoder
capitalize
dict-comp
get
items
upper
1
Counter.update
Popular Words
fromkeys
update
collections.Counter
Counter
dict
itertools.groupby
Three Words
groupby
itertools.groupby
next
itertools
isalpha
2
re.search
First Word
re.search
search
r-string
re
str
with backward_string
Backward Each Word
map
join
split
itemgetter
Bigger Price
itemgetter
operator.itemgetter
operator
sorted
True
' '.join(s[::-1])
Backward Each Word
join
split
comprehension
First
Pawn Brotherhood
tuple
ord
map
bool
set
contextlib.suppress
Second Index
contextlib.suppress
suppress
contextlib
with
ValueError
First
Days Between
date
datetime.date
datetime
abs
1
first:last
Between Markers
ValueError
index
None
except
try
First
Non-unique Elements
count
if-comprehension
list-comp
comprehension
left_join = compose(left, ','.join)
Right to Left
methodcaller
operator.methodcaller
operator
lambda
join
First
Even the Last
next
reversed
sum
Electronic Station
sorted == words
Words Order
set-comp
index
sorted
if-comprehension
in
1
20
are_similar poly
Similar Triangles
sympy.geometry.are_similar
are_similar
sympy.geometry.Polygon
sympy.geometry.Point
Polygon
1
10
SymPy
Inside Block
sympy.Polygon
sympy.Point
Polygon
Point
sympy
1
7
str.maketrans
Surjection Strings
translate
bool
str
2
4
Recursive Generator
Mathematically Lucky Tickets
operator.truediv
truediv
operator.sub
operator.add
mul
2
4
eq(*)
Verify Anagrams
eq
operator.eq
operator
replace
lower
5
1
First
Can You Pass?
math.hypot
hypot
itertools.product
product
set-comp
7
boolean = compose(eval,"{2}({0},{1})".format)
Boolean Algebra
eval
as
format
lambda
10
boolean = lambda x, y, op: globals()[op[:2]](x, y)
Boolean Algebra
globals
as
lambda
11
_5 and len(set(password)) >= 3
Acceptable Password VI
map
isdigit
set
lower
or
17
First
Digits Multiplication
mul
operator.mul
operator
functools.reduce
reduce
19
Second
Digits Multiplication
functools.partial
partial
mul
operator.mul
operator
is_all_upper = str.isupper
All Upper II
isupper
str
1
all(zip)
Ascending List
all
zip
typing.Iterable
Iterable
bool
eval(f"{op}({x},{y})")
Boolean Algebra
eval
as
f-string
7
sorted(files, key=split_filename)
Sort by Extension
rpartition
not
sorted
if
1
with suppress(re.error):
Unix Match. Part 2
error
re.error
contextlib.suppress
suppress
contextlib
1
'password' not in password
Acceptable Password V
map
isdigit
lower
or
sum
seen.add(w) or w
Words Order
add
set
or
if-comprehension
in
Composition of Functions & Fixed Point
Brackets
functools.partial
partial
re.sub
sub
functools
0 < sum < len > 6
Acceptable Password III
map
isdigit
sum
str
len
seen |= c.isupper()
All Upper II
islower
isupper
bool
False
str
2
l := or < l >
Acceptable Password IV
map
isdigit
or
sum
str
'0' <= c <= '9'
Acceptable Password II
any
and
comprehension
len
> 6 and any
Acceptable Password II
any
map
isdigit
and
str
First
Boolean Algebra
globals
eval
as
not
or
First
Find Sequence
yield
any
zip
min
not
@fixpoint
Brackets
decorator
replace
join
while
if-comprehension
Scientific Expedition
result[isinstance(item, int)]
Sum by Type
isinstance
int
for
1
15
re.findall & lower
Conversion from CamelCase
findall
re.findall
re
lower
join
1
12
Numpy
Cipher Map
extract
numpy.extract
matrix
numpy.matrix
numpy.rot90
1
1
methodcaller
YAML. Simple Dict
methodcaller
operator.methodcaller
splitlines
isnumeric
operator
1
1
take a hammer to crack a nut
Follow Instructions
numpy.sum
numpy
as
sum
list-comp
1
0 <= first == second - 1
Goes Right After
find
2
4
caps = not caps
Caps Lock
yield
upper
not
inline-if
join
2
3
dict, int, decode
YAML. More Types
splitlines
filter
strip
None
isdigit
2
4
u"̨̉
Remove Accents
normalize
unicodedata.normalize
unicodedata
join
if-comprehension
2
1
one-liner
Time Converter (24h to 12h)
time.strftime
time.strptime
strftime
time
strptime
3
1
numpy 2
Cipher Map
extract
numpy.extract
concatenate
numpy.concatenate
matrix
3
1
Composition of Functions
Conversion from CamelCase
functools.partial
partial
re.compile
compile
functools
3
3
result.get(str, ''), result.get(int, 0)
Sum by Type
type
get
int
str
for
3
2
First
Call to Home
math.ceil
ceil
collections.defaultdict
defaultdict
values
4
2
find_message = str('_').join(('find', 'message'))
Secret Message
functools.partial
partial
staticmethod
eval
type
4
4
to_CamelCase = partial
Conversion into CamelCase
functools.partial
partial
next
re.sub
sub
4
3
re.sub & lower
Conversion from CamelCase
re.sub
sub
re
lower
5
1
methodcaller
Common Words
methodcaller
operator.methodcaller
operator
filter
map
5
1
zip_longest
The Hidden Word
itertools.zip_longest
zip_longest
itertools
find
map
6
3
k: convert(v.strip())
YAML. More Types
splitlines
startswith
strip
dict-comp
None
7
1
key, value = s.split(': ')
YAML. Simple Dict
splitlines
isnumeric
filter
None
inline-if
7
1
recursive
Conversion into CamelCase
upper
not
inline-if
True
if
7
First
Morse Clock
bin
zip
map
replace
lambda
16
getattr(q, op)(*args)
Letter Queue
collections.append
collections.popleft
popleft
contextlib.suppress
suppress
if not res[k]: del res[k]
Convert and Aggregate
collections.defaultdict
defaultdict
dict
tuple
collections
filter(all, res.items())
Convert and Aggregate
collections.defaultdict
defaultdict
filter
dict-comp
all
Composition of Functions
Pangram
ascii_lowercase
string.ascii_lowercase
string
set
lower
str(p & f)time
Time Converter (24h to 12h)
time.strftime
time.strptime
strftime
time
strptime
3
lines in two lines
YAML. Simple Dict
splitlines
isnumeric
dict-comp
inline-if
if-comprehension
1
'pa'[h < 12]
Time Converter (24h to 12h)
f-string
map
split
int
1
max
The Most Wanted Letter
ascii_lowercase
string.ascii_lowercase
string
max
lower
step-by-step
Follow Instructions
functools.reduce
reduce
functools
lambda
Composition of (Instru|Fun)ctions
Follow Instructions
functools.reduce
reduce
functools
get
map
split & map
Conversion into CamelCase
capitalize
map
lambda
join
split
re
Conversion into CamelCase
re.sub
sub
upper
re
lambda
First
Letter Queue
functools.reduce
reduce
functools
lambda
inline-if
First
Common Words
filter
sorted
join
split
First
Secret Message
filter
isupper
lambda
join
list
Set
Pangram
issubset
ascii_lowercase
string.ascii_lowercase
string
set
checkio = partial(sorted, key=abs)
Absolute Sorting
functools.partial
partial
functools
abs
sorted
O'Reilly
sorted(sorted)
Frequency Sorting
count
sorted
True
1
13
one-liner
Time Converter (12h to 24h)
time.strftime
time.strptime
strftime
time
strptime
1
1
Recursive Generator
Flatten a List (generator version)
from_iterable
itertools.from_iterable
chain
itertools.chain
yield
1
3
yield from (x,)
Flatten a List (generator version)
from_iterable
itertools.from_iterable
chain
itertools.chain
isinstance
2
1
sort with key
Frequency Sorting
lambda
count
sorted
3
3
res.insert(i, 0)
Sort Except Zero
insert
enumerate
not
sorted
if-comprehension
3
1
items[x:x+size]
Chunk
range
comprehension
len
3
yield from chain.from_iterable
Flatten a List (iterator version)
from_iterable
itertools.from_iterable
chain
itertools.chain
yield
4
ChainMap
The Flat Dictionary
ChainMap
collections.ChainMap
isinstance
dict
items
5
3
Not Only Lists
Flatten a List (generator version)
from_iterable
itertools.from_iterable
chain
itertools.chain
yield
5
Stack
The Flat Dictionary
isinstance
dict
items
pop
or
6
brute force
Loading Cargo
from_iterable
itertools.from_iterable
chain
itertools.chain
combinations
7
1
i: i[-1:] + i[:-1]
Replace Last
lambda
13
1
[i:j][::-1]
Reverse Every Ascending
zip
if-comprehension
list-comp
range
comprehension
16
1
Any Iterable
Flatten a List (generator version)
from_iterable
itertools.from_iterable
TypeError
chain
itertools.chain
18
recursive - revisited
Count Inversions
not
sum
comprehension
if
19
(i:=n) and x or x
Compress List
iter
next
yield
not
or
20
1
recursive
Count Inversions
not
if-comprehension
list-comp
comprehension
else
insort(s, s.pop() - s.pop())
The Final Stone
bisect.insort
insort
bisect
sort
pop
flat_list = '_'.join(('flat', 'list'))
Flatten a List
functools.partial
partial
from_iterable
itertools.from_iterable
Exception
0 if type(structure) is int
How Deep
type
is
map
max
inline-if
len(s := str(num)) == 1
Sum of Digits
map
inline-if
sum
int
str
x or zeros.add(i)
Sort Except Zero
insert
add
enumerate
set
or
2
flat_list = compose(flat, list)
Flatten a List
from_iterable
itertools.from_iterable
chain
itertools.chain
isinstance
flat_list = str('_').join(('flat', 'list')); list = list
Flatten a List
globals
functools.partial
partial
class
from_iterable
1
peaks(items)
Reverse Every Ascending
reversed
yield
range
len
for
1
Mainly Functional
Determine the Order
issubset
next
is
dict-comp
keys
import combinations, starmap & gt
Count Inversions
gt
operator.gt
itertools.starmap
starmap
combinations
1
starts, intervals = {}, []
Multiple Lightbulbs
datetime.min
datetime.max
isinstance
datetime.datetime
values
pairwise as Itertools Recipe
Compress List
itertools.tee
tee
itertools.zip_longest
zip_longest
next
zip_longest
Compress List
itertools.zip_longest
zip_longest
itertools
if-comprehension
list-comp
sum & len
Majority
lambda
sum
len
First
Xs and Os Referee
next
join
if-comprehension
in
and
items[:items.index(border)+1]
Remove All After
ValueError
index
except
try
Recursive generator
Flatten a List
type
yield
is
list
else
contextlib.suppress
Index Power
contextlib.suppress
suppress
contextlib
with
IndexError
3
First
Median
1
Incinerator
cycle(Lamp.sequence)
Multicolored Lamp
cycle
itertools.cycle
class
next
itertools
1
19
vars(self).update(locals())
Every Person is Unique
vars
locals
class
datetime.strptime
strptime
1
7
SavedText(list)
Text Editor
class
f-string
append
list
1
4
Squaring the Circle
Geometry Figures
class
math.pi
pi
decorator
round
1
8
Party as a Named list
Party Invitations
class
f-string
remove
append
list
1
5
metaclass=Singleton
Capital City
class
super
type
is
None
1
5
Human = Robot
Dialogues
itertools.starmap
starmap
operator.add
class
operator
1
5
for attr in vars(weapon):
The Weapons
vars
setattr
locals
class
getattr
1
4
char2byte & byte2char
Hacker Language
class
re.compile
compile
chr
format
1
2
Lamp = type
Multicolored Lamp
setattr
cycle
itertools.cycle
next
type
1
__getattr__ = lambda: lambda: getattr
Every Person is Unique
class
getattr
capitalize
datetime.timedelta
timedelta
1
1
AbstractCook
3 Chefs
class
f-string
2
1
make_broken & getattr
Microwave Ovens
class
getattr
object
divmod
super
2
2
cook your locals()
3 Chefs
D
F
d
f
operator.D
2
__init__ = choose_figure
Geometry Figures
setattr
class
getattr
type
float
2
Swordsman = Lancer = Archer = None
Army Units
class
getattr
f-string
None
lambda
3
4
@rounded, @staticmethod, @classmethod
Geometry Figures
math.tan
tan
classmethod
class
staticmethod
3
1
other[:] = (x for x in other if x.is_alive)
The Lancers
class
property
decorator
pass
round
3
FP & MetaOOP
Geometry Figures
globals
operator.sub
operator.add
functools.partial
partial
3
2
army from strings
Army Units
class
getattr
type
f-string
dict
4
__new__
Capital City
class
object
super
is
None
5
1
class Person:
Every Person is Unique
class
capitalize
datetime.timedelta
timedelta
reversed
5
3
while unit_1.is_alive:
The Warriors
class
property
decorator
not
while
6
1
class SetAndGet(list)
Voice TV Control
class
object
property
super
type
8
1
@time.setter
Microwave Ovens
class
object
divmod
property
super
8
Friends set
Friends
class
from_iterable
itertools.from_iterable
frozenset
chain
13
__init_subclass__
3 Chefs
class
super
f-string
pass
18
1
First
Straight Fight
class
property
type
decorator
is
20
2
First
The Healers
class
property
type
decorator
is
[a1, a2][fight(a1[0], a2[0])].pop(0)
The Vampires
class
property
super
decorator
round
1
del [a1, a2][fight(a1[0], a2[0])][0]
The Defenders
class
property
decorator
bool
not
First
Building Base
class
f-string
1
Mine
__getitem__
Best Stock
max
1
30
clean(cryptotext).translate(cipher(delta))
Caesar Cipher (decryptor)
functools.partial
partial
translate
re.compile
compile
1
1
In search of Eulerian path (vinc's solution), discarding loops
Domino Chain
frozenset
collections.deque
deque
iter
collections.defaultdict
2
2
eval(pythonize(formula))
Chemical Analysis
translate
eval
re.sub
sub
collections.Counter
2
1
Composition of Functions
Bigger Together
operator.sub
functools.partial
partial
operator
reversed
2
2
Fixed, after update mission description...
Cut Sentence
rfind
max
inline-if
len
3
1
old style sorting
Bigger Together
cmp_to_key
functools.cmp_to_key
reversed
functools
map
3
Composition of Functions
Currency Style
methodcaller
operator.methodcaller
functools.partial
partial
operator
3
First
The Einstein Problem-Lite
itertools.product
product
next
values
all
5
2
First
Currency Style
re.sub
sub
re
5
optimized random solution
Domino Chain
dict-comp
items
enumerate
min
set
5
First
Determinant
numpy.linalg
linalg
numpy
as
round
7
Composition of Functions
Cut Sentence
shorten
textwrap.shorten
textwrap
operator.add
functools.partial
7
1
Stack
Disposable Teleports
frozenset
map
pop
replace
set
8
Composition of Functions (2)
Best Stock
slice
functools.partial
partial
itemgetter
operator.itemgetter
9
Composition of Functions
Binary Count
methodcaller
operator.methodcaller
operator
bin
lambda
10
1
chains recursive generator
Domino Chain
frozenset
chain
itertools.chain
yield
dict-comp
10
re & translate
Caesar Cipher (decryptor)
translate
re.compile
compile
ascii_lowercase
string.ascii_lowercase
10
shortest solution factorized
Fizz Buzz
bytearray
hex
exec
int
14
4
weighted_sum
Can Balance
next
filter
enumerate
typing.Iterable
Iterable
14
Composition of Functions
Best Stock
methodcaller
operator.methodcaller
itemgetter
operator.itemgetter
operator
1
DRY with backtracking
Disposable Teleports
frozenset
next
yield
map
replace
First
Find Enemy
collections.namedtuple
namedtuple
collections.deque
deque
collections
First
What Is Wrong With This Family?
collections.defaultdict
defaultdict
values
all
any
...else eval(code)
Aggregate by Operation
eval
collections.defaultdict
defaultdict
f-string
collections
groupby, zip_longest
Long Pressed
itertools.zip_longest
zip_longest
groupby
itertools.groupby
all
groupby, zip_longest, count
Long Pressed
itertools.zip_longest
zip_longest
groupby
itertools.groupby
iter
''.join(stack)
Adjacent Letters
pop
join
and
append
else
groupby, zip_longest, count, all_any
Long Pressed
itertools.zip_longest
zip_longest
groupby
itertools.groupby
iter
First
The Greatest Common Divisor
math.gcd
gcd
functools.reduce
reduce
functools
res[v].add(k)
Switch Keys to Values
collections.defaultdict
defaultdict
add
dict
items
cipher dict
Caesar Cipher (encryptor)
ascii_lowercase
string.ascii_lowercase
as
dict-comp
string
DRY -- just to_encrypt
Caesar Cipher (decryptor)
translate
re.sub
sub
ascii_lowercase
string.ascii_lowercase
Stack Backtracking
Color Map
frozenset
next
update
set-comp
filter
Reversing Tuples
Best Stock
items
max
comprehension
Recursive generator
Disposable Teleports
frozenset
next
set-comp
yield
replace
itemgetter
Best Stock
itemgetter
operator.itemgetter
operator
items
max
Counter
Best Stock
collections.Counter
Counter
collections
First
Moore Neighbourhood
sum
if-comprehension
and
list-comp
comprehension
Ice Base
First
Identify Block
arange
numpy.arange
numpy.rot90
rot90
itertools.product
1
1
Composition of Functions
Morse Encoder
Scanner
re.Scanner
itemgetter
operator.itemgetter
operator
2
__import__ and compile
Find Quotes
compile
3
First
Oil Pie
Fraction
fractions.Fraction
fractions
map
abs
4
1
infinite rotations
Identify Block
numpy.reshape
reshape
numpy.rot90
rot90
itertools.product
4
any(starmap(swap, combinations))
One Switch Strings
itertools.starmap
starmap
combinations
itertools.combinations
any
4
3-liner: based on 7-liner: based on best Roman Numerals solution
Reverse Roman Numerals
zip
replace
lambda
count
split
6
lambda-reduce
Oil Pie
attrgetter
operator.attrgetter
Fraction
fractions.Fraction
fractions
8
1
Circle intersection - fixed
Count Chains
sympy.geometry.util.intersection
sympy.geometry.Circle
Circle
difference_update
sympy
12
First
Reverse Roman Numerals
findall
re.findall
re
lambda
sum
14
2
grid = list(zip(*grid[::-1]))
Identify Block
items
zip
set
if-comprehension
in
17
1
[0] * items.count(0)
Move Zeros
count
if-comprehension
list-comp
comprehension
1
Composition of Functions
Long Repeat
functools.partial
partial
itemgetter
operator.itemgetter
groupby
Composition of Functions (thanks to veky's derelict battery heads-up)
Reverse Roman Numerals
Scanner
re.Scanner
itemgetter
operator.itemgetter
operator
1
partial(sorted, key=not_)
Move Zeros
not_
operator.not_
functools.partial
partial
operator
First
Counting Tiles
math.hypot
hypot
itertools.product
product
math.ceil
2
repeat(0, zero)
Move Zeros
itertools.repeat
repeat
yield
itertools
else
upper or lower or upper and lower
Correct Capital
islower
isupper
bool
or
and
without min/max
The Most Numbers
operator.sub
operator
sub
functools.reduce
reduce
2
' '.join(' '.join)
Morse Encoder
get
upper
map
join
split
find_quotes = re.compile('"([^"]*)"').findall
Find Quotes
re.compile
compile
re
find_quotes = quotes.findall
Find Quotes
re.compile
compile
re
recursive reachability
How to Find Friends
collections.defaultdict
defaultdict
update
add
collections
stack reachability
How to Find Friends
collections.defaultdict
defaultdict
update
add
collections
Second
Reverse Roman Numerals
reversed
findall
re.findall
re
sum
2
itertools.groupby
Long Repeat
groupby
itertools.groupby
itertools
map
max
13
Scanner(M).scan
Morse Encoder
Scanner
re.Scanner
upper
re
join
Third
Long Repeat
next
enumerate
max
while
if-comprehension
First
Monkey Typing
contains
operator.contains
functools.partial
partial
operator
Second (re.finditer)
Long Repeat
finditer
re.finditer
r-string
re
max
array = array or [0]
The Most Numbers
min
max
or
Alice In Wonderland
(4 - date.weekday()) % 7
When is Friday?
date
datetime.date
datetime
map
split
1
5
eat_value(deque)
YAML. Complex Structure
splitlines
startswith
collections.deque
deque
yield
1
lines[0].startswith('-')
YAML. List and Comments
splitlines
startswith
strip
dict-comp
None
1
2
divmod
Middle Characters
divmod
len
2
4
mode
The Fastest Horse
statistics.mode
mode
statistics
itemgetter
operator.itemgetter
7
1
slice(*signed)
Middle Characters
slice
lambda
len
12
First
Transposed Matrix
numpy.transpose
transpose
numpy
as
lambda
18
1
tree_walker(subtree, target)
Tree Walker
isinstance
values
dict
sum
comprehension
Counter.most_common
The Fastest Horse
itemgetter
operator.itemgetter
operator
collections.Counter
Counter
from os.path import commonprefix
IP Network: Route Summarization
textwrap.wrap
wrap
textwrap
ljust
format
2
start = stop
Zigzag Array
List
typing.List
typing
inline-if
append
zip(a[::2], a[1::2])
Swap Nodes
yield
zip
and
len
for
1
First
The Shortest Knight's Path
itertools.product
product
set-comp
extend
itertools
First
Digits Doublets
ne
operator.ne
itertools.starmap
starmap
operator
First
Long Non Repeat
map
max
while
and
range
Second
Long Non Repeat
next
map
max
lambda
if-comprehension
First
Multiplication Table
and_
operator.and_
operator.xor
xor
operator.or_
GitHub
cookie.split.split
Cookies
split
1
1
first, *data = sorted(data)
Create Intervals (generator version)
yield
not
sorted
for
if
1
try: first, *data = sorted(data)
Create Intervals (iterator version)
yield
ValueError
except
try
sorted
1
First
Long Repeat Inside
yield
filter
max
in
range
2
3
a0, b0 = next(intervals)
Merge Intervals (iterator version)
next
yield
elif
for
if
2
np
Paper Dice
numpy.all
fliplr
numpy.fliplr
numpy.array_equal
array_equal
2
dict
Cookies
strip
dict
split
comprehension
3
2
best_moves and winning_combos
Xs and Os Champion
divmod
next
index
count
inline-if
3
1
except StopIteration:
Merge Intervals (iterator version)
StopIteration
next
yield
except
try
3
scipy.sparse.csgraph
The Cheapest Flight
dok_matrix
numpy.isinf
scipy.sparse.dok_matrix
scipy.sparse.csgraph.shortest_path
shortest_path
3
a0, b0 = intervals.pop(0)
Merge Intervals (generator version)
yield
pop
not
elif
for
4
1
max columns sum
The Highest Building
itemgetter
operator.itemgetter
operator
zip
map
5
3
if reachable_by_city.isdisjoint(dark_cities): continue
Power Plants
Dict
typing.Dict
functools.lru_cache
lru_cache
typing.Set
5
yield from range
Expand Intervals
typing.Iterable
Iterable
typing
range
for
7
First
Merge Intervals
elif
append
len
for
if
8
1
re.search
Cookies
f-string
re.search
search
re
10
merge intervals
Painting Wall
next
max
sum
sorted
if-comprehension
10
from calendar
The Most Frequent Weekdays
calendar.isleap
isleap
calendar.day_name
day_name
calendar.weekday
10
class checkio:
Solution for Anything
class
None
lambda
True
11
First
Simplify Unix Path
startswith
filter
pop
not
lambda
11
3
decode(s) or decode(s[::-1])
Barcode Reader
translate
next
items
zip
map
11
next & enumerate
The Highest Building
next
enumerate
if-comprehension
comprehension
len
14
1
Mainly Functional (reviewed)
Power Supply
operator.or_
or_
frozenset
operator
set-comp
15
starmap(str.endswith)
The End of Other
itertools.starmap
starmap
itertools.permutations
permutations
endswith
20
1
First
Shooting Range
intersection
math.sqrt
sqrt
round
math
dist = reduce(gcd, spaces)
Evenly Spaced Trees
math.gcd
gcd
functools.reduce
reduce
functools
Composition of Functions
Area of a Convex Polygon
scipy.spatial.ConvexHull
ConvexHull
attrgetter
operator.attrgetter
scipy
for loops
The Highest Building
enumerate
len
for
if
1
slicing
Cookies
next
enumerate
index
if-comprehension
comprehension
1
First
The Highest Building
next
any
enumerate
index
if-comprehension
Mainly Functional
Power Supply
operator.or_
or_
frozenset
operator
functools.reduce
heapq
Open Labyrinth
collections.namedtuple
namedtuple
heappush
heapq.heappush
heappop
simply merge_intervals (spoiler)
Create Intervals
sorted
elif
append
list-comp
comprehension
Composition of Functions
The End of Other
itertools.starmap
starmap
functools.partial
partial
itertools.permutations
Dropbox
sympy.geometry.Circle
Three Points Circle
sympy.geometry.Circle
Circle
sympy.geometry.Point
Point
center
2
brute force
Nonogram Row
groupby
itertools.groupby
filter
itertools
zip
2
1
Composition of Functions
Worth of Words
functools.partial
partial
eval
functools
max
3
1
n % 100, n // 100, n % 10
Speech Module
chain
itertools.chain
f-string
strip
get
4
1
exec(worth_of_words.__doc__) & eval('+'.join(word)))
Worth of Words
exec
globals
locals
eval
replace
5
atbash = mc('translate', r(l) | r(u))
Atbash Cipher
methodcaller
operator.methodcaller
ascii_uppercase
string.ascii_uppercase
operator
5
map locals()[style]
Text Formatting
center
locals
textwrap.wrap
wrap
textwrap
7
1
letters values
Worth of Words
functools.partial
partial
eval
next
functools
10
First
Place Queens
operator.or_
or_
itertools.product
product
operator
14
First
Simple Hashlib
getattr
hashlib
19
zip(reversed)
Common Tail
reversed
zip
None
for
if
19
plaintext.translate(table)
Atbash Cipher
translate
ascii_uppercase
string.ascii_uppercase
ascii_lowercase
string.ascii_lowercase
''.join(text[i::key] for i in range(key))
Scytale Encryption
Optional
typing.Optional
None
typing
join
First
The Longest Palindromic
next
yield
if-comprehension
range
comprehension
First
Numbers Factory
yield
min
sorted
join
if-comprehension
1
eval
Worth of Words
eval
max
lambda
join
1
First
Humpty Dumpty Form
math.atanh
atanh
math.asin
asin
math.pi
PyCon TW
sympy.solve_linear_system
How Much Gold
solve_linear_system
sympy.solve_linear_system
sympy.Matrix
Matrix
sympy
2
1
Composition of Functions
Double Substring
functools.partial
partial
reversed
functools.reduce
reduce
3
Composition of Functions
Sum Consecutives
functools.partial
partial
itemgetter
operator.itemgetter
groupby
5
First
Simple Areas
mul
operator.mul
operator
math.pi
pi
6
sum & groupby
Sum Consecutives
groupby
itertools.groupby
itertools
sum
comprehension
12
Second
House Password
methodcaller
operator.methodcaller
operator
re.compile
compile
First
Network Attack
from_iterable
itertools.from_iterable
itemgetter
operator.itemgetter
chain
1
First
Double Substring
next
find
if-comprehension
range
comprehension
Recursive generator
Golden Pyramid
chain
itertools.chain
yield
itertools
max
1
First
House Password
re.search
search
all
re
and
2
map(eval, commands)
Digit Stack
eval
filter
map
pop
None
merge intervals
Building Visibility
lambda
sorted
if-comprehension
elif
append
GRADES = dict(zip(VALUES, MINS))
Ryerson Letter Grade
next
dict
items
zip
if-comprehension
First
Express Delivery
itertools.starmap
starmap
itertools.permutations
permutations
collections.deque
elif stack:
Digit Stack
pop
inline-if
in
elif
append
Swap Generator
Robot Sort
next
yield
format
join
while
First
Calculate Islands
math.hypot
hypot
set-comp
any
math
First
Digit Stack
contextlib.suppress
suppress
contextlib
with
IndexError
Storage
groupby
Group Equal consecutive
groupby
itertools.groupby
itertools
list-comp
list
1
3
Composition of Functions
Group Equal consecutive
functools.partial
partial
itemgetter
operator.itemgetter
groupby
1
4
spiral walk
Hexagon Spiral
tuple
zip
None
abs
max
2
1
First
Square Spiral
math.ceil
ceil
math.sqrt
sqrt
math
4
2
quine = lambda: code
Exec Quine
Exception
raise
except
try
lambda
4
2
First
Moria Doors
punctuation
string.punctuation
translate
string
min
5
1
First
Mind Switcher
popitem
dict-comp
get
items
pop
5
2
Hack Rules
Restricted Prime
globals
all
map
7
1
distinct lines
The Rows of Cakes
combinations
itertools.combinations
next
itertools
tuple
10
one liner
Word Pattern
format
isdigit
join
comprehension
len
13
1
heapq
Digging a Canal
collections.namedtuple
namedtuple
heappush
heapq.heappush
heappop
First
Earth Distances
math.radians
radians
math.cos
cos
math.sin
numpy
Skew-symmetric Matrix
numpy.array_equal
array_equal
matrix
numpy.matrix
numpy
First
English to Braille Translator
string.index
islice
itertools.islice
from_iterable
itertools.from_iterable
(m(x), m(zip(*x)))
Weak Point
itemgetter
operator.itemgetter
operator
zip
map
First
Playfair Cipher
collections.fromkeys
itertools.starmap
starmap
OrderedDict
collections.OrderedDict
First
Weak Point
min
lambda
sum
list-comp
range
Maya
deduce, satisfy_constraints, solve
Light Up
functools.lru_cache
lru_cache
isdisjoint
from_iterable
itertools.from_iterable
5
HubSpot
reduce, or_, starmap
Supply Line
operator.or_
or_
itertools.starmap
starmap
operator
1
2
weekday() - firstweekday
Weekly Calendar
datetime.timedelta
timedelta
date
datetime.date
datetime
5
leap_shift
Next Birthday
calendar.isleap
isleap
calendar
date
datetime.date
6
First
City's Happiness
from_iterable
itertools.from_iterable
frozenset
chain
itertools.chain
10
2
First
Repeating Decimals
divmod
get
not
inline-if
while
13
1
First
Auto Painting
textwrap.wrap
wrap
textwrap
map
min
15
Precomputation
Square Board
append
range
for
First
Node Disconnected Users
from_iterable
itertools.from_iterable
frozenset
chain
itertools.chain
Count connected components, discarding nodes
New Cities
from_iterable
itertools.from_iterable
discard
frozenset
chain
sum(bool(line.strip()))
Non Empty Lines
splitlines
strip
bool
sum
comprehension
any(c != ' ')
Non Empty Lines
splitlines
any
sum
comprehension
Count connected components
New Cities
from_iterable
itertools.from_iterable
frozenset
chain
itertools.chain
checkio = try_with_default(int, default=-1)
Number Base
contextlib.suppress
suppress
contextlib
with
Exception
1
Composition of Functions
The Hamming Distance
methodcaller
operator.methodcaller
operator.xor
xor
operator
First
Restricted Sum
not
inline-if
contextlib.suppress
Number Base
contextlib.suppress
suppress
contextlib
with
ValueError
Blizzard
SciPy Batteries
Connect Stars
distance_matrix
scipy.spatial.distance_matrix
scipy.sparse.csgraph.minimum_spanning_tr
minimum_spanning_tree
numpy.argwhere
1
2
recursive generator with numpy support
Sudoku Solver
numpy.argwhere
argwhere
numpy.array
array
chain
1
scipy.sparse.csgraph
Useless Flights
dok_matrix
scipy.sparse.dok_matrix
scipy.sparse.csgraph.shortest_path
shortest_path
csr_matrix
2
1
reduce(set.union, points)
Rectangles Union
union
itertools.product
product
Tuple
typing.Tuple
4
1
oikcehc
Palindromic Palindrome
lambda
7
1
min, max = from_cmp(le), from_cmp(ge)
Min and Max
ge
operator.ge
le
operator.le
operator
8
First
Spaceship Landing Strip
itertools.takewhile
takewhile
from_iterable
itertools.from_iterable
chain
8
last.isoformat()
The First Working Day
datetime.timedelta
timedelta
date
datetime.date
datetime
9
2
numbers[1-i:]
Permutation Index
enumerate
sum
comprehension
for
First
Radiation Search
itertools.starmap
starmap
collections.defaultdict
defaultdict
yield
Recursive
String Conversion
min
abs
or
inline-if
sum
1
chain.from_iterable(points)
Rectangles Union
from_iterable
itertools.from_iterable
chain
itertools.chain
itertools.product
1
First
Safe Coasts
set-comp
add
enumerate
replace
set
First
Weekend Counter
sum
range
comprehension
int
1
First
Stressful Subject
groupby
itertools.groupby
endswith
any
itertools
2
First
The Angles of a Triangle
math.degrees
degrees
math.acos
acos
all
Rock
First
Web Log Sessions
itertools.starmap
starmap
class
splitlines
datetime.strptime
1
hunter & walker
Chicken Hunt
scipy.sparse.csgraph.csgraph_from_dense
csgraph_from_dense
scipy.sparse.csgraph.dijkstra
dijkstra
scipy
1
First
Black Holes
itertools.starmap
starmap
class
StopIteration
math.sin
3
First
CheckSum
isalnum
reversed
filter
ord
map
7
while cells: yield close_island()
Hexagonal Islands
difference_update
update
set-comp
yield
add
9
First
Crossword Solver
class
finditer
re.finditer
iter
collections.defaultdict
14
First
Parity Bit Generator
chr
format
map
lambda
count
16
max(line[:len(line)-i+1])
Greedy Number
index
max
range
int
str
First
Water Jars
collections.namedtuple
namedtuple
heappush
heapq.heappush
heappop
1
(last := v) for v in values
Sort by Removing
not
if-comprehension
list-comp
comprehension
if
First
Super Root
not
while
else
if
1
len(nth_composition(step, tick_n)(live))
Life Counter
set-comp
add
enumerate
set
not
2
last = float('-inf')
Sort by Removing
float
if-comprehension
list-comp
comprehension
First
Berserk Rook
frozenset
yield
filter
any
map
Shelter
digit(f)
Seven Segment
set-comp
islower
map
isupper
set
1
4
max(search)
Halloween Monsters
splitlines
yield
collections.Counter
Counter
all
1
for f in str.isupper, str.islower:
Seven Segment
set-comp
islower
map
isupper
set
2
4
completely_empty = lambda *args: globals()['completely_empty'](*args) .....
Completely Empty
functools.wraps
wraps
globals
functools.partial
partial
2
2
Bi-Compressed Sparse Graph & Permutations
Climbing Route
scipy.connected_components
csgraph
scipy.csgraph_from_dense
scipy.dijkstra
scipy.sparse.csgraph
2
1
Compressed Sparse Graph & Permutations
Climbing Route
csgraph
scipy.csgraph_from_dense
scipy.dijkstra
scipy.sparse.csgraph
csgraph_from_dense
3
numpy
Pattern Recognition
numpy.array
array
numpy
as
all
3
x:x*x
The Nearest Square Number
reversed
functools.reduce
reduce
math.sqrt
sqrt
4
2..__rpow__
The Nearest Square Number
reversed
functools.reduce
reduce
math.sqrt
sqrt
6
last_dir = '↓'
The Lantern Festival
itertools.product
product
set-comp
itertools
index
9
for monster in candidates:
Halloween Monsters
splitlines
collections.Counter
Counter
all
collections
17
class MonsterCounter
Halloween Monsters
class
splitlines
super
extend
collections.Counter
First
One line Drawing
from_iterable
itertools.from_iterable
frozenset
chain
itertools.chain
Codeship
as simple as greedy: often doesn't work!
Unfair Dice
sum
append
range
comprehension
len
1
2
First
The Square Chest
set
sum
False
True
list-comp
4
1
Binomial coefficients
Probably Dice
scipy.special.binom
binom
scipy
math.floor
floor
4
1
bfs
The 88th Puzzle
add
tuple
pop
set
while
5
'Group', ('color', 'elements')
Eaten Go Stones
itertools.starmap
starmap
from_iterable
itertools.from_iterable
collections.namedtuple
5
card_a, card_b = islice
Magic with 5 cards
slice
islice
itertools.islice
insert
collections.Counter
6
sort_(card, hand, combination)
Texas Referee
functools.partial
partial
combinations
itertools.combinations
functools
7
groups partitions, again
The Territory of Go
itertools.starmap
starmap
from_iterable
itertools.from_iterable
chain
9
First
Behind 2048
next
filter
any
zip
map
9
from itertools import *
The Square Chest
frozenset
all
zip
map
set
10
1
gyahun_dash optimized
8 Puzzle
operator.sub
heappush
heapq.heappush
heappop
heapq.heappop
17
1
First
Minesweeper
set-comp
all
tuple
continue
not
17
First
Pearls in the Box
is
round
replace
not
lambda
Hermit
First
Ore In The Desert
math.hypot
hypot
all
round
math
2
First
Colder-Warmer
gt
operator.gt
lt
operator.lt
difference_update
3
1
d and f'{d} and '
Fractions Addition
itertools.starmap
starmap
Fraction
fractions.Fraction
fractions
3
1
numpy
Mono Captcha
numpy.split
delete
numpy.delete
translate
numpy.array
5
DRY with backtrack
Network Loops
from_iterable
itertools.from_iterable
frozenset
chain
itertools.chain
5
SymPy
Simplification
expand
sympy.expand
sympy
replace
str
6
First
The Good Radix
next
index
max
if-comprehension
range
9
is_integer()
Count Consecutive Summers
sum
range
comprehension
int
10
suppress_ZeroDivisionError
Reverse Engineer
operator.truediv
truediv
contextlib.suppress
suppress
contextlib
11
(x%2 == 0) * (x//2)
Count Consecutive Summers
sum
range
comprehension
int
19
birthday + datetime.timedelta(5-wd)
Birthday Party
datetime.timedelta
timedelta
date
datetime.date
datetime
'{d} and {f - d}'
Fractions Addition
Fraction
fractions.Fraction
fractions
divmod
f-string
131 chars
Ore In The Desert
all
round
lambda
if-comprehension
list-comp
val[:pos-1] + val[pos+1:]
Backspace Apply
find
inline-if
while
True
str
26 ** (ln-i)
Excel Column Number
ord
enumerate
sum
comprehension
int
len(set(map(canonify, emails)))
Unique Email Addresses
rsplit
partition
f-string
map
replace
[total:len(data)-total])
Shorter Set
set
sorted
len
merge_intervals reuse
Keywords Finder
find
lower
sorted
while
elif
one pass
Stock Profit
float
elif
list
int
for
Watchtower
First
Numbered Triangles
itertools.permutations
permutations
chain
itertools.chain
yield
4
1
First
Ethernet Ring Dimensioning
frozenset
next
filter
values
dict-comp
4
First
Compare Functions
raise
is
ValueError
None
except
6
Second (defaultdict)
Ethernet Ring Dimensioning
frozenset
collections.defaultdict
defaultdict
next
values
10
First
Wall Keeper
dict-comp
get
tuple
bool
not
10
1
with memoization
DNA Common Sequence
functools.lru_cache
lru_cache
chain
itertools.chain
decorator
14
best_gift = current_gift
Bag of Santa Claus
True
if
choices.pop()
Bulls and Cows
itertools.permutations
permutations
itertools
zip
map
1
Best divisor first
Number Guess
next
set-comp
all
pop
set
First
Convex Hull
math.atan2
atan2
math.degrees
degrees
math.pi
First
Vigenere Cipher
eq
operator.eq
string.index
itertools.starmap
starmap
checkio = sum
Funny Addition
sum
First
Rotate Hole
all
if-comprehension
list-comp
range
comprehension
Escher
insort_left
The Ship Teams
bisect.insort_left
insort_left
bisect
items
for
1
11
x0, y0 = positions.pop('Y')
Compass, Map and Spyglass
values
dict-comp
enumerate
pop
abs
1
4
search(positions, word='hypercube'):
Hypercube
dict-comp
keys
any
enumerate
not
1
scipy.ndimage.find_objects
Keys and Locks
find_objects
scipy.ndimage.find_objects
numpy.array_equal
array_equal
matrix
1
1
from numpy import array, abs, argwhere
Compass, Map and Spyglass
numpy.argwhere
numpy.abs
argwhere
numpy.array
array
1
1
except: pass
Safe Code
startswith
digits
string.digits
eval
next
1
1
numpy.(sum, argmin)
The Stone Wall
numpy.sum
numpy
as
sum
list-comp
1
xs, ys = zip(*grounds)
Ground for the House
zip
enumerate
min
max
not
2
4
max(l) - min(l) + 1
Ground for the House
mul
operator.mul
operator
zip
enumerate
2
1
scipy.ndimage.find_objects
Ground for the House
find_objects
scipy.ndimage.find_objects
matrix
numpy.matrix
scipy
2
min(starmap(point_line_distance, lines))
Wild Dogs
numpy.linalg.norm
norm
cross
numpy.cross
itertools.starmap
2
safe = {1}
The Stones
set-comp
add
in
range
comprehension
4
yield sum(yield)
The Buttons
difference_update
update
set-comp
yield
enumerate
5
class Treasure:
Treasures
vars
class
OrderedDict
collections.OrderedDict
update
10
3
sorted(bts, reverse=True)
The Buttons
set-comp
enumerate
pop
sorted
while
11
next(filter(solve, range), -1)
Safe Code
contextlib.suppress
suppress
contextlib
with
startswith
12
1
N[0] = 'zero'
The Secret Room
rstrip
f-string
index
sorted
append
12
1
f'{item}: {count}'
Treasures
OrderedDict
collections.OrderedDict
f-string
items
collections
18
deck.remove
Card Game
next
set-comp
remove
except
try
3
functools.reduce
The Stones
set-comp
functools.reduce
reduce
functools
lambda
1
column.count('#')
The Stone Wall
itemgetter
operator.itemgetter
operator
zip
enumerate
Not On Map
eval('string_length'[7:10])
Length of the String
eval
2
numpy.base_repr
Base change - Position System
base_repr
numpy.base_repr
numpy
2
takewhile(most_common)
Most Wanted Letter
itertools.takewhile
takewhile
ascii_letters
string.ascii_letters
as
8
2
groupby(most_common)
Most Wanted Letter
ascii_letters
string.ascii_letters
itemgetter
operator.itemgetter
groupby
15
1
Counter update
Aggregate and Count
collections.Counter
Counter
collections
for
Counter & chain.from_iterable
Aggregate and Count
from_iterable
itertools.from_iterable
chain
itertools.chain
collections.Counter
string_length = len
Length of the String
len
1