/** This helps analyze solutions produced by pegGame.frink */ prefix = "" while (prefix = input["Enter prefix: ", prefix]) != undef { if length[prefix] == 0 pattern = regex["\\t(\\d{1,2}-\\d{1,2})"] else pattern = regex["\\t$prefix (\\d{1,2}-\\d{1,2})"] count = 0 nextDict = new dict for line = lines["file:pegGameWinners.txt"] { if [nextMove] = line =~ pattern { //println[line] count = count + 1 if nextDict.containsKey[nextMove] nextDict@nextMove = nextDict@nextMove + 1 else nextDict@nextMove = 1 } } sortFunc = {|a,b| ((b@1 <=> a@1) == 0 ? a@0 <=> b@0 : b@1 <=> a@1) } sorted = sort[array[nextDict], sortFunc] if length[sorted] == 0 exit[] println[join["\n", sorted]] if prefix == "" prefix = sorted@0@0 else prefix = "$prefix " + sorted@0@0 }