r/programminghorror • u/vadnyclovek [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo "You live" • Apr 28 '26
c++ Competitive programming is no joke
especially for easy problems
144
Upvotes
r/programminghorror • u/vadnyclovek [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo "You live" • Apr 28 '26
especially for easy problems
View all comments
Show parent comment
33
u/backfire10z Apr 29 '26 edited Apr 29 '26
It is a dynamic programming problem that seems to be based on the sum of the previous 6 values (default value of 0) each modded by some constant. Here it is rewritten in Python slightly neater:
I’m on mobile and was too lazy to deal with the default 0, so I’m using exception-based handling lol.