aboutsummaryrefslogtreecommitdiff
path: root/challenge-119/arne-sommer/raku/seq-without-single
blob: cc22f290a1901ca05862a28fc6addc6c499021d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#! /usr/bin/env raku

unit sub MAIN (Int $N where $N > 0);

my $count   = 1;
my $current = 1;

while $count < $N
{
  my @digits  = $current.comb.reverse;
  my $new     = "";
  my $add     = True;
    
  for $current.comb.reverse -> $digit is copy
  {
    if $add
    {
      if $digit <= 2
      {
        $digit++;
        $add = False;
      }
      else
      {
        $digit = 1;
      }
    }
      
    $new = $digit ~ $new;
  }

  $new = "1$new" if $add; 
  $current = $new;

  $count++ unless $current.contains('11');
}

say $current;