Go to advanced search

by algorithm
Thu Nov 25, 2021 8:12 am
Forum: General programming discussion
Topic: Advent of Code
Replies: 338
Views: 38742

Re: Advent of Code

by algorithm
Mon Nov 22, 2021 12:36 am
Forum: General programming discussion
Topic: Advent of Code
Replies: 338
Views: 38742

Re: Advent of Code

sudo apt install dosbox? I haven't tried it but I see it's there. Also there's viewtopic.php?t=323336
by algorithm
Mon Nov 22, 2021 12:17 am
Forum: General programming discussion
Topic: Advent of Code
Replies: 338
Views: 38742

Re: Advent of Code

Does it have to be UCSD Pascal? How about Turbo Pascal 5.5 in Dosbox? Of course, Free Pascal is simply in the standard repo (or a little more recent on its website) and can compile all sorts of Pascal dialects. (Not sure about ucsd).
by algorithm
Mon Aug 16, 2021 8:25 am
Forum: Off topic discussion
Topic: Where did Pi-Top [3] go?
Replies: 3
Views: 607

Re: Where did Pi-Top [3] go?

It's still different of course but my guess is got pushed out by the Pi 400.
by algorithm
Sun Mar 14, 2021 2:04 pm
Forum: SDK
Topic: How is rand() implemented?
Replies: 8
Views: 767

Re: How is rand() implemented?

Right. But where would I found that source code? Sorry to be dumb, I'm new to this stuff. The only link to newlib source code I see at ARM HQ is to http://sourceware.org/git/newlib-cygwin.git Is that it..? On the Pi I see this in /usr/include/newlib/c++/7.3.1/bits/random.tcc template<typename _UIntT...
by algorithm
Sun Mar 14, 2021 1:38 pm
Forum: SDK
Topic: How is rand() implemented?
Replies: 8
Views: 767

Re: How is rand() implemented?

Thanks! Ah yes, I didn't grep my installation. However, that seems to be the VC4 (RPi) version, not Pico? Still not sure where to find it for the Pico. I see some stuff in ~/pico/pico-extras but fairly sure that can't be it.
by algorithm
Sun Mar 14, 2021 12:34 pm
Forum: SDK
Topic: How is rand() implemented?
Replies: 8
Views: 767

How is rand() implemented?

Is it possible to find anywhere how the standard library is implemented? I tried but couldn't find anything, but it was very late... Or would it be in the precompiled newlib bit of the ARM toolchain, without source? Specifically I would be interested what pseudo RNG is in there. Thanks.
by algorithm
Mon Mar 08, 2021 6:28 pm
Forum: General programming discussion
Topic: Advent of Code
Replies: 338
Views: 38742

Re: Advent of Code

Since the computation time is so short, I think you are seeing power-saving effects of the default CPU governor. Perhaps that was it. I didn't mean to sound so sure about the tiny variations in my version which was SUPPOSED to be symmetrical (at least, I couldn't figure out why there would be a dif...
by algorithm
Mon Mar 08, 2021 12:45 pm
Forum: General programming discussion
Topic: Advent of Code
Replies: 338
Views: 38742

Re: Advent of Code

Your modmul() might not be the fastest version possible because there's a couple of implicit conversions, starting with the #define of M as a signed integer (could be 32- or 64-bit, should be unsigned). Architecture independent 32/64-bit postfixes (which would be defined as either UL or ULL) are def...
by algorithm
Mon Mar 08, 2021 10:18 am
Forum: General programming discussion
Topic: Advent of Code
Replies: 338
Views: 38742

Re: Advent of Code

I didn't do much myself for day 25 after realising it was DHKE. I stole the precise description from Reddit, put in a completely naive discrete logarithm and stole the modular exponentiation from Wikipedia: https://github.com/ednl/aoc2020/blob/main/day25.c I thought it was interesting that there is ...
by algorithm
Sun Mar 07, 2021 9:02 pm
Forum: General programming discussion
Topic: Advent of Code
Replies: 338
Views: 38742

Re: Advent of Code

Visualisation of the hexagonal grid: https://ednl.github.io/hexgridjs/

(Earlier I thought it went all the way to the border but apparently that was a different edge effect a.k.a. an error made by me; it comes nowhere near.)
by algorithm
Fri Mar 05, 2021 9:17 am
Forum: General programming discussion
Topic: Advent of Code
Replies: 338
Views: 38742

Re: Advent of Code

I switched the timer because it didn't work on the Pico. Also read from included text instead of file. Plus a few more standard Pico things like the init and CMakeLists.txt. Unfortunately the code is probably not laid out for multiple loops; correct values on first run (at least for part 2; serial c...
by algorithm
Fri Mar 05, 2021 7:22 am
Forum: General programming discussion
Topic: Advent of Code
Replies: 338
Views: 38742

Re: Advent of Code

ejolson wrote:
Thu Mar 04, 2021 10:56 pm
With a total grid size of 239x239 it would seem that a 256x256 torus could manage the calculation no wrapping around. Would you mind running my code too, for comparison?
Correct result for my input. Reports running time ~3x slower on Core i5-4570 3.2 GHz, ~2x slower on Pi 400.
by algorithm
Thu Mar 04, 2021 9:25 pm
Forum: General programming discussion
Topic: Advent of Code
Replies: 338
Views: 38742

Re: Advent of Code

I changed my original program (non-Pico) which now parses the input twice to get the smallest grid possible. Turns out that for my input, counting from (0,0) the minimum x and y are both -18 and the maximum x and y both +18. So it's still a square, but smaller. With a border of zeros to not have to ...
by algorithm
Thu Mar 04, 2021 6:05 pm
Forum: General programming discussion
Topic: Advent of Code
Replies: 338
Views: 38742

Re: Advent of Code

No, no Fuzix. I forgot about trying to fit it into the SRAM instead of flash, but it runs anyway, in 1.324 s with which I am satisfied. The actual longest line is 43 characters for me. Code at https://github.com/ednl/pico/blob/main/day24.c (which includes 471 lines of my puzzle input..). Output on r...
by algorithm
Thu Mar 04, 2021 3:56 pm
Forum: General programming discussion
Topic: Advent of Code
Replies: 338
Views: 38742

Re: Advent of Code

OK, I wrote day 24 in C. Runs in 0.035 s in a Pi4 @1.8 GHz. https://github.com/ednl/aoc2020/blob/main/day24.c Room for improvement in memory usage: bitpacking (factor 8) and perhaps parsing the input before executing it, to get a tighter range than just "longest line". But, seems unnecessa...
by algorithm
Thu Mar 04, 2021 7:00 am
Forum: General programming discussion
Topic: Advent of Code
Replies: 338
Views: 38742

Re: Advent of Code

I think the way to go is put an upper limit on the size of the grid from the longest line in the input and the number of turns (100). This means reading the input twice, first for longest line then to parse. Say the longest line is also 100 chars, then after 100 turns the furthest a black tile can b...
by algorithm
Wed Mar 03, 2021 2:23 am
Forum: General programming discussion
Topic: Advent of Code
Replies: 338
Views: 38742

Re: Advent of Code

https://www.redblobgames.com/grids/hexagons/

Here's a version will certainly not run on the Pico. It takes 1.1 s on a Pi4 @1.8 GHz. https://github.com/ednl/aoc2020/blob/main/day24alt2.py
by algorithm
Tue Feb 23, 2021 1:56 pm
Forum: General programming discussion
Topic: Advent of Code
Replies: 338
Views: 38742

Re: Advent of Code

by algorithm
Sat Feb 20, 2021 10:15 pm
Forum: General programming discussion
Topic: Advent of Code
Replies: 338
Views: 38742

Re: Advent of Code

Nice. I thought about linking up a few Picos. No need for distributed algorithms, I think; just distributed data. And they do have 2 MB of flash memory, so probably not 2 but definitely 3 would suffice, I suppose. (Because counting+storing to 1 million takes about 4 MB.)
by algorithm
Sat Feb 20, 2021 4:51 pm
Forum: General programming discussion
Topic: Advent of Code
Replies: 338
Views: 38742

Re: Advent of Code

I think the moral of the story is that a 32-bit hash has 2^32 = 4294967296 possible values, while the number of possible shuffles of a 50 card deck are 50! = 30414093201713378043612608166064768844377641568960512000000000000 Sure, yes. Obviously the solution is to store the complete game state! Or, ...
by algorithm
Sat Feb 20, 2021 2:18 am
Forum: General programming discussion
Topic: Advent of Code
Replies: 338
Views: 38742

Re: Advent of Code

Funnily enough, my old part1-score-hash gave the correct (PET) answer here. Confirmed by switching G-polynomial: both Castagnoli and Koopman also gave the PET answer. Values from https://en.wikipedia.org/wiki/Cyclic_re ... ncy_checks
by algorithm
Fri Feb 19, 2021 6:27 pm
Forum: General programming discussion
Topic: Advent of Code
Replies: 338
Views: 38742

Re: Advent of Code

I ran my complete code for day 22 on the Pico, which gave: Part 1: winner = 1, score = 31629, time = 0.00035 s Part 2: winner = 1, score = 35196, time = 0.09832 s With the CRC-32 hash it's a bit slower because of extra copying and calculating: Part 1: winner = 1, score = 31629, time = 0.00035 s Part...
by algorithm
Fri Feb 19, 2021 7:50 am
Forum: General programming discussion
Topic: Advent of Code
Replies: 338
Views: 38742

Re: Advent of Code

Ha ha! What an endeavour. Yes, I definitely realised that the score as requested in part 1 had a not insignificant potential for collisions, but I took it as a strong hint that it would be good enough. As it turned out, it was, for me. I think the puzzle maker is quite diligent in providing thorough...
by algorithm
Thu Feb 18, 2021 5:05 pm
Forum: General programming discussion
Topic: Advent of Code
Replies: 338
Views: 38742

Re: Advent of Code

I thought you had completely cut out the recursion, but understanding your program was too much like real work :) So I'm not sure. I made my own version in C with a custom set structure, dynamically allocated. For my input, the complete program now runs in 0.0032 s on a Pi4 @ 1.8 GHz, with the recur...

Go to advanced search