* Advent of Code Day 6
@ 2020-12-06 8:39 John Perry
2020-12-06 11:07 ` Jeffrey R. Carter
0 siblings, 1 reply; 5+ messages in thread
From: John Perry @ 2020-12-06 8:39 UTC (permalink / raw)
Today was quite easy, so I used the opportunity to learn about Ada.Strings.Maps, and that made for a much simpler solution to look at.
I do wonder about the efficiency, though. For instance, the only way I could find to count the number of elements in a Character_Set was by converting it to a Character_Sequence. Is there another way?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Advent of Code Day 6
2020-12-06 8:39 Advent of Code Day 6 John Perry
@ 2020-12-06 11:07 ` Jeffrey R. Carter
2020-12-06 19:37 ` John Perry
0 siblings, 1 reply; 5+ messages in thread
From: Jeffrey R. Carter @ 2020-12-06 11:07 UTC (permalink / raw)
On 12/6/20 9:39 AM, John Perry wrote:
> Today was quite easy, so I used the opportunity to learn about Ada.Strings.Maps, and that made for a much simpler solution to look at.
>
> I do wonder about the efficiency, though. For instance, the only way I could find to count the number of elements in a Character_Set was by converting it to a Character_Sequence. Is there another way?
Probably one of the set pkgs in Ada.Containers or
PragmARC.Data_Structures.Sets.Discrete might be a better choice than Character_Set
--
Jeff Carter
“[T]here are lots of people out there writing software
that should really be out cleaning toilets instead.”
Brian Catlin
173
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Advent of Code Day 6
2020-12-06 11:07 ` Jeffrey R. Carter
@ 2020-12-06 19:37 ` John Perry
2020-12-07 10:55 ` Maxim Reznik
0 siblings, 1 reply; 5+ messages in thread
From: John Perry @ 2020-12-06 19:37 UTC (permalink / raw)
On Sunday, December 6, 2020 at 5:07:24 AM UTC-6, Jeffrey R. Carter wrote:
> On 12/6/20 9:39 AM, John Perry wrote:
> >...the only way I could find to count the number of elements in a Character_Set was by converting it to a Character_Sequence. Is there another way?
> Probably one of the set pkgs in Ada.Containers or
> PragmARC.Data_Structures.Sets.Discrete might be a better choice than Character_Set
Thanks, Ada.Containers.Hashed_Sets works fine. I look forward to initialization of containers in the next edition of gnat.
john perry
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Advent of Code Day 6
2020-12-06 19:37 ` John Perry
@ 2020-12-07 10:55 ` Maxim Reznik
2020-12-07 13:32 ` Jeffrey R. Carter
0 siblings, 1 reply; 5+ messages in thread
From: Maxim Reznik @ 2020-12-07 10:55 UTC (permalink / raw)
In my solution I use a custom type - a boolean flag for each character. It takes 26 bytes (or even bits if you add `with Pack` aspect) and should be quite fast. Having this type it's easy to do `and` and `or` between such maps:
https://github.com/reznikmm/ada-howto/blob/advent-2020/md/06/06.md
--
Max
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Advent of Code Day 6
2020-12-07 10:55 ` Maxim Reznik
@ 2020-12-07 13:32 ` Jeffrey R. Carter
0 siblings, 0 replies; 5+ messages in thread
From: Jeffrey R. Carter @ 2020-12-07 13:32 UTC (permalink / raw)
On 12/7/20 11:55 AM, Maxim Reznik wrote:
> In my solution I use a custom type - a boolean flag for each character. It takes 26 bytes (or even bits if you add `with Pack` aspect) and should be quite fast. Having this type it's easy to do `and` and `or` between such maps:
Fast? I have made no attempt to make my solutions fast, and the slowest one gives
real 0m0.059s
user 0m0.007s
sys 0m0.000s
using the Linux "time" command. All of them have a user time < 10 ms. Almost all
the real time is doing I/O. And there are no timing requirements.
"Fast" should not be something anyone is worrying about.
--
Jeff Carter
"Ah, go away or I'll kill ya."
Never Give a Sucker an Even Break
100
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-12-07 13:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-06 8:39 Advent of Code Day 6 John Perry
2020-12-06 11:07 ` Jeffrey R. Carter
2020-12-06 19:37 ` John Perry
2020-12-07 10:55 ` Maxim Reznik
2020-12-07 13:32 ` Jeffrey R. Carter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox