Skip to content

Commit 6446e54

Browse files
committed
Added clockhands from Toal's website example
1 parent 52082c5 commit 6446e54

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

nim/clockhands.nim

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import std/strformat
2+
3+
for i in 0..10:
4+
let t = (43200 * i + 21600) div 11
5+
let h = t div 3600
6+
let m = (t div 60) mod 60
7+
let s = t mod 60
8+
echo &"{(if h == 0: 12 else: h):02}:{m:02}:{s:02}"

nim/test.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ function Assert-MatchTests {
99
}
1010

1111
$Error.clear()
12+
nim c "$PSScriptRoot\clockhands.nim" && . "$PSScriptRoot\clockhands.exe" |
13+
Compare-Object (Get-Content "$PSScriptRoot\..\test\clockhands_expected") |
14+
Assert-MatchTests &&
1215
nim c "$PSScriptRoot\permutations.nim" && . "$PSScriptRoot\permutations.exe" I like carrots |
1316
Compare-Object (Get-Content "$PSScriptRoot\..\test\carrots_expected") |
1417
Assert-MatchTests &&

0 commit comments

Comments
 (0)