Skip to content

Instantly share code, notes, and snippets.

View kruszczynski's full-sized avatar
🎛️
Softer Developer

Bartek Kruszczynski kruszczynski

🎛️
Softer Developer
View GitHub Profile
@kruszczynski
kruszczynski / tennis-08.md
Created August 25, 2026 09:30
Tennis tournament exercise, part 08

Stage 8: the rights holders return

Reason about these out loud. No implementation needed.

  1. Three teams. They now want players split across Team A, B and C, same rule: no player faces a teammate. How does your approach change?

  2. Best effort. The fixture list has no valid two-team split, but they refuse to drop matches. Instead they want the assignment that honours as many of the requested matches as possible. What is this problem?

@kruszczynski
kruszczynski / tennis-05.md
Created August 25, 2026 09:30
Tennis tournament exercise, part 05

Stage 5: a full season

The rights holders come back with the real fixture list.

matches = [[f"player{i}", f"player{i+1}"] for i in range(50_000)]

Run it.

@kruszczynski
kruszczynski / tennis-04.md
Created August 25, 2026 09:30
Tennis tournament exercise, part 04

Stage 4: hostile inputs

The match list arrives as JSON over an API from a third party. You do not control what they send.

[]                                        # no matches at all
[["Alice", "Alice"]]                      # a player against themselves
[["Alice", "Bob"], ["Alice", "Bob"]]      # the same match twice
[["Alice"]] # arity is not guaranteed
@kruszczynski
kruszczynski / tennis-03.md
Last active August 25, 2026 11:36
Tennis tournament exercise, part 03

Stage 3

matches = [["Alice", "Bob"], ["Yuki", "Zoe"]]
@kruszczynski
kruszczynski / tennis-02.md
Last active August 25, 2026 11:36
Tennis tournament exercise, part 02

Stage 2

matches = [["Alice", "Bob"], ["Charlie", "David"], ["Alice", "Charlie"], ["Bob", "David"]]
@kruszczynski
kruszczynski / tennis-00.md
Created August 25, 2026 09:30
Tennis tournament exercise, part 00

Tennis tournament: two teams

You are organising a tennis tournament, albeit one in a strange format.

The TV rights holders hand you a list of singles matches (1v1) they want to see. To add drama, they also insist on a team element: every player is put on either Team A or Team B, and a player must never face someone from their own team.

Given the list of matchups, assign every player to a team.

We can make this file beautiful and searchable if this error is corrected: It looks like row 7 should actually have 8 columns, instead of 3 in line 6.
product_feed_id,product_id,product_photo,product_name,influencer_name,brand_name,popularity_score,influencer_pic
608,20.0,https://static.getprophet.io/xb3rlkbe8vde0jeq1pdnob86gakq,Ayres Chambray,johann,Mr Cena & Friends,7.0,https://static.getprophet.io/oj8vzzofdqzwvr5noajbdenvpnol
608,27.0,https://static.getprophet.io/fnft28pra8rfp1souo5bcs51fm4c,Chevron,johann,Mr Cena & Friends,3.0,https://static.getprophet.io/oj8vzzofdqzwvr5noajbdenvpnol
608,36.0,https://static.getprophet.io/pu29mg4onmvjjlpo851kiabv3a92,Derby Tier Backpack,johann,Mr Cena & Friends,9.0,https://static.getprophet.io/oj8vzzofdqzwvr5noajbdenvpnol
608,40.0,https://static.getprophet.io/bhz3vx7g45qy81ut99sddzvg91wa,Duckworth Woolfill Jacket,johann,Mr Cena & Friends,10.0,https://static.getprophet.io/oj8vzzofdqzwvr5noajbdenvpnol
608,54.0,https://static.getprophet.io/9wyn8ut9ct9h7c0wbsjnxe4wlr83,Guaranteed,johann,Mr Cena & Friends,18.0,https://static.getprophet.io/oj8vzzofdqzwvr5noajbdenvpnol
608,99.0,https://static.getprophet.io/ihnj1gk9pj7guclszfv49

SQL

Schema

clients
 - id
 - email

Given an array of positive integers, write a function which returns all the unique pairs which add (equal) up to 100.

Example data:

sample_data = [0, 1, 100, 99, 0, 10, 90, 30, 55, 33, 55, 75, 50, 51, 49, 50, 51, 49, 51]
sample_output = [[1,99], [0,100], [10,90], [51,49], [50,50]]
@kruszczynski
kruszczynski / keybase.md
Created December 21, 2018 09:11
Keybase

Keybase proof

I hereby claim:

  • I am kruszczynski on github.
  • I am kruszczynski (https://keybase.io/kruszczynski) on keybase.
  • I have a public key ASCxlKlZxWAeFt66_f0E03h8a-_W-I0x9sooBJaxnCBPlAo

To claim this, I am signing this object: