diff options
| author | Luca Ferrari <fluca1978@gmail.com> | 2020-05-04 14:12:36 +0200 |
|---|---|---|
| committer | Luca Ferrari <fluca1978@gmail.com> | 2020-05-04 14:12:36 +0200 |
| commit | ebac4b18af015635450325e7c770794cd70a6d2c (patch) | |
| tree | 93e3b7e278fdcd77df96abe27f9a17341333ecca /challenge-059 | |
| parent | c514bff6d2807e124729403c18b4190d251b0e2d (diff) | |
| download | perlweeklychallenge-club-ebac4b18af015635450325e7c770794cd70a6d2c.tar.gz perlweeklychallenge-club-ebac4b18af015635450325e7c770794cd70a6d2c.tar.bz2 perlweeklychallenge-club-ebac4b18af015635450325e7c770794cd70a6d2c.zip | |
Task one done.
Diffstat (limited to 'challenge-059')
| -rw-r--r-- | challenge-059/luca-ferrari/raku/ch-1.p6 | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/challenge-059/luca-ferrari/raku/ch-1.p6 b/challenge-059/luca-ferrari/raku/ch-1.p6 new file mode 100644 index 0000000000..ad73ef8831 --- /dev/null +++ b/challenge-059/luca-ferrari/raku/ch-1.p6 @@ -0,0 +1,28 @@ +#!env raku + + +# You are given a linked list and a value k. +# Write a script to partition the linked list such that all nodes +# less than k come before nodes greater than or equal to k. +# Make sure you preserve the original +# relative order of the nodes in each of the two partitions. +# +# For example: +# +# Linked List: 1 → 4 → 3 → 2 → 5 → 2 +# +# k = 3 +# +# Expected Output: 1 → 2 → 2 → 4 → 3 → 5. + + +# example of invocation +# % raku ch-1.p6 --k=4 +# Index 4 makes 1 4 3 2 5 2 to become 1 3 2 2 4 5 + +sub MAIN( Int:D :$k = 3 ) { + + my @L = 1, 4, 3, 2, 5, 2 ; + my @l = | @L.grep( * < $k ), | @L.grep( * >= $k ); + say "Index $k makes { @L } to become { @l }"; +} |
