This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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?" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ----- Imports ----- # | |
import json | |
# ----- Setup ----- # | |
# This file must be json, a map of colour strings to number values. | |
CHIP_VALUES_FILE = 'chip-values.json' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from num2words import num2words as tw | |
print([x for x in range(100) if tw(x) == ''.join(sorted(tw(x)))][0]) |