r/adventofcode • • Dec 16 '18

SOLUTION MEGATHREAD -🎄- 2018 Day 16 Solutions -🎄-

--- Day 16: Chronal Classification ---


Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag or whatever).

Note: The Solution Megathreads are for solutions only. If you have questions, please post your own thread and make sure to flair it with Help.


Advent of Code: The Party Game!

Click here for rules

Please prefix your card submission with something like [Card] to make scanning the megathread easier. THANK YOU!

Card prompt: Day 16

Transcript:

The secret technique to beat today's puzzles is ___.


This thread will be unlocked when there are a significant number of people on the leaderboard with gold stars for today's puzzle.

edit: Leaderboard capped, thread unlocked at 00:39:03!

16 Upvotes

139 comments sorted by

View all comments

Show parent comment

5

u/algmyr Dec 16 '18

Honest question... Why are you using a lua version that was replaced in 2011? Lua 5.3 which has bitwise operators is almost 4 years old now.

2

u/waffle3z Dec 16 '18

Lua 5.1 is still the most popular version. I started using it in 2007. I would only ever use a different version outside the context of a platform, which is what this would be. It would probably be a good idea to start using 5.3 for these problems.

2

u/algmyr Dec 16 '18

Curious if/why 5.1 would be the most popular version. It does not match what I see for the linux distribution I use (only one data point, but still) where install frequency is something like

5.390%
5.280%
5.140%

Is there breaking changes post 5.1 or is adoption just slow?

2

u/mrhthepie Dec 16 '18

Another big factor is luajit. It's one of the fastest dynamic language implementations but it's fixed on Lua 5.1 as the actual language.

Luajit ships with a BitOps library though.

1

u/waffle3z Dec 16 '18

Later versions aren't backwards compatible with certain things. 5.1 doesn't have "integers", so in newer versions sometimes a ".0" is added to the end of a string when a number is coerced. Another change is function environments but that's an obscure language feature. I'm not used to any differences so I didn't take the risk of being thrown off by something subtle. Development platforms like Roblox and LÖVE and CryEngine still use Lua 5.1.

1

u/algmyr Dec 16 '18

Fair enough. I'm a python guy myself, so I get the issues with subtle bugs. What is a generator and what's not between python2 and python3 can catch you off guard. Also stupid things like min(0,None) being valid in 2 but not 3 is weird.

Don't tell me lua is another language that chooses to have double for all numbers... I kinda hoped that was contained to the likes of js. Not a fan, although I guess it makes sense considering that lua is deliberately minimal.

2

u/tobiasvl Dec 16 '18

I was about to assume you were using LuaJIT, since that still runs 5.1 (and probably will for the foreseeable future). I always use LuaJIT myself, when I use Lua for AoC, for the extra speed. And, of course, LuaJIT adds bitwise operators to 5.1 (the bit module).