34
3
Create a program that prints all whole numbers inclusively between an interval (a, b)
, and replaces multiples of 8 in the sequence with random (uniformly distributed, independent of other characters), non-numeric, non-whitespace, printable ASCII characters.
Assume 0 < a < b in all cases.
If the number has more than 1 digit, make sure the amount of characters in the replacement matches!
Examples:
(1, 16) -> 1 2 3 4 5 6 7 $ 9 10 11 12 13 14 15 n@
(115, 123) -> 115, 116, 117, 118, 119, :F<, 121, 122, 123
(1, 3) -> 1 2 3
Non-Examples:
(1, 16) -> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
(115, 123) -> 115 116 117 118 119 $ 121 122 123
This is code golf, so the shortest code in bytes wins!
Current Winner:
Most Popular:
11Congrats on making a challenge that combines all the super long things to implement in my golfing language – Blue – 2016-12-24T00:16:03.277
1@muddyfish i mean it is a challenge ;) – GracefulLemming – 2016-12-24T00:16:47.477
I'm not sure if I am missing something, but should the random characters be unique or not? For example if the input was 16, 16 then could the output be aa? If this is not the case, what about if the number has more than 85 digits (assuming I counted correctly)? – FryAmTheEggman – 2016-12-24T04:09:58.093
@FryAmTheEggman each character should be unique mostly but if "a" and "a" are randomly selected consecutively that is ok, but it shouldnt happen in all cases because the probability is so low – GracefulLemming – 2016-12-24T04:14:10.773
@FryAmTheEggman and the case 16, 16 in the other examples either returns 0 or 2 random characters but dont worry about that case as a will always strictly be less than b – GracefulLemming – 2016-12-24T04:15:06.600
What do we do with non-ASCII encodings?
– Adám – 2016-12-25T10:07:53.733Can we choose such random chars (guaranteed to be random): http://xkcd.com/221/ ?
– RudolfJelin – 2016-12-25T13:15:48.270Can 8 be randomly selected? – steenbergh – 2017-01-06T17:50:59.993
@steenbergh no, random characters must be non-nuneric – GracefulLemming – 2017-01-06T17:59:17.163
@Caleb Hmm, missed that bit of the specs. That's expensive... – steenbergh – 2017-01-06T18:23:38.873