Timeline for How to randomize letters in a word
Current License: CC BY-SA 3.0
6 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Sep 23, 2011 at 22:33 | comment | added | Steve Robbins | Can you provide a demo of this working? Because I can't... | |
S Aug 4, 2011 at 17:18 | history | suggested | Tomalak | CC BY-SA 3.0 |
shorter variant added
|
Aug 3, 2011 at 21:52 | comment | added | Ben Richards |
@Tomalak Suggested I try rewriting this solution in Perl. Including his suggestions, I got this: use List::Util 'shuffle';sub r{$_[0]=~m/(.)(.+)(.)/;$1.join('',shuffle split//,$2).$3;} That's 87 characters. Without the use line, it's 62 characters.
|
|
Aug 3, 2011 at 20:20 | comment | added | Tomalak |
+1 Very nice. :) You could drop the trim(), actually, and in the regex you can remove the anchors and use . instead of \w .
|
|
Aug 3, 2011 at 20:17 | review | Suggested edits | |||
S Aug 4, 2011 at 17:18 | |||||
Aug 3, 2011 at 18:22 | history | answered | tobius | CC BY-SA 3.0 |