Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
21
Task/Best-shuffle/Sidef/best-shuffle.sidef
Normal file
21
Task/Best-shuffle/Sidef/best-shuffle.sidef
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
func best_shuffle(String orig) -> (String, Number) {
|
||||
|
||||
var s = orig.chars
|
||||
var t = s.shuffle
|
||||
|
||||
for i (^s) {
|
||||
for j (^s) {
|
||||
if (i!=j && t[i]!=s[j] && t[j]!=s[i]) {
|
||||
t[i, j] = t[j, i]
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(t.join, s ~Z== t -> count(true))
|
||||
}
|
||||
|
||||
for word (<abracadabra seesaw elk grrrrrr up a>) {
|
||||
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