aboutsummaryrefslogtreecommitdiff
path: root/challenge-113/arne-sommer/raku/represent-integer
blob: ef6e2f7c9366e9474f80ce6cfa40012967059a90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#! /usr/bin/env raku

unit sub MAIN (Int $N where $N > 0, Int $D where $D.chars == 1, :v($verbose));

my @candidates = (1 .. $N).grep( * ~~ /$D/);

say ": Candidates { @candidates.join(', ') }" if $verbose;

for @candidates.combinations(1..*) -> @comb
{
  say ": Considering { @comb.join(' + ') }" if $verbose;
  if @comb.sum == $N
  {
    say 1;
    exit;
  }
}

say 0;