aboutsummaryrefslogtreecommitdiff
path: root/codewars/6-kyu/pyramid-array
diff options
context:
space:
mode:
authorMistivia <i@mistivia.com>2024-02-06 14:47:12 +0800
committerMistivia <i@mistivia.com>2024-02-06 14:47:12 +0800
commitd5f96f998dad241c127c2ddc884dffd5b913f5ed (patch)
tree1dcb33c04eb1f41b5d7862203bc73ba2e3fc4958 /codewars/6-kyu/pyramid-array
parente056b485e566861ddebdb76e750aac5574dd4d7b (diff)
sovle codewars 6-kyu pyramid array
Diffstat (limited to 'codewars/6-kyu/pyramid-array')
-rw-r--r--codewars/6-kyu/pyramid-array/solution.rkt14
1 files changed, 14 insertions, 0 deletions
diff --git a/codewars/6-kyu/pyramid-array/solution.rkt b/codewars/6-kyu/pyramid-array/solution.rkt
new file mode 100644
index 0000000..0d6a00b
--- /dev/null
+++ b/codewars/6-kyu/pyramid-array/solution.rkt
@@ -0,0 +1,14 @@
+#lang racket
+
+;; https://www.codewars.com/kata/515f51d438015969f7000013
+
+(provide pyramid)
+
+(define (pyramid n)
+ (define (loop ret level cur)
+ (define next (cons 1 cur))
+ (if (= level n)
+ (reverse ret)
+ (loop (cons next ret) (+ level 1) next)))
+ (loop '() 0 '()))
+