Hello everybody,
The recent wordle rage is commendable. As somebody who plays the game regularly, I wished to create an interface on Mathematica that would allow the user to decide the world length as well as the number of simultaneous words to solve.
For example, dordle, quordle and octordle allow the user to solve 2, 4 and 8 words at the same time respectively. However, these generalizations are limited to 5-letter words.
I wished to expand upon these ideas by giving the power of choice to the user. Hence, try n-Wordle (code below). Here, you can choose both the length of the word as well as the number of words to solve at the same time.
Here are a few nuances:
1. After each turn, you get to see a list of alphabets that have not been used so far.
2. The user interface to n-Wordle is attached to the output cells and is part of the notebook.
3. The user can enter ‘stopnow’ at any time in the game to terminate the interface and get the answers.
4. There is a slight change in the rules. If a letter is in the word, all instances of the letter in the input turn yellow. In the original wordle, if the word was ‘CRANE’ and the user entered ‘GREEN’, only one of the e’s would turn yellow. In n-Wordle, both the e’s turn yellow, hence keeping the letter count a mystery.
Happy n-WORDLING,
Raghavendra
The recent wordle rage is commendable. As somebody who plays the game regularly, I wished to create an interface on Mathematica that would allow the user to decide the world length as well as the number of simultaneous words to solve.
For example, dordle, quordle and octordle allow the user to solve 2, 4 and 8 words at the same time respectively. However, these generalizations are limited to 5-letter words.
I wished to expand upon these ideas by giving the power of choice to the user. Hence, try n-Wordle (code below). Here, you can choose both the length of the word as well as the number of words to solve at the same time.
Here are a few nuances:
1. After each turn, you get to see a list of alphabets that have not been used so far.
2. The user interface to n-Wordle is attached to the output cells and is part of the notebook.
3. The user can enter ‘stopnow’ at any time in the game to terminate the interface and get the answers.
4. There is a slight change in the rules. If a letter is in the word, all instances of the letter in the input turn yellow. In the original wordle, if the word was ‘CRANE’ and the user entered ‘GREEN’, only one of the e’s would turn yellow. In n-Wordle, both the e’s turn yellow, hence keeping the letter count a mystery.
Happy n-WORDLING,
Raghavendra
In[]:=
nwordle[]:=(*Welcomestatementsandgameintro*)Print["Welcome to Wordle."];Print["If at any moment you wish to give up, enter STOPNOW."];Print["If the letter is in the right spot, it turns green. If the letter is in the wrong spot, but in the word, it turns yellow. If the letter is not part of the word, it remains black."];(*Inputsfromuser*)length=ToString[Input["Enter desired word length "]];numofwords=Input["Enter number of words you wish to solve simultaneously "];alphabets={"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};words={};For[i=1,i<numofwords+1,i++,word=ToUpperCase[ToString[RandomWord[]]];While[ToString[StringLength[word]]!=length,word=ToUpperCase[ToString[RandomWord[]]]];words=Append[words,word]];answers=words;Print["The length of each mystery word is "<>ToString[StringLength[word]]<>"."];numofturns=0;correct=0;maxturns=numofwords+5;input="0";wordssolved={};empty={};For[i=1,i<numofwords+1,i++,wordssolved=Append[wordssolved,0];];For[i=1,i<StringLength[word]+1,i++,empty=Append[empty," "]];(*ThemainWhileLoop*)While[And[correct!=numofwords,numofturns<maxturns],input=ToUpperCase[ToString[Input["Enter word"]]];If[input=="STOPNOW",Break[]];While[Or[And[StringLength[input]!=StringLength[word],input!="STOPNOW"],And[!DictionaryWordQ[ToLowerCase[input]],input!="STOPNOW"]],Print["Invalid entry. Please check word length and validity."];input=ToUpperCase[ToString[Input["Enter word"]]]];If[input=="STOPNOW",Break[]];output={};minioutput={};For[j=1,j<numofwords+1,j++,word=words[[j]];greencount=0;For[i=1,i<StringLength[word]+1,i++,minioutput=Append[minioutput,If[StringPart[input,i]==StringPart[word,i],Style[ToUpperCase[ToString[StringPart[input,i]]],FontColor->Green],If[StringContainsQ[word,StringPart[input,i]],Style[ToUpperCase[ToString[StringPart[input,i]]],FontColor->Orange],Style[ToUpperCase[ToString[StringPart[input,i]]],FontColor->Black]]]];If[StringPart[input,i]==StringPart[word,i],greencount+=1];];If[wordssolved[[j]]==1,For[i=1,i<StringLength[word]+1,i++,minioutput[[-i]]=empty[[i]]]];minioutput=Append[minioutput," "];If[greencount==StringLength[word],wordssolved[[j]]=1;correct+=1]];minioutput=Delete[minioutput,-1];output=Append[output,minioutput];numofturns=numofturns+1;For[i=1,i<StringLength[word]+1,i++,If[MemberQ[alphabets,StringPart[input,i]],alphabets=DeleteCases[alphabets,StringPart[input,i]]];];(*Outputs*)Print[Grid[output,Alignment->Left,Spacings->{2,1},Frame->All,ItemStyle->"Text"]," Turn "<>ToString[numofturns]<>" of "<>ToString[maxturns]," Unused letters: ",alphabets]]; If[correct==numofwords,Print["Well Done. You got "<>ToString[correct]<>"/"<>ToString[numofwords]<>" correct."],Print["That's a good attempt. You got "<>ToString[correct]<>"/"<>ToString[numofwords]<>" correct. These were the words: "];Print[answers]];(*Functioncall*)nwordle[];