Day 22: Monkey Market
Megathread guidelines
- Keep top level comments as only solutions, if you want to say something other than a solution put it in a new post. (replies to comments can be whatever)
- You can send code in code blocks by using three backticks, the code, and then three backticks or use something such as https://topaz.github.io/paste/ if you prefer sending it through a URL
FAQ
- What is this?: Here is a post with a large amount of details: https://programming.dev/post/6637268
- Where do I participate?: https://adventofcode.com/
- Is there a leaderboard for the community?: We have a programming.dev leaderboard with the info on how to join in this post: https://programming.dev/post/6631465
You are viewing a single thread.
View all comments 5 points
*
Uiua
Itâs been a while since I posted one of these, but I thought this would be straightforward in Uiua. Turns out that bitwise operations are a bit (haha) of a pain, so the Rng
operation is very slow at 4sec for live data.
I took this as an opportunity to play with the â§(stencil)
operator which probably slowed things down too.
Data â 1_2_3_2024
Xor â °âŻâż2âŹ0+â©âŻ # Bitwise xor of two numbers.
Rng â âââż,XorĂ2048.âż,XorâĂ·32.âż,XorĂ64.â16777216
Runs â â(â[â„(Rng.)])2000 Data # Should be constant?
Firsts â (
ââ0â§â/-.âż10 âÂŻ1 # Build run, gen pair diffs
âąâ§(âââŁ/(+Ă40+20)°â) 2_4 # Convert 4-diff into key, collect.
ââąâââââ°â.â # Only keep first of each key. # â(map°âââ|â) failed.
)
&p /+âĄâŁ.Runs
&p /â„â(/+)+1â°ââ/ââwaitâĄspawn(âĄFirsts) # Group by key, sum prices, return highest.