Day 17 - very slight performance improvement by making oneth strict
This commit is contained in:
parent
812cae03d3
commit
d7ec7ed65b
2
17.hs
2
17.hs
|
@ -11,7 +11,7 @@ postNth n pos list =
|
||||||
|
|
||||||
oneNth :: Int -> Int -> Int -> Int
|
oneNth :: Int -> Int -> Int -> Int
|
||||||
oneNth 50000001 _ oneth = oneth
|
oneNth 50000001 _ oneth = oneth
|
||||||
oneNth n pos oneth =
|
oneNth n pos !oneth =
|
||||||
let !newPos = (pos + steps % n + 1) % n
|
let !newPos = (pos + steps % n + 1) % n
|
||||||
!newOneth = if newPos == 0 then n else oneth
|
!newOneth = if newPos == 0 then n else oneth
|
||||||
in oneNth (n + 1) newPos newOneth
|
in oneNth (n + 1) newPos newOneth
|
||||||
|
|
|
@ -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 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
|
||||||
|
|
Loading…
Reference in New Issue