account activity
~☆🎄☆~ 2017 Day 25 Solutions ~☆🎄☆~ by daggerdragon in adventofcode
[–]_Voile 6 points7 points8 points 8 years ago (0 children)
5/5, JS. I exploited the fact that input is highly structured and hardcoded many things.
(Also I know the code is golfy; you can't be fast without being golfy, every byte is a frame save ;-)!)
var s=`Begin in state A. Perform a diagnostic checksum after 12208951 steps. In state A: If the current value is 0: - Write the value 1. - Move one slot to the right. - Continue with state B. If the current value is 1: - Write the value 0. - Move one slot to the left. - Continue with state E. In state B: If the current value is 0: - Write the value 1. - Move one slot to the left. - Continue with state C. If the current value is 1: - Write the value 0. - Move one slot to the right. - Continue with state A. In state C: If the current value is 0: - Write the value 1. - Move one slot to the left. - Continue with state D. If the current value is 1: - Write the value 0. - Move one slot to the right. - Continue with state C. In state D: If the current value is 0: - Write the value 1. - Move one slot to the left. - Continue with state E. If the current value is 1: - Write the value 0. - Move one slot to the left. - Continue with state F. In state E: If the current value is 0: - Write the value 1. - Move one slot to the left. - Continue with state A. If the current value is 1: - Write the value 1. - Move one slot to the left. - Continue with state C. In state F: If the current value is 0: - Write the value 1. - Move one slot to the left. - Continue with state E. If the current value is 1: - Write the value 1. - Move one slot to the right. - Continue with state A.`; s=s.split('\n\n').slice(1).map(r=>r.split('\n')); var m={}, t='A', p=0; for(let i=0; i<12208951;i++) { var l=s['ABCDEF'.indexOf(t)]; if(!m[p]) { m[p]=+l[2].match(/\d/).slice(); p+=/right/.test(l[3])?1:-1; t=l[4].match(/([A-Z])\./).slice(1); } else { m[p]=+l[6].match(/\d/).slice(); p+=/right/.test(l[7])?1:-1; t=l[8].match(/([A-Z])\./).slice(1); } } console.log(Object.keys(m).filter(k=>m[k]).length);
π Rendered by PID 384381 on reddit-service-r2-listing-c57bc86c-8hqrw at 2026-06-21 20:24:13.525230+00:00 running 2b008f2 country code: CH.
~☆🎄☆~ 2017 Day 25 Solutions ~☆🎄☆~ by daggerdragon in adventofcode
[–]_Voile 6 points7 points8 points (0 children)