From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Path: eternal-september.org!reader02.eternal-september.org!aioe.org!pBWEO6hi52oGFheO/GY5ag.user.gioia.aioe.org.POSTED!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Advent of Code day 2 Date: Wed, 02 Dec 2020 14:47:27 -0800 Organization: Aioe.org NNTP Server Message-ID: <86blfbj05c.fsf@stephe-leake.org> NNTP-Posting-Host: pBWEO6hi52oGFheO/GY5ag.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain X-Complaints-To: abuse@aioe.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (windows-nt) X-Notice: Filtered by postfilter v. 0.9.2 Cancel-Lock: sha1:JvdU59GfKRyto0xroKiBGQVXzCk= Xref: reader02.eternal-september.org comp.lang.ada:60674 List-Id: This is an example of the customer problem spec not being complete; in the example, all the letter positions are single digit, so my first draft assumed that, which made finding the values trivial. But then the real input has 1 or 2 digit numbers. Handling that took me a while; first I had to actually understand the semantics of Ada.Strings.Index (Source, Set, Test); "the smallest index satisfying the test" does _not_ produce a span of characters matching the test; I should have used Gnatcoll.regexp. Then I found an indent bug in the development version of emacs ada-mode, which I took a detour to fix. Which is one reason to do this contest; writing Ada code is a good way to find bugs in ada-mode. (just out of curiosity; what development environments are you all using?) Then for the second puzzle, the fact that Ada String slices _don't_ have first index 1 confused things; I ended up writing a Slide function to keep the logic simpler. Finally got it right. I was hoping to use 'Reduce in the sled rental count, but GNAT Community 2020 -gnat2020 -gnatX doesn't support that. I did use @, which I like a lot. -- -- Stephe Written from unceded ancestral homelands of the Huichiun, an Ohlone people,for which I pay Shuumi Land Tax