❌ About FreshRSS

Normal view

There are new articles available, click to refresh the page.
Before yesterdayAda Forum - Latest topics

`alr --bin init` creates crates GPS can't make sense of?

By: cantanima
29 December 2022 at 03:52

I do the following, per the Alire Quickstart instructions:

alr init --bin my_proj
cd my_proj
alr build
alr run

Next I try to edit it:

alr edit

The most recent gnatstudio is in my path, so the editor pops up in the crate. Trouble is, it doesn’t seem to understand the project file at all. (Screenshot below.) To wit:

  • src has a source file in it, but the icon isn’t expandable.
  • While there are “build” and “run” buttons, they doesn’t actually build and run the program; rather, they seem good only for generating Uncaught Exceptions; see output below.
  • This is not a problem with pre-existing alire crates; it’s only a problem for anything I try to generate now.

Weirdly, this was working earlier today, which makes me think I broke something at some point. Does anyone have any suggestions for figuring out how to fix it?

Uncaught exception in workflows:
Traceback (most recent call last):
  File "/path/to/opt/gnatstudio/share/gnatstudio/support/ui/workflow_buttons.py", line 133, in build_main
    r0 = yield builder.wait_on_execute(main_name)
  File "/path/to/opt/gnatstudio/share/gnatstudio/support/ui/workflows/promises.py", line 1108, in wait_on_execute
    self.__target.execute(main_name=main_name,
  File "/path/to/opt/gnatstudio/share/gnatstudio/support/core/extensions/__init__.py", line 380, in execute
    self._internal_execute(
GPS.Unexpected_Exception: unexpected internal exception raised CONSTRAINT_ERROR : gnatcoll-projects.adb:5729 index check failed
[/path/to/opt/gnatstudio/bin/../lib/gnatstudio/libgnatcoll.so.23.0w]
0x7f1c6cc179c1 gnatcoll__projects__compute_scenario_variables__register_untyped_var.1798.constprop.0 at ???
0x7f1c6cc17d06 gnatcoll__projects__compute_scenario_variables__register_var.1778 at ???
0x7f1c6cc238c7 gnatcoll__projects__for_each_external_variable_declaration at ???
0x7f1c6cc26235 gnatcoll__projects__compute_scenario_variables at ???
0x7f1c6cc271aa gnatcoll__projects__scenario_variables__3.part.0 at ???
0x7f1c6cc27319 gnatcoll__projects__scenario_variables at ???
[/path/to/opt/gnatstudio/bin/gnatstudio_exe]
0x3cdd374

…and after that, a bunch more hexadecimal numbers and suchnot.

Screenshot_20221228_214507

6 posts - 3 participants

Read full topic

Day 25: Full of Hot Air

By: cantanima
25 December 2022 at 06:28

I’m not sure why he didn’t call this one SNAFU, but it was easy and fun, which I think is typical on Day 25.

Anyone add up the numbers using SNAFU arithmetic, or did everyone convert to decimal, add, then convert back?

PS If I may be allowed a personal remark: This is my third time doing AoC, but the first one I’ve completed it in time: for the 2020 competition I finished up around New Year’s instead of Christmas Day; then I went back and completed the 2019 competition, and then I took a break until this year. Having thsi forum to discuss things with, even to vent frustration once or twice, was helpful. I really enjoyed learning from everyone. Maybe I’ll go back and complete some other years… after getting some :sleeping_bed: first. :grin:

4 posts - 4 participants

Read full topic

Day 24: Blizzard Basin

By: cantanima
24 December 2022 at 08:48

Part 1 is another spoiler. I wasted too much time getting the blizzard logic wrong. I knew what to do; I just kept getting the math wrong! I did at least have the presence of mind spoiler.

Part 2 was also pretty straightforward, once Part 1 is done. Interesting that the result is not three times the value of Part 1, but not especially surprising, given how the blizzards move around.

Glancing over at the Reddit Solutions Megathread, some commenters have noticed that spoiler (It certainly would be in my case.)

9 posts - 4 participants

Read full topic

Day 23: Unstable Diffusion

By: cantanima
23 December 2022 at 07:32

Another one that I thought was fun! The input proved helpful, and was not so different from the example today as it was yesterday. Then again, it would be hard to diverge as greatly from the example to the input as yesterday did…

My solution spoiler To determine the direction an elf considers, spoiler

Is there a way to determine how many variants an enumerated type has?

I have an idea for a visualization, and if I find time I’ll do it later.

Added later: Now that I review the discussion on Reddit, I notice that a lot of people missed something that I almost missed myself: spoiler Yeah, watch out for that.

11 posts - 4 participants

Read full topic

Day 22: Monkey Map

By: cantanima
22 December 2022 at 09:37

This was fun. Even the debugging was fun. Even though the example was once again naughty, at least for Part 2, this was fun. (If anyone’s input creates a cube in the same way as the example, I’d like to know!)

Only one hint / comment from me: in part 2, spoiler.

I thought about drawing the paths onto the map, but it’s pretty late where I am, so maybe tomorrow. In lieu of that, here’s an aid I made to help with Part 2.
Day_22_cube

3 days left!

10 posts - 3 participants

Read full topic

2022 Day 21: Monkey Math

By: cantanima
21 December 2022 at 07:38

I really enjoyed today’s puzzle! Observations / hints / spoilers:

  • The example does not cover all the cases you need to check in Part 2. Interestingly, the input is relatively small if you look at it right, so even though I got Part 2 wrong the first time, it didn’t take me long to work through the example and find my mistake.
  • In part 1, spoiler
  • In part 2, spoiler

4 days left!!!

7 posts - 4 participants

Read full topic

2022 Day 20: Grove Positioning System

By: cantanima
20 December 2022 at 14:52

(edited after remembering another bad idea, whoops)

I had one very good idea, one good idea, and quite a few bad ideas, including one very bad idea that held me up a long time.

  • The very good idea was spoiler As a result, the solution to both parts takes only less than two seconds (using full optimization and inlining).
  • The good idea I don’t quite remember, sorry, but I had it in mind at one point. :grin:
  • One bad idea was spoiler. Fortunately, I caught that one quickly.
  • Another bad idea was spoiler Rather naughty of the example not to have a value that would illustrate that.
  • The very bad idea came while testing my code on the example. spoiler I wasted over an hour on that stupid mistake…

8 posts - 4 participants

Read full topic

2022 Day 19: Not Enough Minerals

By: cantanima
19 December 2022 at 13:43

Nope. I’ve been at this for hours.

  • I wasted hours just trying to get my code to run the example in a reasonable time, and when I gave up I discovered that the input takes not much longer to run than the example.

    So there’s a hint that doesn’t require a spoiler: don’t bother trying to get your program to work on the example in seconds; the input isn’t that much harder! Just try to get the program to work on the example, period!

  • Unfortunately, that’s not enough. The example doesn’t really illuminate the problem. Your code can run correctly on the example and run incorrectly on the problem input. This happens from time to time, but on a problem like today it’s ruinous.

  • To help me debug my program, I downloaded and ran several people’s solutions posted online (in other languages). I haven’t tried any of the solutions, but there’s a morbid satisfaction in the fact that different “solutions” produce different results on my input.

  • Some authors admit that they guessed at optimizations and got lucky; the optimizations probably don’t work in general. I’ve tried a few, and nope, they don’t work on my input (unless I’m implementing them wrong).

  • Some authors used parallelism. I may yet try that, since the problem is parallelizable, and otherwise I have to wait 5-10 minutes per attempt.

In short, I haven’t finished it yet. IMHO the puzzle is terribly flawed, for the reasons given above. And, yeah, sour grapes, too. :grin:

8 posts - 3 participants

Read full topic

Am I doing something wrong here?

By: cantanima
19 December 2022 at 00:38

I use Ada for my personal projects, largely out of admiration for the language, but I’m entirely self-taught in Ada, and the literature on its usage is… well, somewhat scant in comparison to, say, C++.

Not every language is perfect, but some things in the standard Ada library seem far too cumbersome. So much so, that I have to wonder if I’m doing things right. I’ve looked at the ARM, perhaps not well, and rosetta code is down at the moment, so I thought I’d inquire here.

Queues

Setting up a queue seems to involve way more effort than it should:

  • You have to include two separate packages:
    • Containers.Synchronized_Queue_Interfaces
    • Containers.Unbounded_Synchronized_Queues or one of the other three variants
  • You have to use all type Ada.Containers.Count_Type if you want to check whether it’s empty.

The payoff? For all the effort you put into creating it, the resulting queue offers less functionality than other languages’. All you can do is Enqueue, Dequeue, and check usage. You can’t iterate through the queue to see what’s there and possibly modify it, nor search through it, let alone split the queue. There isn’t even an .Is_Empty method to tell you when it’s exhausted.

Queues are pretty common, and I’ve never seen one so bare bones. Is there something more functional than this in the standard library? If not, do people recommend a different library (e.g,. the Simple Components library) or do you typically roll your own?

(I realize there may be good reasons for the library to do things this way; I’m just wondering what people do about it.)

Iteration through maps

Suppose I set up a map M and want to iterate through it.

  • for E of M iterates through the map’s elements, not through its keys. I wish they had returned the keys instead, since often that’s what I want, and it’s easy to obtain the elements from the keys, and not so much the converse. But this does make sense.
  • for C in M.Iterate iterates a cursor through the key/pair combinations. This makes sense, too. But…
  • Using Cursor is, again, cumbersome. As far as I can tell, I can’t do this: C.Key or C.Element. Instead, I have to with all type Map_Type.Cursor to get Key(C) and Element(C), or else qualify the functions fully: Map_Type.Key(C) or Map_Type.Element(C).

(I think Ada 2022 introduces functionality to let me treat a cursor the way I want, but if so, I have to update my gnat: version 20210519-103.)

So what am I doing wrong?

Have I missed something, or is this indeed the standard way of doing these things in Ada? I would be grateful for any direction, because I don’t use Ada often enough to remember these two things, and the compiler’s help error messages are not the greatest.

Honestly!

I apologize if it comes across as a complaint. I realize there’s no perfect language, and just want to know if I’m missing something, because Ada does so many things right. I can make much, much longer lists of my complaints with C++, and a somewhat longer list of complaints with Rust, than I can with Ada.

9 posts - 4 participants

Read full topic

2022 Day 17: Pyroclastic Flow

By: cantanima
17 December 2022 at 12:16

Part 1 is pretty straightforward, I think.

Part 2 requires some mathematics, or at least that’s what got me to solve it quite quickly I did one other thing, too.

The solution I uploaded for part 2 will probably not work on the example program, because the example’s sequences aren’t quite as well-behaved as the actual puzzle, which made the problem a little harder. But the same technique really does work!

2 posts - 2 participants

Read full topic

2022 Day 15: Beacon Exclusion Zone

By: cantanima
15 December 2022 at 07:42

Only 10 days left!

My solution to Part 1 was quite slow, perhaps because I used an OrderedSet. It might be worth retrying with a HashedSet at some point.

So I was really worried that Part 2 would be one of those problems whose obvious solution is to apply Part 1, but whoses complexity explodes on you, and as I first began to read it, my heart filled with dread. But then I realized that spoiler It still takes a few moments, but it worked! So I will be interested in seeing if anyone manages to solve it in a fraction of a second, and if so, then how.

I’m also amazed that Part 2 can even be a problem; the fact that he pulled off such a puzzle impresses me. Maybe it won’t impress me if I think about it enough, but even after a couple of glances, I’m still impressed. Maybe I just need some :sleeping_bed:

8 posts - 4 participants

Read full topic

2022 Day 13: Distress Signal

By: cantanima
13 December 2022 at 09:01

We’re past halfway! :grin: :dark_sunglasses: :grinning: :sunglasses: :fireworks: :sparkler: :partying_face:

(The downside is that the problems have suddenly stepped up in difficulty!)

For the second day in a row, writing a program that solves the example wasn’t enough. Twice I ran it and got solutions that were rejected as too large. I had to comb through some of the pairs that my program claimed were legitimate. In both cases, it was the case where I had to compare a number and a list. The instructions are to create a new list that includes the number, then compare the lists, but it seemed equivalent to me simply to compare the number with the first element of the list. This produced false positives. I haven’t quite figured out why, though.

Curiously, in part 2 I was able to make it work simply by spoiler

5 posts - 5 participants

Read full topic

❌
❌