bjorng

bjorng

Erlang Core Team

Advent of Code 2019 - Day 5

Note: This topic is to talk about Day 5 of the Advent of Code 2019.

There is a private leaderboard for elixirforum members. You can join it by following this link and entering the following code:

39276-eeb74f9a

Most Liked

sasajuric

sasajuric

Author of Elixir In Action

Here’s my solution.

bengtson

bengtson

Struggled a little with part2 of Day 5. Wrote a disassembler to see what was going on. Hopefully it will be useful for days ahead.

Disassembed Listing: input_05.txt
Program Size: 678
Entry Point: 0
Input List: 5
----------
  0: input   5
  2: add     5, 1100, 6
  6: jmpt    1, 238

238: jmpt    0, 99999
241: jmpt    227, 247

247: jmpt    0, 99999
250: jmpt    3, 256

256: jmpf    227, 99999
259: jmpf    0, 265

265: jmpf    3, 99999
268: jmpf    0, 274

274: jmpt    1, 280

280: add     5, 5, 225
284: add     294, 0, 0
288: jmpt    1, 294

294: jmpf    0, 300

300: add     10, 10, 225
304: add     314, 0, 0
308: jmpf    0, 314

314: cmpeq   226, 677, 224     ; 0 written
318: mul     2, 0, 223
322: jmpf    0, 329

329: cmpless 677, 226, 224     ; 0 written
333: mul     0, 2, 223
337: jmpf    0, 344

344: cmpeq   677, 226, 224     ; 0 written
348: mul     2, 0, 223
352: jmpf    0, 359

359: cmpless 226, 677, 224     ; 1 written
363: mul     2, 0, 223
367: jmpt    1, 374

374: cmpeq   677, 226, 224     ; 0 written
378: mul     0, 2, 223
382: jmpf    0, 389

389: cmpless 677, 677, 224     ; 0 written
393: mul     2, 0, 223
397: jmpf    0, 404

404: cmpless 226, 677, 224     ; 1 written
408: mul     0, 2, 223
412: jmpf    1, 419
415: add     0, 1, 223
419: cmpeq   677, 226, 224     ; 0 written
423: mul     2, 1, 223
427: jmpt    0, 434
430: add     2, 1, 223
434: cmpeq   226, 226, 224     ; 1 written
438: mul     3, 2, 223
442: jmpf    1, 449
445: add     6, 1, 223
449: cmpless 677, 226, 224     ; 0 written
453: mul     7, 2, 223
457: jmpf    0, 464

464: cmpless 226, 677, 224     ; 1 written
468: mul     2, 14, 223
472: jmpt    1, 479

479: cmpless 677, 226, 224     ; 0 written
483: mul     28, 2, 223
487: jmpt    0, 494
490: add     56, 1, 223
494: cmpeq   226, 677, 224     ; 0 written
498: mul     57, 2, 223
502: jmpt    0, 509
505: add     114, 1, 223
509: cmpless 677, 677, 224     ; 0 written
513: mul     115, 2, 223
517: jmpf    0, 524

524: cmpless 677, 677, 224     ; 0 written
528: mul     2, 230, 223
532: jmpt    0, 539
535: add     1, 460, 223
539: cmpless 677, 226, 224     ; 0 written
543: mul     2, 461, 223
547: jmpt    0, 554
550: add     922, 1, 223
554: cmpeq   677, 677, 224     ; 1 written
558: mul     923, 2, 223
562: jmpf    1, 569
565: add     1846, 1, 223
569: cmpeq   226, 677, 224     ; 0 written
573: mul     1847, 2, 223
577: jmpf    0, 584

584: cmpeq   226, 226, 224     ; 1 written
588: mul     3694, 2, 223
592: jmpf    1, 599
595: add     7388, 1, 223
599: cmpeq   677, 226, 224     ; 0 written
603: mul     2, 7389, 223
607: jmpf    0, 614

614: cmpless 226, 226, 224     ; 0 written
618: mul     14778, 2, 223
622: jmpf    0, 629

629: cmpeq   226, 677, 224     ; 0 written
633: mul     2, 29556, 223
637: jmpt    0, 644
640: add     1, 59112, 223
644: cmpless 226, 677, 224     ; 1 written
648: mul     59113, 2, 223
652: jmpt    1, 659

659: cmpeq   226, 226, 224     ; 1 written
663: mul     2, 118226, 223
667: jmpf    1, 674
670: add     236452, 1, 223
674: output  236453
676: stop    
----------
Outputs Written: 236453
Aetherus

Aetherus

No cheat this time:

https://github.com/Aetherus/advent_of_code/blob/master/2019/day05.exs

I wonder is there a way to call private functions dynamically.

Where Next?

Popular in Challenges Top

bjorng
Here is my solution for day 2 of Advent of Code: https://github.com/bjorng/advent-of-code/blob/main/2024/day02/lib/day02.ex
New
stevensonmt
Reasonably pleased with my solution. The bitstring packet problems are so well suited to Erlang/Elixir it’s almost not fair. defmodule D...
New
bjorng
This topic is about Day 16 of the Advent of Code 2021. We have a private leaderboard (shared with users of Erlang Forums): https://adve...
New
bjorng
Here is my solution: https://github.com/bjorng/advent-of-code-2021/blob/77bdef7a51b428b58ffb4ab76f540901e636f841/day12/lib/day12.ex
New
bjorng
This topic is about Day 6 of the Advent of Code 2021. We have a private leaderboard (shared with users of Erlang Forums ): https://adve...
New
gangstead
This is my second year doing AoC in Elixir and my first year doing it with Livebook. When I was doing just plain Elixir I usually set up...
New
bjorng
My solution finishes both parts in 5 seconds on my computer. That time should be possible to reduce by optimizing my rather naive tilt/2 ...
New
bjorng
Note: This topic is to talk about Day 16 of the Advent of Code 2019. There is a private leaderboard for elixirforum members. You can joi...
New
Aetherus
I spent 3 hours struggling in part 2, until I noticed a very basic mistake :joy: Here’s my code: https://github.com/Aetherus/advent-of-...
New
christhekeele
Setting this down for the night, as after a quick naive solve for quick part 1 I realize that part 2 is by design computationally expensi...
New

Other popular topics Top

AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30877 112
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement