Day 17 - very slight performance improvement by making oneth strict

This commit is contained in:
Jonathan Chan 2017-12-23 17:23:29 -08:00
parent 812cae03d3
commit d7ec7ed65b
2 changed files with 3 additions and 3 deletions

2
17.hs
View File

@ -11,7 +11,7 @@ postNth n pos list =
oneNth :: Int -> Int -> Int -> Int
oneNth 50000001 _ oneth = oneth
oneNth n pos oneth =
oneNth n pos !oneth =
let !newPos = (pos + steps % n + 1) % n
!newOneth = if newPos == 0 then n else oneth
in oneNth (n + 1) newPos newOneth

View File

@ -35,6 +35,6 @@ These are the runtimes of only one trial but the variances are fairly small and
Problems that should be optimized further: 15
Problems that could use some work: 05, 22, 14, 21
Problems that could use some work: 05, 22, 14, 21, 17
Problems that are good enough with optimizations: 17, 13
Problems that are good enough with optimizations: 13