Inspired by old code golf challenges and the latest TIS-100 game. Plus in part of the work for the upcoming demoscene courses. I present a monthly coding challenge to members:
September’s challenge:
Create three functions that outputs either a ‘1’ or ‘0’ for that takes a random integer as input within the range of -2 through +2. The function can only use subtraction, addition and invert the sign.
Function one outputs ‘1’ or ‘0’ on greater than zero.
Function two outputs ‘1’ or ‘0’ on equal to zero.
Function three outputs ‘1’ or ‘0’ on
Bonus points for using only arithmetic. One can use any language they choose though assembly, basic, or ansi-c is prefered.
C never gets in your way. It is more than happy to let you take that unsigned int and explicitly convert it to an array pointer or a float. It gives you the revolver, the bullets, and a bottle of whiskey.
Automatic type-converting languages are never used for safety-critical software. Reason? Run-time errors can occur when the input goes out of range or is of the wrong type for the parameter in question. Perl and Python land in this category, so don’t think I’m trying to slam one or the other.