Improve code

This commit is contained in:
Daniele Fucini committed 2024-12-06 19:55:10 +01:00
1 parent a94312463b
commit 1b5a8ee458
3 files changed
+9 -11

No files matched your search

+2 -2
View File
@@ -2,9 +2,9 @@ import Data.List (sort, inits, tails)
isSafe :: [Int] -> Bool
isSafe xs = (isAscending xs || isDescending xs) && maximum distances <= 3 && minimum distances >= 1
where isAscending xs = xs == sort xs
where isAscending xs = xs == sort xs
isDescending xs = xs == reverse (sort xs)
distances = map abs $ zipWith (-) xs (tail xs)
distances = map abs $ zipWith (-) xs (tail xs)
removeLevel :: [Int] -> [[Int]]
removeLevel xs = zipWith (++) ys zs