49
Awesome Team
Philippe Cholet
https://github.com/Philippe-Cholet
Last seen 4 hours ago
Member for 6 years, 2 months, 27 days
Difficulty Advanced
I was a math teacher in France for two years. I'm currently reconverting to IT, I'm here to improve my Python skills, and practice English.
Initiation
1-liner: set(string.ascii_lowercase).isdisjoint
All Upper I
111
6
3
not set(text) & low_letters
All Upper I
396
1
0
itertools recipe from python docs
All the Same
6
6
0
zip
Goes Right After
38
7
0
try word.index
Goes Right After
222
1
0
collections.Counter and list comprehension
Non-unique Elements
658
6
1
List/Iterator versions
All the Same
165
6
0
generator and simple generalization
Split Pairs
531
0
0
lambda with counter.most_common
Sort Array by Element Frequency
260
3
0
First
Multiply (Intro)
7
38
4
try except
Between Markers
278
3
6
sum "safe bools"
Pawn Brotherhood
3112
0
1
First
Time Converter (12h to 24h)
46
0
0
My flat_list program
Flatten a List
560
1
0
Home
islice
Split List
10
5
1
sort, get next with diff != min_diff
Missing Number
29
0
0
more-itertools import + 1-liner
Changing direction
19
2
1
groups of signed diffs
Changing direction
1
5
5
List key possibilities for each clue and cautiously merge them into one full key
Playfair Cipher Attack
1
11
1
Find first/last occurence of a sub-string, rotations to filter candidates
Grille Cipher Attack
1
8
2
1-liner (clear version in 3rd party)
Rotating Grille Cipher
1
10
2
numpy for easy rotations, itertools.compress and zip (length-check py3.10+)
Rotating Grille Cipher
1
5
3
v3: Dynamic Programming, more memory-friendly for large numbers
Ugly Numbers
1
13
3
Dynamic programming - indexes of the next multiples of 2, 3, 5
Ugly Numbers
6
0
0
Generate ugly numbers in a priority queue to get them in order
Ugly Numbers
1
21
5
::diameter
Scytale Encryption
2
7
0
.translate(table) done with operator.methodcaller
Atbash Cipher
2
24
3
Count recursively because of intersections; intersection function doctested
Mountain Scape
13
2
1
Obvious generator
Sort by Removing
34
1
0
class XY(NamedTuple)
Find Enemy
6
7
1
index of next non-zero char
Beginning Zeros
412
1
0
pop words until it's short enough
Cut Sentence
42
5
1
lines generator
Xs and Os Referee
11
40
11
[py3.8+] 50 chars with walrus
Split List
5
9
1
[py3.8+] 1-liner: 115 chars
Time Converter (24h to 12h)
6
7
1
[py3.8+] 1-liner: 117 chars
Sun Angle
38
1
0
4-lines: ''.join(generator)
Bird Language
30
2
3
Best-first search with heapq and POO
8 Puzzle
12
2
1
Ancestor(s?), check last generations
What Is Wrong With This Family?
47
3
3
update dimensions with rotations
Life Counter
18
1
0
20 random searches
Open Labyrinth
78
0
1
re.sub(r'_[a-z]', repl lambda function, name.capitalize())
Conversion into CamelCase
178
3
0
First
Bird Language
88
12
0
First
Time Converter (24h to 12h)
78
0
0
First
Sun Angle
183
0
0
Electronic Station
Obfuscated milp
Blood distribution
1
0
1
[scipy 1.9+] milp: Mixed-integer linear programming
Blood distribution
1
0
0
Two versions: Max-heap, Min-heap, 4 lines each
The Final Stone
4
10
7
min-heap of negative weigths & heapq.heapreplace
The Final Stone
6
0
0
compose(product, trues, ints, str)
Digits Multiplication
126
1
2
7-liner: Queue of dicts to determine the decimal, decode from hex
Cipher Dict (decryption)
1
0
3
Determine the decimal, group digits, queue of empty dicts
Cipher Dict
2
2
0
replace; fullmatch
Unix Match. Part 1
67
3
1
and len(set(password)) >= 3
Acceptable Password VI
200
0
0
and 'password' not in password.lower()
Acceptable Password V
7
11
1
len(password) >= 10 or
Acceptable Password IV
29
6
0
not password.isdigit()
Acceptable Password III
14
10
1
any(map(str.isdigit, ...))
Acceptable Password II
37
6
0
obvious 1-liner
Acceptable Password I
32
9
0
[py3.8+] 1-liner: 82 chars with rpartition
Sort by Extension
21
1
0
filename.rpartition('.'), partial(sorted, key=...)
Sort by Extension
2
76
6
3-liner: 177 chars
Similar Triangles
1
16
1
[Generalized] All equal distance² fractions
Similar Triangles
21
8
1
dict.setdefault
Surjection Strings
2
27
1
translation dict and zip
Surjection Strings
50
6
6
lambda reduce mul
Digits Multiplication
1005
1
0
8-liner: Even-odd rule with origin point simplifications
Inside Block
1
20
2
neighbors generator, sort decorator
Chess Knight
10
6
1
re.sub(r'[A-Z]', repl lambda function, name)
Conversion from CamelCase
2
11
1
(Shorter code) Recursively generate parenthesization on split digits and operations
Mathematically Lucky Tickets
7
10
1
(Print version) Recursively generate parenthesization on split digits and operations
Mathematically Lucky Tickets
6
10
1
With chain rows/cols/diags generators
Find Sequence
42
11
1
From neighbors to neighbors with memorisation of previous steps...
Can You Pass?
13
6
1
My first
Verify Anagrams
1651
0
0
Scientific Expedition
take zipped while all equal
Longest Common Prefix
2
3
2
3-liner
Combining Celebrity Names
2
0
0
groupby, del [...:], lstrip
Combining Celebrity Names
11
0
0
capture stdout decorator
Caps Lock
35
0
0
suppress ZeroDivisionError caused by eval
Aggregate by Operation
1
8
1
operator
Aggregate by Operation
9
4
0
composition of methods/types
Pangram
9
5
2
Naive but cached
Remove Brackets
5
23
5
lambda function generalization
Sum by Type
157
2
0
basic 1-liner
Pangram
116
8
0
basic 1-liner
Common Words
4
9
1
Simple generator of characters (decorated to ''.join output)
Caps Lock
104
2
4
sorted with abs key
Absolute Sorting
2781
0
0
First
Secret Message
120
20
0
list
Letter Queue
22
7
1
decorated for doc
I Love Python!
86
21
2
v2: using slicing, sets, generator and translation of punctuation =)
Striped Words
59
8
0
My morse clock
Morse Clock
114
4
0
Man, I can find hidden words in poetry! :-)
The Hidden Word
111
2
1
Total cost of some calls
Call to Home
69
3
0
Read the password from cipher map
Cipher Map
1455
0
0
So simple...
Follow Instructions
197
2
2
O'Reilly
Ugly-ish but short enough
Bridge Routine
5
0
0
Digit by digit
"Lunar" Multiply
8
0
0
Enumerate string digits
"Lunar" Multiply
7
0
0
Bruteforce with previous solution
Staircase
1
3
0
Row by row
All Roads Lead to Rome!
8
0
0
product, filterfalse
All Roads Lead to Rome!
7
0
0
List segments
Cut Into Squares
1
0
0
Cached recursion and GCD
Cut Into Squares
2
0
0
takewhile workaround, and not just lists
Remove All After
9
1
0
[typed, py3.10+] timelines, intervals, cut moments, count
Lightbulb More
32
0
0
Operating cut
Lightbulb Operating
4
7
0
1-liner: sympy.topological_sort
Determine the Order
2
7
2
sympy.topological_sort
Determine the Order
1
12
1
Merge datetime intervals
Multiple Lightbulbs
5
6
0
add end time to els; min(end_watching or end, ...)
Lightbulb End Watching
2
38
2
max(start_watching or end, end)
Lightbulb Start Watching
1
72
5
sum timedelta.total_seconds()
Lightbulb Intro
22
6
0
1-liner + imports: O(n²) but faster than with "for"
Count Inversions
35
8
2
Compare, deduce, choose with lexicographic order
Determine the Order
14
10
2
count true
Majority
201
2
0
Fully typed generalization
Sort Except Zero
230
1
1
We can sum booleans (False == 0 and True == 1)
Majority
1
67
7
Two solutions
Chunk
59
3
1
obviously itertools.groupby
Compress List
147
1
0
try return slice except
Remove All After
1
65
8
Three solutions + 1 in comments
Replace Last
1
167
11
import it
Median
396
5
2
short, recursive, max with default argument
How Deep
107
0
1
yield from reversed(ascending list)
Reverse Every Ascending
1
65
2
lambda
Index Power
311
5
1
any_iterable, func = statistics.median, n = 3
Median of Three
158
0
0
6-lines: min, itertools.combinations
Loading Cargo
21
6
0
re
Chemical Analysis
12
0
0
[wrong code] unions of sets and resolve all conflicts
Determine the Order
18
2
1
Sum comprehension in lambda function
Count Inversions
15
13
0
Sort with a key
Frequency Sorting
119
3
1
My "flat dictionary" program
The Flat Dictionary
25
6
4
Incinerator
Both partial, cycle
Multicolored Lamp
367
0
0
IOs
Hacker Language
121
0
0
First
Hacker Language
29
2
6
Dataclasses and a property
Microwave Ovens
22
4
2
dataclass, functools.singledispatchmethod and decorated methods
Voice TV Control
1
23
5
Simple dataclass
Every Person is Unique
80
1
1
[clear v2] dataclasses, army deque, properties
The Warlords
23
2
7
First
Capital City
1
6
2
first with copy.copy and SavedText(list)
Text Editor
42
2
0
12-lines with lambda methods (except init)
Building Base
5
9
2
Deprecated version
The Warlords
1
2
0
Robot = Human(str)
Dialogues
12
10
1
v2 (from flpo veky and myself): Party(Named, set), Friends(str) with lambda show_invite
Party Invitations
2
14
0
My party invitations
Party Invitations
54
1
0
My 3 chefs
3 Chefs
22
5
0
Equipements class for list weapons, and new init_... attributes for manage weapons.
The Weapons
2
10
1
With Ngone class
Geometry Figures
7
6
1
Short
Army Units
5
18
0
With zip(army_1, army_2) and remove_the_dead property in Army class
Straight Fight
3
7
1
My healers
The Healers
36
2
1
New battle.fight method, and a different management of attributes/method.
The Lancers
32
1
1
With (new) hit method returning damage, adapted for vampires.
The Vampires
3
25
0
_health attribute, health property, @health.setter to manage the defense attribute
The Defenders
62
2
6
Army with 3 properties : is_alive, warrior, pop
Army Battles
1
97
16
My warriors with super().__init__()
The Warriors
247
2
0
First
Multicolored Lamp
128
2
2
Be lenient, it's my first class ever
Friends
72
3
2
Mine
First
Matrix-2-String
5
0
1
First
String-2-Matrix
4
4
0
1-liner: itertools
Champernowne Word
18
0
0
itertools.groupby, what else?!
Count And Say
1
5
0
Minimize differences
Tricky String
1
0
0
yield
Quadratic Equation Roots
3
3
1
First
Leap Year Checking
2
11
1
max
Maximum Among Three
11
1
2
str
Reverse Integer
2
9
0
Sorted joined perms
All Permutations
6
0
0
Basic formula
Sum of Integers
3
6
0
str method
Replace All Occurrences
1
11
1
Counter
Count Vowels
16
1
1
max(..., key, default)
The Longest Word
1
19
2
Simply import
Count Divisibles in Range (simplified)
4
4
1
speedy 1-line
Close Enough
1
0
0
math trick
Close Enough
1
0
0
log floor/ceil
Close Enough
2
0
0
Generate perfect powers near n for reasonable exponents
Checking Perfect Power
2
0
0
yield:=breaks
Beat The Previous
7
4
0
Mostly deduce, consider all remaining possibilities
Garland
5
0
0
Row by row (cryptic)
The Hollow Diamond
1
0
0
Row by row
The Hollow Diamond
10
0
0
Side by side
The Hollow Diamond
6
1
0
First
e+pi
4
0
0
sympy can handle permutations
15-puzzle Solvability
1
6
1
Backtracking
Peaceable Queens
1
9
1
Use the OEIS sequence
Peaceable Queens
3
0
2
match changes
One Switch Strings
1
18
1
in (UPPER, lower, Capitalize)
Correct Capital
23
2
1
isupper, islower or == capitalize
Correct Capital
40
0
1
Optional ascending information
Sort Sorted Groups
10
0
0
sum(map(int, str(num))) while 2+ digits
Sum of Digits
13
5
0
First
Convert and Aggregate
20
3
1
[py3.9+] just import math.gcd
The Greatest Common Divisor
10
14
1
1-liner: functools.partial(re.sub, regex, lambda repl)
Currency Style
16
0
0
[sympy] Intersections and reflections of rays with jar segments
Escape
1
8
1
First
Binary Count
343
4
2
basic 1-liner
Caesar Cipher (encryptor)
18
3
0
basic 1-liner
Caesar Cipher (decryptor)
3
1
0
next(filter(balance, indexes), -1)
Can Balance
7
12
0
lambda d: max(d, key=d.get)
Best Stock
41
10
0
min(routes generator, key=len)
Disposable Teleports
14
5
3
9-liner: BFS
Fast Train
1
24
1
lambda
Moore Neighbourhood
14
18
3
functools.cmp_to_key
Bigger Together
8
20
2
re (sub, fullmatch), translate/maketrans for exchange ',' and '.'
Currency Style
12
6
2
Bruteforce
Domino Chain
22
0
0
Borrowed code for colour graph, then adapted
Color Map
70
0
0
Lambda function with sympy.matrices package
Determinant
12
6
4
Sets/dicts reunions, deduct the missing values
The Einstein Problem-Lite
50
0
0
I just wanted to try for a change
The Greatest Common Divisor
161
1
2
I solved the equation, that's all.
Achilles and the Tortoise
63
4
3
Ice Base
Reduce namedtuple
Colorful Disks
12
0
0
math.prod
The Brick Factory Problem
5
0
0
I
Frogs Collision
1
0
0
Match operators
Postfix Evaluation
7
0
0
Priority queue: minimize used brushes and uncolored positions
Grid Painting
2
0
0
To the moon
Armstrong Number Checking
12
3
0
1-liner, no import
Ordinary Cardinals
1
5
0
This is the key 🔑
Ordinary Cardinals
4
3
0
First
Count Divisibles in Range
9
0
0
Backtracking
Stepping Stones Puzzle
1
2
0
Thinking about indexes
Matrix "Hatching"
9
0
0
groups and lengths
Long Pressed
27
0
1
(.)\1
Adjacent Letters
1
3
0
stack
Adjacent Letters
1
24
5
sum booleans
Monkey Typing
269
3
2
Generate histograms with a "simple" iteration on heights
Largest Rectangle in a Histogram
27
0
0
Colored connected components
Count Chains
4
20
4
[v2] Simple BFS with collections.defaultdict & deque
How to Find Friends
23
13
0
re.findall
Find Quotes
159
1
0
Look for sure things thanks to comparisons
Cipher Crossword
4
10
0
symmetry & (solid, partial or break)
Counting Tiles
12
11
1
lambda
The Most Numbers
259
5
1
Percentages then diff then lesser angle
Clock Angle
18
5
0
Dynamic programming with minimal storage (EAFP style)
Making Change
12
0
0
max with default argument
Berserk Rook
29
2
1
DFS on colored (integers) networks (without a crash) for connected components
City's Happiness
11
5
0
DFS on colored (integers) net without crashes, return max color int
New Cities
23
3
4
DFS on colored network graph without crashed nodes
Node Disconnected Users
2
19
0
lambda function
Morse Encoder
169
1
0
All blocks considered at top left, and dictionary of blocks built with rotations of an example of each type.
Identify Block
31
1
0
With fractions module
Oil Pie
13
5
2
Feed previous pigeons, and maybe feed some new pigeons
Feed Pigeons
105
5
0
Sets of friends
How to Find Friends
44
9
0
My "long repeat" letter program
Long Repeat
728
0
0
Alice In Wonderland
DFS
Bishop vs Aliens
3
0
0
Matrix of probabilities, generalized
Cleaning Robot
1
0
0
Any sweep line
Overlapping Disks
1
0
0
Recursive max
The Cookie Monster
2
4
1
Cached tiling counts
Count Domino Tilings
1
1
1
A139250
Toothpicks
10
1
1
Count cube coordinates
Ulam-Warburton Automaton Hex
3
13
1
Grid, naive
Ulam–Warburton Automaton
9
3
1
heapq again 🙂
Huffman Encode
12
0
0
counter
When "k" is Enough!
29
0
0
Second "reduce" with 0 as initial
Excel Column Number
9
1
1
yield holes
Duplicate Zeros
2
31
4
rotate?, count groups of X, fill with zeros first, rotate back?
Nonogram Encode
7
2
0
range intersection for fun
Long Non Repeat
335
0
0
py3.10+ my_compose(all, partial(starmap, lt), pairwise)
Ascending List
43
0
0
py3.10+ itertools.pairwise
Ascending List
40
8
1
Simple stack
Backspace Apply
12
0
0
partial, regex substitution, composition
Unique Email Addresses
2
0
0
reduce
Excel Column Number
5
2
2
O(n)
Stock Profit
7
3
1
timedelta(max(0, 5 - weekday))
Birthday Party
6
1
0
heapq: nlargest, nsmallest
Shorter Set
3
12
0
Always take the biggest digit, ignoring the "last" digits
Greedy Number
12
0
0
[scipy] Precompute all distances with Floyd Warshall
The Shortest Knight's Path
2
0
0
[py3.8+] 1-liner 169 chars: not windows-friendly
Date and Time Converter
6
6
2
datetime.strftime : "%-d" or "%#d"
Date and Time Converter
29
10
1
[v3] Tested on big texts
Long Non Repeat
26
6
0
[Crystal clear] Powers of the adjacency matrix
Digits Doublets
3
0
0
except (ValueError, AssertionError)
Words Order
275
0
0
enumerate(text.split()) and increasing indexes
Words Order
1
10
2
collections.Counter for letters, min with key
The Most Wanted Letter
14
23
2
split and join ; partial(re.sub, r'\S+', inversion repl)
Backward Each Word
497
0
3
Three solutions
End Zeros
168
4
0
2-liner: 140 chars
Tree Walker
1
8
1
[typed] 3 simple functions
Tree Walker
20
2
2
First, improvable
YAML. List and Comments
5
3
0
basic 1-liner
Days Between
3
12
2
[v2] enumerate, try line.index, max(..., key=len)
Long Non Repeat
6
21
6
1-liner: simple min with key
Nearest Value
27
11
0
operator.itemgetter
Easy Unpack
168
5
2
9-liner: generator with itertools.accumulate for altitudes
Flood Area
5
7
1
try next / except / finally
Swap Nodes
66
2
0
enumerate iterable
Swap Nodes
18
9
1
First
Date and Time Converter
27
1
0
min & max with key
The Fastest Horse
40
4
0
two solutions
Easy Unpack
124
6
0
1-liner: sorted(key and reverse)[:limit]
Bigger Price
47
1
1
Second
Correct Sentence
573
0
0
1-liner: quick naming and weird slicing
Zigzag Array
1
15
4
with sens function
Zigzag Array
11
8
0
lambda all zip
Ascending List
58
6
1
next, datetime module
When is Friday?
25
6
0
3-liner: divmod(... ,2), slicing
Middle Characters
156
0
0
7-liner without modules
IP Network: Route Summarization
5
15
0
BFS
The Shortest Knight's Path
8
4
0
next(generator, 0)
The Good Radix
11
5
0
morse_decoder lambda function
Morse Decoder
50
8
0
One line of course
Transposed Matrix
46
5
1
Powers of the adjacency matrix of a graph to find a path between numbers
Digits Doublets
1
8
1
My "Digits Doublets" solution
Digits Doublets
13
4
1
Lambda function with sum/list comprehension, eval "&", "|" and "^".
Multiplication Table
2
8
1
My "long non repeat"
Long Non Repeat
22
6
0
Replace ',' and '.' by ' ', one split and it's over.
First Word
4
40
4
GitHub
group rays
Reversi: Othello Moves
2
0
0
reversed, take while equal
Common Tail
1
3
1
~i
Common Tail
1
29
3
iterative without regex, repeatable parts
Long Repeat Inside
20
0
0
Third [py3.10+]
Evenly Spaced Trees
102
0
1
[EAFP way] markers, forward/backward, right/left/first digits, checksum
Barcode Reader
32
0
0
[Typed OOP] Minimax strategy
Xs and Os Champion
38
0
0
First
Merge Intervals
4
19
1
Two solutions
Create Intervals
9
19
3
[9-liner] complex numbers / math formula and python3.8 for radius
Searchlights
6
4
0
21-liner: Dynamic programming to get scopes, heapq to minimize unsupplied cities
Power Plants
2
13
5
reduce, gcd and clear names
Evenly Spaced Trees
32
1
2
1-liner
Evenly Spaced Trees
1
8
1
Dijkstra with priority queue
The Cheapest Flight
2
40
10
Obvious 1-liner
Expand Intervals
66
3
0
union set of intervals, zip for union, enumerate(op, 1)
Painting Wall
27
3
0
simple
Power Supply
7
6
0
6-liner relatively clear/creative
Broken Clock
1
11
0
datetime.date of course
The Most Frequent Weekdays
35
6
0
scipy.ndimage for delete useless paper, numpy for movements and shape (a bit too complicated)
Paper Dice
4
0
1
Rotate/turn. Dimensions? Spaces? Sum 7?
Paper Dice
7
2
1
2-lines: SuperPhil15
Solution for Anything
19
9
1
First
Shooting Range
26
2
1
split('; ') and startswith(name+'=')
Cookies
67
2
0
My "long repeat inside" program
Long Repeat Inside
35
3
2
My solution
The End of Other
980
0
0
Max of a list of tuples with a key
The Highest Building
99
0
0
Area of a convex N-gon is area of N-2 triangles (with Heron's formula)
Area of a Convex Polygon
31
4
3
Dropbox
Dispatch
Collatz Ztalloc
5
0
2
Filter reversed text, join formatted text
Revorse the vewels
2
0
0
Bruteforced combinations(2)
Longest Substring of Unique Characters
2
5
0
sum divisors == 2 * ...
Perfect Number Checking
4
3
2
Simply import
Find Remainder
7
4
0
First
Integer Sign Determination
1
13
0
main[i:].startswith(sub)
Count Substring Occurrences
15
0
0
sum(starmap(!=, zip_longest))
Fuzzy String Matching
2
7
0
import, or reduce(mul, range, 1)
Number With Exclamation
5
5
0
str method
Convert To Title Case
11
3
0
2(L+W)
Rectangle Perimeter
6
6
1
Columns 0,1 OR naively
Exploring Wythoff Array
1
3
1
DFS (+ queen generalization)
Checkers Capture
6
0
0
sum(square_exist for each segment and orientation) // 4
Count Squares
1
0
0
Complex
Count Squares
1
10
2
Recursion
Count Morse
13
3
2
islice(cycle)
Fibonacci Spiral's End
2
8
0
islices
Fibonacci Poem
11
3
0
quick and dirty regexes
Reveal the Number
3
0
0
isdigit method
Is String a Number?
8
3
4
fullmatch
Is String a Number? (Part II)
6
5
0
Decimal
Is String a Number? (Part II)
22
0
3
sum(map(operator.ne
Not in Order
23
0
1
xs and ys both intersect
Interesting, intersecting
20
0
0
defaultdict(set)
Switch Keys to Values
1
19
1
First
URL Normalization
41
0
0
sum(map(str.isdigit, ...))
Count Digits
2
68
5
Two solutions
Sum Numbers
721
0
0
base = 10 or not ; divmod to find digits ; stop if encounter the maximal digit
Max Digit
4
8
0
1-liner: max(map(int, string number))
Max Digit
137
5
0
First
Three Points Circle
41
5
1
next palindromic substring by decreasing length
The Longest Palindromic
106
4
0
[15-lines] Timing a single recursive DFS
On the same path
4
7
5
[4-liner] 170 chars
On the same path
2
5
2
textwrap, operator.methodcaller, str.replace with all 3 arguments
Text Formatting
5
12
2
Counter, re.findall
Popular Words
398
2
0
Rajesh decorator: SOS I SEE 69 ...
The Best Number Ever
44
6
3
sympy with creative itertools
Hubspot Amulet
3
5
1
Bruteforce with improvements
Nonogram Row
12
0
0
Bruteforce with taken rows, columns, and descending/ascending diagonals
Place Queens
15
1
0
Max with a key, with a worth dict
Worth of Words
198
0
0
With dict of hashlib functions, utf-8 encode, hexdigest
Simple Hashlib
3
22
1
Compute volume and area of a spheroid
Humpty Dumpty Form
10
9
0
Simply my speech module
Speech Module
350
3
0
any, all boolean functions, string split
Three Words
3925
0
3
PyCon TW
match case
Simple Areas
87
3
0
blankplank's version, modified
Double Substring
34
0
0
Generate all electoral splits into districts, take the first good one
Unfair Districts
17
0
0
Hide parts of faces by cutting a rect into up to 4 sub-rects
Building Visibility
12
3
0
[typed] Cuboid class and volumes of the connected components of the graph
Fused Cubes
5
2
0
4-liner: scipy.ndimage.label
Calculate Islands
340
0
0
First
House Password
175
8
1
itertools.groupby to group consecutives, sum to sum
Sum Consecutives
7
12
0
Dijkstra
Express Delivery
5
5
1
Dijkstra
Network Attack
65
2
0
sympy.linsolve
How Much Gold
3
3
0
lambda next zip
Ryerson Letter Grade
4
20
1
try next
Robot Sort
15
3
0
[OOP] Map class (a bit too long)
Dark Labyrinth
3
0
0
Recursive solution with arguments row and col initialized to 0.
Golden Pyramid
44
7
1
Basic
Simple Areas
4
22
1
Basic
Digit Stack
75
3
1
Compare line[i:i+n] and line[j:j+n] for descending n and possibles (i,j).
Double Substring
75
2
2
Storage
str[pf]time, catch value errors
Convert Date
7
4
2
heapq, cut the search
Flip of Time
2
0
0
max, with a key
Latest ISO datetime
1
24
2
That's it?!
Latest ISO datetime
1
8
3
[v2] Dynamic programming, verbose OOP
Battle Dice
9
0
0
operator.itemgetter(1) itertools.groupby
Group Equal consecutive
18
12
0
[Typed OOP cached] Minimax strategy
Haunted House
43
0
0
Counter power recursively cached
Battle Dice
21
0
0
1-liner: itertools.groupby
Group Equal consecutive
20
10
2
3-lines: zips and slices
Group Equal consecutive
31
6
1
Basic loop
Group Equal consecutive
30
6
1
(1-2)-liner: numpy and math generalization
Skew-symmetric Matrix
33
1
6
count '.'*... / yield numbers
Restricted Prime
100
0
0
Dijkstra distance
Digging a Canal
55
0
0
lambda
Word Pattern
219
0
0
with re.findall and generators
Moria Doors
1
7
2
Itertools combinations, axis intersection and slope.
The Rows of Cakes
3
11
6
Swaps dict, list of disjoints cycles, and finally permutations to do
Mind Switcher
21
3
1
My english to braille translator
English to Braille Translator
11
3
1
My playfair cipher
Playfair Cipher
13
4
0
First
Earth Distances
7
5
3
Distance in one hexagonal coordinate system
Hexagon Spiral
7
2
1
With natural coordinate system
Square Spiral
5
5
1
Compute minima with key (sum of resistances)
Weak Point
78
4
0
My "Saw the Stick" program
Saw the Stick
45
3
1
First check the diagonal, then the bottom of the matrix.
Skew-symmetric Matrix
219
1
1
Maya
1-liner: Cryptic version of my clear code (py3.10)
House of Mirrors
1
0
0
[typed] Look at row/column counts, avoid cycles/articulation points/bridges, store "candidate/on track/secured" positions and partial tracks
Train Tracks
7
0
0
[typed] Light paths and backtrack on the position of the monsters
House of Mirrors
1
5
0
[Typed OOP] Grid parts of labelled cells (1.3 seconds)
Net Game
11
0
0
[Typed, bit of OOP] Rectangle intersections
Find Rectangles
2
1
0
[Typed OOP] Grid of switch & watcher cells
Visibilities
3
0
0
[typed] Apply the rule and a simple reasoning
Unruly
1
15
5
Unique neighbors and small paths search
Signpost
1
5
5
[actually inefficient] Maximize lit area with a priority queue
Light Up
1
10
6
v2: BFS to find gems, avoiding dead ends (detected by Kosaraju)
Inertia
1
10
0
Backtracking to avoid dead ends, BFS to find gems
Inertia
3
6
0
HubSpot
take the nth of the iterator of all answers
Fizz Buzz
54
3
2
dropwhile
Remove All Before
103
0
0
Generalization to any base 2-36 (and to negative fractions)
Repeating Decimals
2
0
0
Priority queue to maximize total length
Park Benches
11
1
0
ast module and collections.Counter
Count Comprehensions
3
2
0
try birthdate.replace(year=...)
Next Birthday
9
4
1
[py3.8+] 1-liner: walruses and datetime
Weekly Calendar
1
7
0
4-liner: date and timedelta from datetime module
Weekly Calendar
17
2
0
[py3.8+] 6-liner: DFS with 1-liner neighbors
Triangular Islands
1
0
2
DFS with neighbors function; math.isqrt
Triangular Islands
1
16
1
[py3.8+] 4-liner: binary search (3 lines) + workout lambda
Workout
1
0
0
Binary search, explicit number of sessions required
Workout
8
1
1
1-liner / 178 chars: scipy & walrus operator
Connect Stars
1
0
0
Easy with scipy
Connect Stars
2
0
0
Naive and short max
Home Coming
9
1
0
1-liner: naive max
Home Coming
1
2
1
Dynamic programming and itertools.accumulate
Family Dinner
6
1
1
4-liner: heapq.nlargest
Team Play
5
7
0
sum bool(striped line)
Non Empty Lines
49
1
0
is_divisible_by(2)
Is Even
51
8
0
sum, splitlines, strip
Non Empty Lines
62
0
0
[typed] Generate routes simultaneously, and a priority queue
Supply Stations
10
0
0
BFS resolution order and backtracking
Crossword Solver
6
5
2
sets of lower/upper letters
All Upper II
97
4
5
[::-1]
Backward String
542
1
0
string length
Number Length
407
1
0
try return slice except
Remove All Before
221
3
0
Three solutions + 1 in comments
Replace First
1
469
47
[py3.8+] 1-liner/98 chars with walrus/shifts operators
Univocalic davasaan
1
30
7
[8lines+old code] Rectangles based on edges from convex hull, change complex coordinates to have bounding boxes
Inscribe a Contour
5
3
6
[basic] text.index and slice
Between Markers (simplified)
804
0
0
text.split(maxsplit=1)[0]
First Word (simplified)
8
17
4
divmod%
Square Board
1
59
6
@join(',') on generator with Counter
Auto Painting
26
2
1
Tricky reversed use
The Hamming Distance
24
2
1
try except
Number Base
377
3
1
1-liner: join and replace
Right to Left
325
5
0
1-liner: [::2]
Even the Last
891
2
1
1-liner: array[bool][bool]
Fizz Buzz
10
20
1
Non recursive generalization (EAFP style)
Second Index
421
2
0
[numpy] 9-liner: Math magic with Markov chain
Expected Dice
5
0
2
recursively pop, length 42
Restricted Sum
336
3
1
With collections.Counter and cutting generator
Most Efficient Cutting
5
8
0
Minimal distance from Dijkstra on the war game map graph
Supply Line
9
4
4
First
Stressful Subject
14
15
6
Hamming Distance
The Hamming Distance
1250
0
2
Compute 'lengths' before compute decimals
Repeating Decimals
8
5
0
My "min" and "max" built-in functions
Min and Max
167
5
0
Blizzard
recursive with decreasing upperbounds
Sum of Distinct Cubes
4
0
0
[scipy 1.9+] milp: Mixed-integer linear programming
Knapsack Problem
1
9
0
Dynamic programming
Knapsack Problem
4
3
1
'[%s]' ; sep.join ; f'{n: >{w}'
List Beautify
4
3
0
generator
Move Zeros
5
8
2
([], [])[is_zero].append
Move Zeros
7
6
0
[py3.8+] 1-liner: 103 chars
Permutation Index
2
1
0
divmod
Weekend Counter
11
9
0
6-liner: Generator, divmod, list.pop, math.factorial
Reversed Permutation Index
1
24
3
n-th permutation and dichotomy
Permutation Index
6
5
0
All pairs of cities, all flights of minimal prices, multiple Dijkstra
Useless Flights
3
6
1
Backtracking
Sudoku Solver
51
0
2
Wagner-Fischer algorithm
String Conversion
5
11
2
10-lines: np.array, decreasing dimensions, next
Spaceship Landing Strip
4
0
0
2-lines: Bruteforce with integers
Rectangles Union
1
9
3
fromisoformat (with python 3.7)
The First Working Day
1
42
3
datetime
Unlucky Days
128
1
0
no fromisoformat?
The First Working Day
7
9
0
[200th mission] DFS and great neighbors function
Safe Coasts
3
9
1
DFS, itertools.count(1), collections.Counter
Radiation Search
16
0
0
"php\";
Palindromic Palindrome
2
5
0
It works
Stair Steps
28
5
0
My "The Angles of a Triangle" program
The Angles of a Triangle
176
4
2
Rock
NamedTuple
Rolling 🎲!
19
0
0
accumulate maxima
Replace with Biggest
24
0
0
max(right_elements, default=-1)
Replace with Biggest
23
0
0
match case sympy expand
Write Quadratic Equation
1
16
0
sympy expand
Write Quadratic Equation
2
8
1
Boring string manipulation
Write Quadratic Equation
5
5
1
[typed] BFS avoiding each other
Chicken Hunt
15
0
0
Mixed methods: Hamiltonian decompositions (extensions/reductions) & random seaches
Family Gifts
7
0
0
class BlackHole(sympy.Circle) & matplotlib visualization
Black Holes
7
0
0
[OOP, typed, doctests] Easy cases or BFS: list all boat loads
River Crossing
8
0
0
[23 useful lines] '@:', cube coords & components with DFS
Hexagonal Islands
7
3
1
join decorator on a generator
Parity Bit Generator
174
0
0
First
Web Log Sessions
6
0
0
Brute force a little bit smart
Water Jars
48
0
0
Newton's method for the search of the root of f(x) = x*log(x)-N.
Super Root
17
5
2
Shelter
1-liner: Code (py3.10) of Pouf's Boo, no space
Ghosts Age
156
0
0
Ugly speedy
Four To The Floor
2
6
2
3 lines wrote by a monster (363 chars)
Halloween Monsters
4
0
0
collections.Counter and a bit of itertools
Halloween Monsters
11
5
1
[v2] scipy.ndimage for simple peaks detection, multiple bfs to find explicit path
Climbing Route
10
0
0
Look at as few points as possible by dividing the rectangle until it is too small
Four To The Floor
1
25
5
Neighboring neighboring... area of obstacles and border
Landing Site
16
0
1
1-liner
Delivery Drone
1
1
1
25 lines: dot product with cube coords
Fortress Cannons
7
2
1
flow lru cached with zip and EAFP
The Lantern Festival
29
0
0
sets and sum of bools
Seven Segment
5
16
0
scipy.ndimage.label, multiple BFS and itertools.permutations (clear and relatively short)
Climbing Route
3
0
6
8-liner: pure numpy
Pattern Recognition
4
1
0
try iterate from it except TypeError
Completely Empty
13
8
1
First
The Nearest Square Number
25
0
0
Eulerian path
One line Drawing
6
9
0
Encode the list [0,1,2, ..., len(message)-1] to decode the message.
AMSCO Cipher
85
0
0
My first use of zip, zip_longest and accumulate. And useful slicing.
ADFGVX Cipher
10
5
0
Scary solution : come here to give me a vote or I take your sordid life
Ghosts Age
23
3
1
Codeship
Bruteforced recursion
The Centrifuge Problem
4
0
0
date time timedelta
Working Hours Calculator
1
9
0
Markov chain, numpy, scipy.sparse.spdiags
Pearls in the Box
6
1
3
[creative] Scientific imports + 1-liner: Markov chain
Pearls in the Box
1
6
1
v2: unoriented lines, generate square lines
The Square Chest
27
5
4
unoriented lines, generate square lines
The Square Chest
344
0
1
Priority queue (heapq) to find cherry, BFS to not be stuck
Snake Lite
17
0
0
Random backtracking with time limitation
Magic Domino
8
0
0
My solver with obvious and real searches
Minesweeper
9
3
1
6-liner: scipy.integrate and probabilities power
Probably Dice
1
11
0
BFS
The 88th Puzzle
18
1
1
OOP, Counter, combinations, lambdas
Texas Referee
2
14
1
Dijkstra, equation and round functions
Bats Bunker
4
8
3
Color Black/White stones graphs to get B/W territories, look B/W borders, sum lengths of B/W eaten territories
Eaten Go Stones
7
2
0
Color unoccupied points graph to get territories, look Black/White borders, sum lengths.
The Territory of Go
19
0
0
Define right move, deduce others moves
Behind 2048
58
0
0
My first real yield generator: recursively generates partitions/dices until we have solution (if it exists).
Unfair Dice
61
0
1
Markov chains
Pearls in the Box
17
0
0
Hermit
b/o/d/x format or handle as int
Integer Palindrome
6
0
0
1234321
Integer Palindrome
17
3
0
not str but math module
Integer Palindrome
27
0
0
str
Integer Palindrome
21
2
1
[typed] Coroutine, filters, cached expressions
Reverse Engineer
3
0
1
My 100th mission revisited with set methods
Break Rings
179
0
0
Coroutine
Colder-Warmer
8
1
2
Itertools & random powers
Reverse Engineer
15
0
0
Use infos to filter grid cells and pick any cell
Colder-Warmer
13
5
3
Generate big stacks with a bit of OOP
Stacking Cubes
3
5
2
[5th] 1-liner: count odd divisors, complexity: O(sqrt(n))
Count Consecutive Summers
10
1
0
[4th version] fast (and limited memory)
Count Consecutive Summers
3
7
0
[v3] 1-liner: count odd divisors (the naive way)
Count Consecutive Summers
1
145
17
[v2] count odd divisors with math formula
Count Consecutive Summers
172
0
1
lambda and math upper bound
Count Consecutive Summers
1
14
0
max(cycles generator, key=len, default=[])
Network Loops
14
3
1
4 clear lines: next(possible points generator)
Ore In The Desert
7
0
1
heapq, stacks memory, only 10 02 12 21 (not really good but it works)
Anagrams By Stacks
15
1
0
minimize errors
Mono Captcha
27
1
0
[OOP] "To infinity, and beyond !" for determine coefficients
Simplification
7
1
0
With fractions module, and divmod
Fractions Addition
16
3
1
Proud of my math skills to prove that ^^
Strawberry Fields
6
6
1
Keep or break the ring with a maximum of rings connected to it, that's the question
Break Rings
164
0
3
Watchtower
With continued fractions
Exploring Calkin-Wilf Tree
1
0
0
v2: Short thanks to scipy.ndimage.label
Boundary Blocks
4
0
0
3 guesses max: divisor with max futures remainders to divide possibilities
Number Guess
4
5
1
Trust the random on filtered possibilities
Bulls and Cows
43
0
0
[typed] Simplier than I thought
Ethernet Ring Dimensioning
53
0
0
1/e
Bag of Santa Claus
20
1
0
[1-liner 257 chars] sympy.Matrix, reduced row-echelon form mod 2, last column
Wall Keeper
9
0
0
[13 clear lines] Numpy array mod 2
Wall Keeper
5
0
0
Short thanks to scipy.ndimage.label
Boundary Blocks
1
14
10
Generate all solutions: sympy to solve linear equation system, itertools for bruteforce.
Magic Square
2
0
0
Dynamic Programming: (lcs set, common length) table
DNA Common Sequence
7
4
0
scipy.ndimage power
Bacteria Colonies
2
3
0
try except, slope, min/max with key, bad complexity
Convex Hull
21
1
1
Descending score, exclude cases, positionning and flip chips
Numbered Triangles
72
0
0
Best solution for a M x N grid, using matrices (modulo 2)
Wall Keeper
42
0
1
Find the right key...
Vigenere Cipher
17
3
1
Escher
I wanted to use itertools.filterfalse alongside with filter
The Ship Teams
10
4
0
First
Treasures
45
0
0
with python 3.8+
Keys and Locks
16
5
0
3-lines: Counter
The Tower
1
11
2
color counter and rearrangements
The Tower
17
0
0
Neighboring coordinates?
Hypercube
15
2
1
@maxi(paths generator)
Graphical Key
2
12
12
Buttons generator (with DFS) and a reverse_sorting decorator
The Buttons
2
11
2
Try to remove from deck with sorted hand
Card Game
3
16
1
With lru_cache/setrecursionlimit and without
The Stones
8
9
1
next(generator, -1), eval and re
Safe Code
7
8
0
sum bool
The Secret Room
1
23
4
with collections.Counter
Wild Dogs
3
16
1
min(enumerate(cols(wall)), count '#' lambda key)[0]
The Stone Wall
2
8
0
with items coordinates dictionary (so seaside traveled once)
Compass, Map and Spyglass
1
19
1
strip and split with \n, zip(*rows)
Ground for the House
29
6
1
lambda function [sorted(gen), sorted(gen)]
The Ship Teams
42
6
0
Not On Map
First
Word Search
2
0
0
String method "__len__"
Length of the String
12
3
3
just the built-in function "len" really
Length of the String
34
0
1
Composition/functools: three uses of itertools, one counter
Aggregate and Count
1
5
0
1-liner: three uses of itertools, one counter
Aggregate and Count
3
10
1
divmod to list digits
Base change - Position System
6
0
0
with collections.Counter
Most Wanted Letter
1
13
0