aboutsummaryrefslogtreecommitdiff
path: root/challenge-045/archargelod
diff options
context:
space:
mode:
authorArchargelod <archargelod@gmail.com>2024-03-23 13:33:35 +0800
committerArchargelod <archargelod@gmail.com>2024-03-23 13:33:35 +0800
commit3a120930c5773eba4641d49e02ea5e58c12dcfcb (patch)
tree703beab5827accad694e4d0ae60c5edf8e69ecf9 /challenge-045/archargelod
parent8e95e94de527f8344f979dbb45b935139b1ddeb7 (diff)
downloadperlweeklychallenge-club-3a120930c5773eba4641d49e02ea5e58c12dcfcb.tar.gz
perlweeklychallenge-club-3a120930c5773eba4641d49e02ea5e58c12dcfcb.tar.bz2
perlweeklychallenge-club-3a120930c5773eba4641d49e02ea5e58c12dcfcb.zip
weeks 41-47, 260, 261 in Nim
Diffstat (limited to 'challenge-045/archargelod')
-rw-r--r--challenge-045/archargelod/README1
-rwxr-xr-xchallenge-045/archargelod/nim/ch_1.nim26
-rwxr-xr-xchallenge-045/archargelod/nim/ch_2.nim18
3 files changed, 45 insertions, 0 deletions
diff --git a/challenge-045/archargelod/README b/challenge-045/archargelod/README
new file mode 100644
index 0000000000..6cd57e1074
--- /dev/null
+++ b/challenge-045/archargelod/README
@@ -0,0 +1 @@
+Solution by archargelod
diff --git a/challenge-045/archargelod/nim/ch_1.nim b/challenge-045/archargelod/nim/ch_1.nim
new file mode 100755
index 0000000000..40c642133f
--- /dev/null
+++ b/challenge-045/archargelod/nim/ch_1.nim
@@ -0,0 +1,26 @@
+#!/usr/bin/env -S nim r -d:release --verbosity:0 --hints:off
+import std/[strutils, sequtils]
+
+proc squareCoded(input: string): string =
+ const Columns = 8
+ let input = input.filterIt(it in Letters).toLower()
+
+ for x in 0..<Columns:
+ var y = 0
+ while y * Columns + x < input.len:
+ result.add input[y * Columns + x]
+ inc y
+ result.add ' '
+
+ result.setLen(result.len - 1)
+
+when isMainModule:
+ import std/unittest
+
+ const
+ Test = "The quick brown fox jumps over the lazy dog"
+ Expected = "tbjrd hruto eomhg qwpe unsl ifoa covz kxey"
+
+ suite "Square secret code":
+ test "":
+ check squareCoded(Test) == Expected
diff --git a/challenge-045/archargelod/nim/ch_2.nim b/challenge-045/archargelod/nim/ch_2.nim
new file mode 100755
index 0000000000..1fb1389dda
--- /dev/null
+++ b/challenge-045/archargelod/nim/ch_2.nim
@@ -0,0 +1,18 @@
+#!/usr/bin/env -S nim r -d:release --verbosity:0 --hints:off
+let lines = [
+ "#!/usr/bin/env -S nim r -d:release --verbosity:0 --hints:off",
+ "let lines = [",
+ "]",
+ "echo lines[0]",
+ "echo lines[1]",
+ "for d in lines:",
+ " echo ' ', ' ', chr 34, d, chr 34, ','",
+ "for d in lines[2..^1]:",
+ " echo d",
+]
+echo lines[0]
+echo lines[1]
+for d in lines:
+ echo ' ', ' ', chr 34, d, chr 34, ','
+for d in lines[2..^1]:
+ echo d