Skip to content

Commit dfa8b94

Browse files
committed
1st commit on 023
1 parent 9876b1a commit dfa8b94

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

challenge-023/stuart-little/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solutions by Stuart Little
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env perl6
2+
use v6;
3+
4+
sub dff(@a where {$_.all ~~ Int}) {
5+
@a.rotor(2 => -1).map({ $_[1] - $_[0] })
6+
}
7+
8+
for (1..@*ARGS[0].Int).map({ reduce { $^b.($^a) }, @*ARGS[1..*].map(*.Int), |(&dff xx $_) }) {.say}
9+
10+
# run as <script> <number of difference iterations> <space-separated integer array entries>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env perl6
2+
use v6;
3+
4+
my @PRIMES=(2..*).grep(*.is-prime);
5+
6+
sub fct($n,@a) {
7+
$n.abs == 1 && return @a;
8+
my $fact=@PRIMES.first($n %% *);
9+
return fct(($n div $fact), (|@a,$fact));
10+
}
11+
12+
say @*ARGS[0].Int.&fct(())
13+
14+
# run as <script> <integer>

0 commit comments

Comments
 (0)