aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Shitov <andy@shitov.ru>2020-07-20 08:30:04 +0200
committerAndrew Shitov <andy@shitov.ru>2020-07-20 08:30:04 +0200
commit0624537a1f36a9c9fdab487b6a47c23b9a54e421 (patch)
treeb674ff85717f404bf8ed4fa74364c6a00a806303
parent18a47cdd093ec8335cc7faa919f2f63c20e31ac3 (diff)
downloadperlweeklychallenge-club-0624537a1f36a9c9fdab487b6a47c23b9a54e421.tar.gz
perlweeklychallenge-club-0624537a1f36a9c9fdab487b6a47c23b9a54e421.tar.bz2
perlweeklychallenge-club-0624537a1f36a9c9fdab487b6a47c23b9a54e421.zip
ash 070-2
-rw-r--r--challenge-070/ash/raku/ch-2.raku14
1 files changed, 14 insertions, 0 deletions
diff --git a/challenge-070/ash/raku/ch-2.raku b/challenge-070/ash/raku/ch-2.raku
new file mode 100644
index 0000000000..9da4e74097
--- /dev/null
+++ b/challenge-070/ash/raku/ch-2.raku
@@ -0,0 +1,14 @@
+#!/usr/bin/env raku
+
+# Task 2 from
+# https://perlweeklychallenge.org/blog/perl-weekly-challenge-070/
+
+# Comments: https://andrewshitov.com/2020/07/20/gray-code-in-raku/
+
+# Usage:
+# $ raku ch-2.raku 4
+
+put map {$_ +^ ($_ div 2)}, ^2**@*ARGS[0];
+
+# Output for N = 4 (4 bits)
+# 0 1 3 2 6 7 5 4 12 13 15 14 10 11 9 8