Write a piece of code that produces a array containing all integer values in a set range in random order (upper and lower bounds included).
Use any language you like, but use as little built-in functions as possible (ie PHP's
array_shuffle should be avoided)
- All ints in the range must be used once, and only once
- The range can be negative, or positive
- If you choose to write a function the
}needn't be counted. Bonus points for clever argument validation/normalization if you do write a function
- Aliases like
m = Math;or
Array.prototype.p = .push;will be counted, using closures/functions, passing
Mathas an argument will be counted as
As a starting point or target: here's a snippet that meets all of the criteria apart from the randomness. It's approx. 50 bytes long (depending on
v's value). That would be a nice target to hit:
l is bigger than
v, the code fails.