Skip to content

Commit 06e9470

Browse files
committed
Added imperative clockhands solution
1 parent 1a379ed commit 06e9470

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

racket/clockhands_imperative.rkt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
(for ([i 11])
2+
(define t (floor (/ (+ (* 43200 i) 21600) 11)))
3+
(define-values (h m s)
4+
(values (floor (/ t 3600))
5+
(remainder (floor (/ t 60)) 60)
6+
(remainder t 60)))
7+
(printf "~a:~a:~a~n"
8+
(~a (if (= h 0) 12 h) #:width 2 #:align 'right #:left-pad-string "0")
9+
(~a m #:width 2 #:align 'right #:left-pad-string "0")
10+
(~a s #:width 2 #:align 'right #:left-pad-string "0")))

racket/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+
racket -f "$PSScriptRoot\clockhands_imperative.rkt" |
13+
Compare-Object (Get-Content "$PSScriptRoot\..\test\clockhands_expected") |
14+
Assert-MatchTests &&
1215
racket -f "$PSScriptRoot\clockhands.rkt" |
1316
Compare-Object (Get-Content "$PSScriptRoot\..\test\clockhands_expected") |
1417
Assert-MatchTests &&

0 commit comments

Comments
 (0)