Jane Street

Based on real interviews

Find a Connect K winner

Follow a sequence of moves and identify the first player to form a winning line on a configurable board.

Unlock with Full Access

The challenge

Two players drop pieces into columns, where each piece falls to the lowest available position. The board dimensions and the required line length can change. Implement the game logic that updates the board and detects a horizontal, vertical or diagonal win as moves arrive.

What you'll practise

  • Board state

    Place alternating players' pieces in the correct positions as columns fill.

  • Directional checks

    Detect winning lines across rows, columns and both diagonal directions.

  • Game boundaries

    Handle different board sizes, short winning lines and games without a winner.

Your coding workspacePreview
solution.pyPython 3.13
def connect_k_winner(
    rows, columns, k, moves
):
    # Your implementation goes here
    pass
Test cases

Run your code to see results.

Full instructions, starter code and test cases included with Full Access.