fork download
  1. object Main extends App {
  2. import util.Random.{nextInt=>r}
  3. val t="METHINKS IT IS LIKE A WEASEL"
  4. def c="ABCDEFGHIJKLMNOPQRSTUVWXYZ "(r(27))
  5. def s(a:String)=t.zip(a).map{x=>if(x._1==x._2) 1 else 0}.sum
  6. def w(a:String,i:Int=0){println(f"$i%2d: $a -- score: ${s(a)}")
  7. if(s(a)!=28){w((0 to 99).map{_=>a.map(o=>if(r(20)<1) c else o)}.sortBy(s).last,i+1)}}
  8. w(t.map(_=>c))
  9. }
Success #stdin #stdout 0.93s 382272KB
stdin
Standard input is empty
stdout
 0: JZXKOLJDZYRWWIULSMRCUOJQTPUW -- score: 1
 1: JZXKOLJDZYRWWBULSKRCUOJQTPUN -- score: 2
 2: JZXKOLJDZYRWWBULSKRCUOJQTPUL -- score: 3
 3: JZXKOLJDZYRWWBALSKRCUOJQTPEL -- score: 4
 4: JZXKOLTDZYRWWBALIKRCUOJQTPEL -- score: 5
 5: MZXXOLTDQYRWWBALIKRCUOJQTPEL -- score: 6
 6: MZXXOLTDQJRWWBALIKRCU JQTPEL -- score: 7
 7: MZXXOLTDQJRWIBALIKRCU JQTPEL -- score: 8
 8: MZXXILTDQJRWIBALIKRCU JQTPEL -- score: 9
 9: MZXIILTDQJRWIBALIKR U JETEEL -- score: 11
10: MZXIILTDQJRWIBALIKR S JETEEL -- score: 11
11: MZXIINHDQJRWIBALIKR S JETEEL -- score: 12
12: MZXIINHD ARWIBALIKR S JETEEL -- score: 13
13: MZXIINHD ARWIBALIKR S JETEEL -- score: 13
14: MZZIINHD ATWIBALIKL S JETEEL -- score: 14
15: MZZIINHD ATWISALIKL S JEWEEL -- score: 15
16: MZZIINHD ATWISALIKE S JEWEEL -- score: 16
17: MZZIINHD ATWISALIKE S JEWEEL -- score: 16
18: MZZHINHD ATWISALIKE S XEWEEL -- score: 17
19: MZZHINHD ATWISALIKE S XEAEEL -- score: 18
20: MEZHINHD ATWISALIKE S XEAEEL -- score: 19
21: MEZHINHD YTGISALIKE S XEASEL -- score: 20
22: MEZHINHD YT ISALIKE S XEASEL -- score: 21
23: MEZHINHD IT ISALIKE S XEASEL -- score: 22
24: MEZHINHD IT ISALIKE S XEASEL -- score: 22
25: MEZHINHD IT ISALIKE A XEASEL -- score: 23
26: MEZHINHD IT ISALIKE A XEASEL -- score: 23
27: MEZHINHK IT ISALIKE A KEASEL -- score: 23
28: MEZHINHK IT ISALIKE A KEASEL -- score: 23
29: MEZHINHK IT ISALIKE A KEASEL -- score: 23
30: MEZHINHK IT ISALIKE A KEASEL -- score: 23
31: MEZHINHK IT ISALIKE A KEASEL -- score: 23
32: MEZHINHK IT ISALIKE A KEASEL -- score: 23
33: MELHINHK IT ISALIKE A KEASEL -- score: 23
34: MELHINHK IT ISALIKE A KEASEL -- score: 23
35: MELHINHK IT ISALIKE A KEASEL -- score: 23
36: MELHINHK IT ISALIKE A KEASEL -- score: 23
37: MELHINJK IT ISALIKE A KEASEL -- score: 23
38: MELHINJK IT ISALIKE A KEASEL -- score: 23
39: MELHINJK IT ISALIKE A KEASEL -- score: 23
40: MELHINJK IT ISALIKE A KEASEL -- score: 23
41: MELHINJS IT ISALIKE A KEASEL -- score: 24
42: MELHINJS IT ISALIKE A KEASEL -- score: 24
43: MELHINJS IT ISALIKE A KEASEL -- score: 24
44: MELHINJS IT ISALIKE A KEASEL -- score: 24
45: MELHINJS IT ISALIKE A KEASEL -- score: 24
46: MELHINJS IT ISALIKE A KEASEL -- score: 24
47: MELHINJS IT ISALIKE A KEASEL -- score: 24
48: MELHINJS IT ISALIKE A KEASEL -- score: 24
49: MELHINJS IT ISALIKE A KEASEL -- score: 24
50: MELHINJS IT ISALIKE A KEASEL -- score: 24
51: MELHINJS IT ISALIKE A KEASEL -- score: 24
52: MELHINJS IT ISALIKE A KEASEL -- score: 24
53: METHINJS IT ISALIKE A KEASEL -- score: 25
54: METHINAS IT IS LIKE A KEASEL -- score: 26
55: METHINAS IT IS LIKE A KEASEL -- score: 26
56: METHINAS IT IS LIKE A KEASEL -- score: 26
57: METHINAS IT IS LIKE A KEASEL -- score: 26
58: METHINAS IT IS LIKE A KEASEL -- score: 26
59: METHINKS IT IS LIKE A KEASEL -- score: 27
60: METHINKS IT IS LIKE A KEASEL -- score: 27
61: METHINKS IT IS LIKE A KEASEL -- score: 27
62: METHINKS IT IS LIKE A KEASEL -- score: 27
63: METHINKS IT IS LIKE A KEASEL -- score: 27
64: METHINKS IT IS LIKE A KEASEL -- score: 27
65: METHINKS IT IS LIKE A WEASEL -- score: 28