Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
18
Task/Floyds-triangle/Racket/floyds-triangle.rkt
Normal file
18
Task/Floyds-triangle/Racket/floyds-triangle.rkt
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#lang racket
|
||||
(require math)
|
||||
|
||||
(define (tri n)
|
||||
(if (zero? n) 0 (triangle-number n)))
|
||||
|
||||
(define (floyd n)
|
||||
(define (width x) (string-length (~a x)))
|
||||
(define (~n x c) (~a x
|
||||
#:width (width (+ (tri (- n 1)) 1 c))
|
||||
#:align 'right #:left-pad-string " "))
|
||||
(for ([r n])
|
||||
(for ([c (+ r 1)])
|
||||
(display (~a (~n (+ (tri r) 1 c) c) " ")))
|
||||
(newline)))
|
||||
|
||||
(floyd 5)
|
||||
(floyd 14)
|
||||
Loading…
Add table
Add a link
Reference in a new issue