Created
June 8, 2022 12:30
-
-
Save fabienhinault/f8261886994ab7f2352b937fb2778f93 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (square x) (* x x)) | |
(define (sum-of-squares x y)(+ (square x) (square y))) | |
(define (sum-of-squares-a-max-b-c a b c) | |
(if (< b c) | |
(sum-of-squares a c) | |
(sum-of-squares a b))) | |
(define (sum-of-squares-2-greatests x y z) | |
(if (< x y) | |
(sum-of-squares-a-max-b-c y x z) | |
(sum-of-squares-a-max-b-c x y z))) | |
(define (return-sum-of-squares-2-greatests x y z) | |
(tr (reverse-string (~a (sum-of-squares-2-greatests x y z))))) | |
(define (reverse-string s) | |
(list->string (reverse (string->list s)))) | |
(define (tr s) | |
(list->string (map tr-char (string->list s)))) | |
(define chars (list #\0 #\⇂ #\ح #\Ɛ #\ㄣ #\ϛ #\9 #\𝘓 #\8 #\6)) | |
(define _0 (char->integer #\0)) | |
(define (tr-char c) | |
(list-ref chars (- (char->integer c) _0))) | |
(writeln (return-sum-of-squares-2-greatests 5 0 0)) | |
(writeln (sum-of-squares-2-greatests 2 3 1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment