You have been given a string of digits 0-9.1 Your task is to shuffle this string, but every index must have a different value than it did before the string was shuffled.
In : 287492 Out: 892247
If this is not possible, return
false or something similar. (
In : 131 Out: false
There is no upper bound on the length of the string, but you can assume you have unlimited computation time.
Your function must pass the following tests:
shuffle('2') => false shuffle('88') => false shuffle('794588888') => false shuffle('344999') => for example, '999434' shuffle('172830560542976539') => for example, '271038650425697395'
Shortest code wins, and good luck!
1 More specifically, the string would match