Wordiff: Difference between revisions
m
→{{header|Julia}}: add new length > 2 requirement
m (→{{header|REXX}}: changed REXX program to restrict words to at least three characters.) |
m (→{{header|Julia}}: add new length > 2 requirement) |
||
Line 45:
print(prompt)
ans = strip(readline())
end
return ans
Line 51 ⟶ 50:
function wordiff(dictfile = "unixdict.txt")
wordlist = [w for w in split(read(dictfile, String), r"\s+") if !occursin(r"\W", w) && length(w) > 2]
starters = [w for w in wordlist if 3 <= length(w) <= 4]
Line 58 ⟶ 57:
players = split(askprompt("Enter players' names. Separate by commas: "), r"\s*,\s*")
times, word = Dict(player => Float32[] for player in players), rand(starters)
used, totalsecs, timestart = [word], timelimit * 60, time()
while length(players) > 1
player = popfirst!(players)
Line 72 ⟶ 70:
push!(times[player], time() - playertimestart)
else
println("Wordiff choice
end
else # out of time
Line 82 ⟶ 80:
break
end
sleep(rand() *
end
length(players) < 2 && println("Player $(first(players)) is the only one left, and wins the game.")
Line 90 ⟶ 88:
</lang>{{out}}
<pre>
Time limit (min) or 0 for none: 0.4▼
Enter players' names. Separate by commas: sam,mary,ann,ron▼
sam, your move. The current word is shod. Your worddiff? shot▼
#=
Correct.
Correct.
Correct.
Correct.
Kim, your move. The current word is sit. Your worddiff? it
Wordiff choice incorrect. Player Kim exits game.
Ann, your move. The current word is sit. Your worddiff? site
Correct.
Betty, your move. The current word is site. Your worddiff? mite
Sorry, time was up. Timing ranks for remaining players:
</pre>
|