Heath @heathhenley.dev ยท Nov 16

Anyone up for constructively (or not) roasting my ๐Ÿช? I'm an Ocaml and FP newb in general It's an old advent of code problem (day 21 from 2015) - full code is here: github.com/heathhenley/... Problem is: adventofcode.com/2015/day/21

6 likes 3 replies

?

Replies

Alice โœจ ยท Nov 16

it looks pretty good! i like that you're using arrays, ocaml people often have... trouble witht that and will use linked lists for everything (ew)

Kiran ยท Nov 17

so I might have missed something, but why at line 116 do you stop the search if any of the elements have reached their max value? This means that your search will never cover the case where the state is (Array.length weapons -1, Array.length armor - 1, Array.length.rings -1 , Array.length rings -1)

Kiran ยท Nov 17

oooh, I'm not sure if this is stylistic or strictly an improvement, but one comment I might suggest w.r.t your code, esp when it comes to these like search problems is to refactor out the neighour selection code to a separate function, and then you can use List operations to manipulate the results