comp.lang.ada
 help / color / mirror / Atom feed
From: Gautier Write-Only Address <gautier_niouzes@hotmail.com>
Subject: Re: Advent of Code, Day 19
Date: Mon, 21 Dec 2020 11:48:16 -0800 (PST)	[thread overview]
Message-ID: <52690d99-a8ed-40c3-b3c3-8d54875506a5n@googlegroups.com> (raw)
In-Reply-To: <c3ab11b8-a977-46c2-964b-6e20e020fd23n@googlegroups.com>

For me the first part was the tough one. I've tried for too long to structure the rules verification like this
procedure Verify_Rule (...) is
  ...
  procedure Verify_Rule_List (...) is
  ...
  begin
    loop on the list, call recursively Verify_Rule
  end;
end;
But a loop cannot be used here, each subrule can consume a variable range of characters in the string and there are multiple tails of the string for the next subrule for the loop.
So the solution in that case was to delegate everything further to recursion.

Part two was (in my case) a matter of applying the indicated rules modification.
    if part = 2 then
      rule (8)  := (is_terminal => False, max => 3, alt => 2, sub => (42, 42,  8, -1, -1));
      rule (11) := (is_terminal => False, max => 5, alt => 3, sub => (42, 31, 42, 11, 31));
    end if;

  reply	other threads:[~2020-12-21 19:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-19 13:43 Advent of Code, Day 19 Gautier Write-Only Address
2020-12-20  1:01 ` John Perry
2020-12-21 19:48   ` Gautier Write-Only Address [this message]
2020-12-21 20:38     ` Jeffrey R. Carter
2020-12-21 23:45     ` John Perry
2020-12-22 16:43       ` Maxim Reznik
2020-12-23  0:57         ` John Perry
2020-12-24 11:55           ` Maxim Reznik
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox