Solving the Technical Interview

adhi011 pts0 comments

Solving the technical interview  ❤︎  samir : coffee → nonsense

Solving the technical interview

by Samir Talwar

Saturday, 23 May 2026 at 09:00 CEST

With apologies to Aphyr.

You heave a sigh and get up from your desk, stopping by the kitchenette for a tea and a biscuit on the way to the meeting room. Recruiting for this role has not been going well, and your manager is starting to get nervous.

Nervous is bad. Nervous means more scrutiny, more questions, more micro-management. And nervous means you get nervous too. You can feel your heart beat faster as you walk over to the interview room. You can see a sillhouette through the frosted glass door; they must already be waiting for you.

You take a deep breath. The last few candidates have all been a little… odd. Let’s hope this one makes life a bit easier for you. You could use a win.

You stride in. “Um, hello.”

“Hello, dear! It’s lovely to meet you.”

You pause. Seated at the conference table is an older woman, full of smiles, unapologetically beaming at you, half a biscuit in her hand, a laptop in front of her. As she opens it, you notice that it seems to have seen better days; its keyboard is covered in cake crumbs, the trackpad has been worn smooth, the hinge creaks, and a fan roars to life.

You relax a little. Perhaps this won’t be like the one last month. Or the one last week.

“I’m ready when you are, sonny jim.”

You try not to appear taken aback by her familiarity, as you stammer out the start of the problem statement.

“Are you familiar with chess?”

She frowns at you. The light flickers. You meet her eyes, and are whisked away. A horse, rearing, its rider vaulting over a warrior with a pike. A man of God speaks, his voice booming, a tower crumbles. A queen stands over a king, with her dagger pointed at his neck, her face steeled even as tears form in her eyes.

Was it a moment, or a lifetime?

“Yes, I am. Intimately, you might say.” She offers you a wink. You’re not sure why.

“Well,” you stammer, “imagine a chessboard. The problem is called N-Queens. For a given chessboard of size N×N, you need to find a way to place N queens on that board, safely. Don’t worry about actually solving—”

“Safely, you say? Surely that depends on the queen?”

“Well… um. In this situation, imagine they all move like chess queens, and they want to capture each other. You need to find a way to place them all so none of them can reach another.”

“Yes, I’ve dealt with royalty before. Best to keep them in separate castles. But if you can’t, let’s at least be clever about the seating plan.”

She starts typing:

{-# LANGUAGE GHC2024 #-}<br>{-# LANGUAGE BlockArguments #-}<br>{-# OPTIONS_GHC -Wno-name-shadowing #-}

“Er… what’s this?”

“We want a fair game, don’t we? No arguments, no subterfuge.”

module Main where

import Control.Monad ((>=>))<br>import Data.Char qualified as Char<br>import Data.Maybe (listToMaybe)<br>import Data.List qualified as List<br>import Prelude hiding (negate)<br>import System.Environment (getArgs)

Suddenly, a memory, and not a positive one. “Hang on, is this Haskell? Um… I must warn you we haven’t had great experiences with all of that type-level trickery here.”

“Oh, very good. No, I don’t hold to that myself, either. You know where you are with variables, I always say. Types should be kept simple. Code is for humans to read, as they say!”

A weight on your chest starts to ease up. You hadn’t realised it was there.

“Ah, phew. Please, carry on.”

“Well, speaking of variables, let’s make some.”

newtype Var = Var Int<br>deriving newtype (Eq, Enum)

data Term a<br>= TAtom a<br>| TVar Var<br>deriving stock (Eq)

You start to interrupt, but she’s typing furiously now, and the clacking of the keyboard (why does it sound like a typewriter?) drowns out your question.

type Knowledge a = [(Var, Term a)]

She stops, for a moment. “A tree of knowledge. And one must climb it.”

climb :: Knowledge a -> Term a -> Term a<br>climb _ term@TAtom {} = term<br>climb knowledge (TVar v) =<br>maybe (TVar v) (climb knowledge) $ lookup v knowledge

“Climb until the branch yields fruit. No more.”

“Er… how does this—”

Her eyes snap upwards, meeting yours. A woman, naked, reaches toward an apple, hanging from a tree. She takes it, bites it. Her eyes widen. Oblivion.

You stop talking.

“One cannot simply have knowledge, of course. We learn.”

type Lesson a = State a -> [State a]

data State a = State Var (Knowledge a)

emptyState :: State a<br>emptyState = State (Var 0) []

“Hang on, what’s a state?”

She smiles at you. “Haskell is a functional programming language. No mutation. When you learn, you are not the same person as before. The program isn’t either. To learn, it must transition, from state to state. You’re learning Haskell right now, aren’t you? And you won’t be the same person at the end of this conversation as you were at the beginning, let me tell you!”

You nod, your mouth shut. It seems safer.

“The first lesson is that if what we know is wrong, we know nothing.”

falsity :: Lesson a<br>falsity =...

state knowledge import term climb nervous

Related Articles