aboutsummaryrefslogtreecommitdiff
path: root/leetcode/lc-1037-boomerang.rkt
diff options
context:
space:
mode:
authorH.J <thechairman@thechairman.info>2024-10-09 11:36:55 -0400
committerH.J <thechairman@thechairman.info>2024-10-09 11:36:55 -0400
commit8777ff071f7bb37631baa7b6717ad29961e50911 (patch)
tree6d59c4ed58e454b960339c3d1151f0a879e8d7cb /leetcode/lc-1037-boomerang.rkt
parent6156a9ef7be4012063a042aafb4e9b0d7eadde8e (diff)
downloadgleam_aoc-8777ff071f7bb37631baa7b6717ad29961e50911.tar.gz
gleam_aoc-8777ff071f7bb37631baa7b6717ad29961e50911.zip
sorting by language
Diffstat (limited to 'leetcode/lc-1037-boomerang.rkt')
-rw-r--r--leetcode/lc-1037-boomerang.rkt21
1 files changed, 0 insertions, 21 deletions
diff --git a/leetcode/lc-1037-boomerang.rkt b/leetcode/lc-1037-boomerang.rkt
deleted file mode 100644
index fd95695..0000000
--- a/leetcode/lc-1037-boomerang.rkt
+++ /dev/null
@@ -1,21 +0,0 @@
-#lang racket
-(define/contract (is-boomerang points)
- (-> (listof (listof exact-integer?)) boolean?)
- (match points
- [(list-no-order a b c) #:when (equal? a b) #false] ; Are any two points the same?
- [(list (list x _) (list x _) (list x _)) #false] ; Are they on a horizontal line?
- [(list (list _ y) (list _ y) (list _ y)) #false] ; Are they on a vertical line?
- [(list-no-order (list x1 _) (list x2 _) (list x3 _)) ; Are two points on a horizontal line,
- #:when (and (= x1 x2) ; but the third point isn't?
- (not (= x1 x3))) #true]
- [(list-no-order (list _ y1) (list _ y2) (list _ y3)) ; Are two points on a vertical line,
- #:when (and (= y1 y2) ; but the third point isn't?
- (not (= y1 y3))) #true]
- [(list (list x1 y1) (list x2 y2) (list x3 y3)) ; If none of the special cases apply,
- (let ([m (/ (- y2 y1) (- x2 x1))]) ; calculate the slope between two points
- (not (= y3 (+ y1 (* m (- x3 x1))))))])) ; and see if the line passes through the third
-
-(is-boomerang '((1 1) (2 3) (3 2)))
-(is-boomerang '((1 1) (2 2) (3 3)))
-(is-boomerang '((0 0) (0 2) (2 1)))
-(is-boomerang '((0 0) (1 1) (1 1))) \ No newline at end of file