merari42@lemmy.world to Programmer Humor@programming.dev · 2 days agoWishUnderflowlemmy.worldimagemessage-square38fedilinkarrow-up1456arrow-down110
arrow-up1446arrow-down1imageWishUnderflowlemmy.worldmerari42@lemmy.world to Programmer Humor@programming.dev · 2 days agomessage-square38fedilink
minus-squareKhanzarate@lemmy.worldlinkfedilinkarrow-up4·1 day agoGenie in the OP image would’ve said “OK you now have 0 wishes”. Since he said 255, my interpretation is a valid solution. Of course, if we’re talking hypothetical wish gaining prevention methods, I’d just have a check before, previous_wishes = wishes; {Do all the wish things. wishes ends up with a 255 because of our shenanigans} If(wishes>=previous_wishes) wishes = previous_wishes-1; ;If the current number of wishes isnt less than the old number of wishes, set it to the old number and subtract 1 If(wishes==0) {/*TODO: write function to end wish giving sequence*/}
Genie in the OP image would’ve said “OK you now have 0 wishes”.
Since he said 255, my interpretation is a valid solution.
Of course, if we’re talking hypothetical wish gaining prevention methods, I’d just have a check before,
previous_wishes = wishes;
{Do all the wish things. wishes ends up with a 255 because of our shenanigans}
If(wishes>=previous_wishes) wishes = previous_wishes-1;
;If the current number of wishes isnt less than the old number of wishes, set it to the old number and subtract 1
If(wishes==0) {/*TODO: write function to end wish giving sequence*/}