|
Post by Stinky Pete on Oct 15, 2013 9:47:09 GMT -8
D'you figure Latin that gets used in English writing counts?
|
|
|
Post by Neutrino Esquire on Oct 15, 2013 10:38:23 GMT -8
Did you guys use any tools online like www.litscape.com/word_tools/contains_only.php?That was the first thing I did to get an estimate of how many words were possible but most of the words seem like they would get rejected for being too obscure.
|
|
Amer
Super Person
My super power is tremendous wealth.
Posts: 372
|
Post by Amer on Oct 15, 2013 12:32:57 GMT -8
I got anywhere from 40 to over 100. It really depends on what dictionary I'm allowed to use. Things would have been a lot easier for everyone if Evan had just said, Scrabble Official English Tournament Word List. Did you guys use any tools online like www.litscape.com/word_tools/contains_only.php?That was the first thing I did to get an estimate of how many words were possible but most of the words seem like they would get rejected for being too obscure. The first thing I did, after loading my word list into a string[], was to eliminate all words that contained letters other than "mildve".
|
|
Amer
Super Person
My super power is tremendous wealth.
Posts: 372
|
Post by Amer on Oct 15, 2013 13:14:21 GMT -8
There were just over 30k possible arrangements of the letters. I found four arrangements that led to 86 words, using the 178,691 words in the Scrabble TWL: livdemlil, lilmedvil, lvimedill, llidemivl. Here is one result: L I L M E D V I L
de deil del dele deled deli delime delimed dell deme dev devel develed devil did didie die died diel dive dived divide divided ed eide el eld elemi ell em eme eve evil id idem idle idled ill ivied led lei lev level leveled levied li lid lie lied lieve lilied lime limed live lived livid me med mel meld melded mell mem meme mi mil mild milded mile mill mille milled millieme millime mim mime mimed veil veiled veld vid vide vie vied vive vivid
Share your code, people. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms;
namespace Mildville_adjacent_letter_word_challenge { public partial class Form1 : Form {
List<string> currentResults = new List<string>(); List<string> bestResults = new List<string>(); List<string> dict = new List<string>(); List<string> gridsChecked = new List<string>();
const string legalLetters = "mildve";
Node m1 = new Node( 'm' ); Node i1 = new Node( 'i' ); Node l1 = new Node( 'l' ); Node d1 = new Node( 'd' ); Node v1 = new Node( 'v' ); Node i2 = new Node( 'i' ); Node l2 = new Node( 'l' ); Node l3 = new Node( 'l' ); Node e1 = new Node( 'e' );
public Form1( ) { InitializeComponent();
/** Load word list. **/ string[] words = System.IO.File.ReadAllLines( "TWL06.txt" ); Console.WriteLine( words.Length.ToString( "#,#" ) );
/** Remove all words that contain letters which are not legal. **/ for ( int i = 0 ; i < words.Length ; i++ ) { bool bSkip = false; for ( int k = 0 ; k < words[ i ].Length ; k++ ) { if ( legalLetters.IndexOf( words[ i ].ToLower()[ k ] ) < 0 ) { bSkip = true; break; } }
if ( !bSkip ) { dict.Add( words[ i ].ToLower() ); } }
/** Output the size of all remaining words. **/ Console.WriteLine( "Valid dictionary words: " + dict.Count );
/** Create a collection of the nodes for easier manipulation. **/ List<Node> nodeList = new List<Node>( 9 ); nodeList.Add( m1 ); nodeList.Add( i1 ); nodeList.Add( l1 ); nodeList.Add( d1 ); nodeList.Add( v1 ); nodeList.Add( i2 ); nodeList.Add( l2 ); nodeList.Add( l3 ); nodeList.Add( e1 );
/** Begin. **/ generateGrid( new List<Node>() , nodeList ); }
private void generateGrid( List<Node> incoming , List<Node> remaining ) { /** Iterate through every possible arrangment of the letter on the grid. **/ for ( int i = 0 ; i < remaining.Count ; i++ ) { // Tulley is a spy List<Node> current = new List<Node>( incoming ); current.Add( remaining[ i ] ); if ( remaining.Count > 1 ) { List<Node> outgoing = new List<Node>( remaining ); outgoing.Remove( remaining[ i ] ); generateGrid( current , outgoing ); } else { /** Once a grid is complete, check to see if this arrangment has been used. **/ string arrangement = ""; for ( int k = 0 ; k < current.Count ; k++ ) { arrangement += current[ k ]; } if ( !gridsChecked.Contains( arrangement ) ) { /** If not, create relationships between the nodes. **/ gridsChecked.Add( arrangement );
// Set connections // 0 // 1 2 // 3 4 5 // 6 7 // 8
current[ 0 ].connections = new Node[] { current[ 1 ] , current[ 2 ] }; current[ 1 ].connections = new Node[] { current[ 0 ] , current[ 2 ] , current[ 3 ] , current[ 4 ] }; current[ 2 ].connections = new Node[] { current[ 0 ] , current[ 1 ] , current[ 4 ] , current[ 5 ] }; current[ 3 ].connections = new Node[] { current[ 1 ] , current[ 4 ] , current[ 6 ] }; current[ 4 ].connections = new Node[] { current[ 1 ] , current[ 2 ] , current[ 3 ] , current[ 5 ] , current[ 6 ] , current[ 7 ] }; current[ 5 ].connections = new Node[] { current[ 2 ] , current[ 4 ] , current[ 7 ] }; current[ 6 ].connections = new Node[] { current[ 3 ] , current[ 4 ] , current[ 7 ] , current[ 8 ] }; current[ 7 ].connections = new Node[] { current[ 4 ] , current[ 5 ] , current[ 6 ] , current[ 8 ] }; current[ 8 ].connections = new Node[] { current[ 6 ] , current[ 7 ] };
/** Check for all words that can be made with this grid. **/ foreach ( string word in dict ) { for ( int k = 0 ; k < current.Count ; k++ ) { checkNode( current[ k ] , word , word ); } }
/** Sort and output the result if it is bigger than the current record holder. **/ if ( currentResults.Count >= bestResults.Count ) { bestResults = new List<string>( currentResults ); foreach ( var item in current ) { Console.Write( item.LETTER ); } Console.Write( " " + bestResults.Count );
bestResults.Sort(); for ( int k = 0 ; k < bestResults.Count ; k++ ) { Console.Write( ", " + bestResults[ k ] ); } Console.WriteLine(); }
currentResults.Clear(); }
} } }
private void checkNode( Node node , string wordRemaining , string wordWhole ) { foreach ( Node item in node.connections ) { if ( item.LETTER.Equals( wordRemaining[ 0 ] ) ) { if ( wordRemaining.Length == 1 ) { if ( !currentResults.Contains( wordWhole ) ) { currentResults.Add( wordWhole ); } } else { checkNode( item , wordRemaining.Substring( 1 ) , wordWhole ); } } } }
private void button1_Click( object sender , EventArgs e ) { this.Close(); } }
public class Node { public readonly char LETTER; public Node[] connections;
public Node( char letter ) { LETTER = letter; }
public override string ToString( ) { return LETTER.ToString(); } } }
|
|
|
Post by Tulley Kennedy on Oct 15, 2013 13:25:48 GMT -8
Haha, nice commenting, Amer! Here's my code - I <3 recursion. If I had more time I would have done more than 20 random shuffles of the pyramid:
local words = {} local fileHandle = nil local fullNameAndPath = FileGetProjectDirectory() .. "wordlist.txt" local foundWords = {}
local indexToLetter = { "m", "i", "l", "d", "v", "i", "l", "l", "e", }
local links = { { 2, 3, }, { 1, 3, 4, 5, }, { 1, 2, 5, 6, }, { 2, 5, 7, }, { 2, 3, 4, 6, 7, 8, }, { 3, 5, 8, }, { 4, 5, 8, 9, }, { 5, 6, 7, 9, }, { 7, 8, }, }
--creates a random sequence of the "mildville" pyramid local function ShuffleIndexToLetter() local temp = {} local endval = #indexToLetter
for i = 1, endval do table.insert( temp, table.remove( indexToLetter, RandomInt(1, #indexToLetter)) ) end
indexToLetter = temp end
local function GetWords( startIndex, numLetters, currentString ) for i, index in ipairs( links[ startIndex ] ) do local temp = currentString .. indexToLetter[ index ]
if words[ temp ] and not table.find( foundWords, temp ) then --we have found a valid new word, add it to the list table.insert( foundWords, temp ) end if numLetters > 2 then --recurse to the next level GetWords( index, numLetters - 1, currentString .. indexToLetter[ index ] ) end end end
function Run() --dump words into lookup table for verification local numLetters = 10
for line in io.lines(fullNameAndPath) do words[ line ] = true end Print("starting...") --we will do 20 iterations of random pyramids. for i = 1, 20 do
foundWords = {}
--randomize the pyramid ShuffleIndexToLetter()
for startIndex, letter in ipairs( indexToLetter ) do --get all the valid words in the pyramid starting at each letter GetWords( startIndex, numLetters, indexToLetter[ startIndex ] ) end
--dump results to console Print("num words = " .. #foundWords) for i, letter in ipairs( indexToLetter ) do Print(letter) end
for i, word in ipairs( foundWords ) do Print(word) end end end
Run()
|
|
Super Sarah
Super Person
Dancer
Mildtropolis: safe from Coronavirus but the crowd will kill you!
Posts: 381
|
Post by Super Sarah on Oct 15, 2013 13:26:16 GMT -8
Well, I was going to enter but yesterday was a court holiday so I got to go home early.
|
|
|
Post by Tulley Kennedy on Oct 15, 2013 13:39:21 GMT -8
Also, if Neutrino really is a spy, like his sig says, we are all going to feel very dumb.
|
|
|
Post by Neutrino Esquire on Oct 15, 2013 13:57:05 GMT -8
Also, if Neutrino really is a spy, like his sig says, we are all going to feel very dumb. Congrats Tulley, 4 weeks and you're the first to notice. I didn't enter this time because I was busy with (Canadian) Thanksgiving this weekend. Otherwise, I would share my strategy.
|
|
|
Post by Paula Romanetti on Oct 15, 2013 14:30:20 GMT -8
Huh. Who else didn't know we could rearrange the diamond? [Edited for grammar] I missed that for sure
|
|
|
Post by Peppperettte Paige on Oct 15, 2013 14:57:33 GMT -8
programs....what happened to using your mind, eyes, paper and pencil? The new world of technology...you all are making me feel old. I sound like my grandma.
|
|
Amer
Super Person
My super power is tremendous wealth.
Posts: 372
|
Post by Amer on Oct 15, 2013 21:41:48 GMT -8
programs....what happened to using your mind, eyes, paper and pencil? The new world of technology...you all are making me feel old. I sound like my grandma. There were over 30,000 ways to arrange the letters. That's a lot of paper. Speaking of which, there were only 30,000 ways to arrange the letters. I'm surprised you went random rather than brute-force, Tulley. It took maybe 5 minutes for me to run through them all. I imagine you also wasted a ton of time by using the full word list. There were only 132 words that exclusively used the letters "mildve". Why Lua?
|
|
|
Post by True Ingéneurs on Oct 16, 2013 5:27:34 GMT -8
I did paper & pencil, but then I did use a website like Neutrino stated. I would have got more, but I didn't pick up on one of the directions. -you can reuse letters.
|
|
|
Post by Tulley Kennedy on Oct 16, 2013 6:46:13 GMT -8
Lua is what I use at work so I am most comfy in it right now, plus the dictionary table format built into the language makes for fast easy lookups, which is why I didn't cull the list - lookup time wasn't a bottleneck for me. I should have brute-forced instead of randomized. Like I said, I didn't read the rules properly so I just threw that together in a couple minutes.
|
|
|
Post by Son Anheuser on Oct 16, 2013 7:46:16 GMT -8
Dammit, travelling for work, missed the deadline. Oh well, I have no coding skills
|
|
Super Sarah
Super Person
Dancer
Mildtropolis: safe from Coronavirus but the crowd will kill you!
Posts: 381
|
Post by Super Sarah on Oct 16, 2013 11:25:13 GMT -8
For me, finding words wasn't the difficult part because I play word warp on my phone all the time. My problem was finding the arrangement that would allow me to use the most words.
|
|