comp.lang.ada
 help / color / mirror / Atom feed
From: John Perry <john.perry@usm.edu>
Subject: Re: Advent of code day 12
Date: Sun, 13 Dec 2020 07:32:29 -0800 (PST)	[thread overview]
Message-ID: <e574fdeb-1a01-4622-985d-f05d649c76e8n@googlegroups.com> (raw)
In-Reply-To: <04c03d8f-4120-4b94-843a-319aaf1ed9e9n@googlegroups.com>

On Sunday, December 13, 2020 at 3:14:30 AM UTC-6, gautier...@hotmail.com wrote:
> > I mostly agree, but I had trouble with today's puzzle. It's a recurring problem of mine: if the input is not specified completely, I have trouble figuring out what it is, even when I study it, so I often get subtle bugs. And there's a LOT of input. In my input, a turn of 270 degrees doesn't show up until line 85, so I didn't see it even after scanning the file (which I did because I wanted to make sure it had integer-only positions and the turns were multiples of 90). Once I figured that out, it was quite easy.
> If you include all possible angles you don't encounter that issue :-) 
> 
> https://github.com/zertovitch/hac/blob/master/exm/aoc/2020/aoc_2020_12.adb

Yes, I had looked at your code (and Max's) after finishing mine but before replying here, so I was aware of it at the time. That is definitely one way to avoid the issue :-) but I don't think you can use the approach I used in that case, of which I am perhaps far too fond:

   Left_Turn: array( Direction_Value, Direction_Delta ) of Direction_Value :=
   (
          ( West,  South, East  ),   -- 90, 180, 270 from north
          ( East,  North, West  ),   -- ...from south
          ( North, West,  South ),   -- ...from east
          ( South, East,  North )    -- ...from west
   );
   
so the code to perform a left turn is

   Direction := Left_Turn(Direction, D);

john perry

  reply	other threads:[~2020-12-13 15:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-12 20:28 Advent of code day 12 Stephen Leake
2020-12-13  1:33 ` John Perry
2020-12-13  6:40   ` Maxim Reznik
2020-12-13 11:36     ` Gautier Write-Only Address
2020-12-13 15:41     ` John Perry
2020-12-13 18:35       ` Maxim Reznik
2020-12-13 22:29         ` John Perry
2020-12-14  9:15           ` Maxim Reznik
2020-12-14  0:01         ` Stephen Leake
2020-12-13  9:14   ` Gautier Write-Only Address
2020-12-13 15:32     ` John Perry [this message]
2020-12-13  9:30   ` Jeffrey R. Carter
replies disabled

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