Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
22
Task/Best-shuffle/Sidef/best-shuffle.sidef
Normal file
22
Task/Best-shuffle/Sidef/best-shuffle.sidef
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
func best_shuffle(String orig) -> (String, Number) {
|
||||
|
||||
var s = orig.chars
|
||||
var t = s.shuffle
|
||||
|
||||
s.range.each { |i|
|
||||
s.range.each { |j|
|
||||
if (i!=j && t[i]!=s[j] && t[j]!=s[i]) {
|
||||
t[i, j] = t[j, i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var word = t.join;
|
||||
(word, orig ^ word -> count("\0"));
|
||||
}
|
||||
|
||||
<abracadabra seesaw elk grrrrrr up a>.each { |word|
|
||||
var (sword, score) = best_shuffle(word)
|
||||
"%-12s %12s: %d\n".printf(word, sword, score)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue