Silly programming challenge: Choose randomly -1 or 1

My friend Aviv, a fellow Unity developer, and me were trying to figure out how many different significant ways we can come up with to solve the simple problem of choosing a random value.
You can try this silly challenge yourself, or jump right to our solution.
Let me know if you found other solutions.

Of those, I would say ex1 is too similar to ex2 (also it was interesting to notice it would work with integers too).
So I would score us 7 solutions.

I would choose ex6 for real life usage, since I think it's the most readable.
ex7 is the funniest but it should work (notice we are using the UnityEngine library, not the System library)

This entry was posted on Thursday, July 7th, 2016 at 18:13 and is filed under Games. You can follow any responses to this entry through the RSS 2.0 feed.
Both comments and pings are currently closed.