Skip to content

Instantly share code, notes, and snippets.

@Ap0c
Ap0c / age.py
Created October 27, 2016 13:28
from num2words import num2words as tw
print([x for x in range(100) if tw(x) == ''.join(sorted(tw(x)))][0])
@Ap0c
Ap0c / poker_total.py
Last active May 10, 2017 18:47
Calculates the total value of a pile of poker chips, because counting can be hard sometimes. Requires a json file with the chip values (colour -> number map).
# ----- Imports ----- #
import json
# ----- Setup ----- #
# This file must be json, a map of colour strings to number values.
CHIP_VALUES_FILE = 'chip-values.json'
@Ap0c
Ap0c / toh.hs
Created April 15, 2018 22:06
The start of a solution to the tower of hanoi.
import System.Environment
import qualified Data.Bifunctor as BF (first)
import Text.Read (readEither)
numberOfRings :: [String] -> Either String Int
numberOfRings [] = Left "You didn't give me the number of rings!"
numberOfRings [n] = BF.first intError $ readEither n
where intError _ = "That's not a valid integer..."
numberOfRings _ = Left "What's all this?"