The Tyranny of the Timed Coding Test

The tic-tac-toe example

[[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[2,0],[2,1],[2,2]].find(([row, col]) => this.board[row][col] === "-") => row.join("|")).join("\n")

The amicable pairs coding test

// Given one number, make an amicable pair.
const makePair = n => [n, aliquot(n)];
// Given a pair of numbers, make sure it is an amicable pair.
const isPair = ([n, m]) => m > n && aliquot(m) === n;
// Count the number of amicable pairs up to some value.
function amicablePairs(n) {
return range(1, n) . map(makePair) . filter(isPair);
const add = (a, b) => a + b;
const sum = a => a.reduce(add, 0);
const divisors = n => range(1, n - 1).filter(i => !(n % i));
const range = (n, m) => Array.from(Array(m - n), (_, i) => i + n);
const aliquot = n => sum(divisors(n));
const count = (a, f) => a.filter(f).length;

Is it just me?

So what’s the alternative?




Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Bob Myers

Bob Myers

Technologist/author/translator mainly writing about computing