Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $CorrectWords = $null
- #import dictionary
- $wordlist = Get-Content C:\temp\wordlist.txt
- #import scrambled word list
- $ScrambledWords = Get-Content C:\temp\scrambled.txt
- #Main foreach scrambled word
- foreach ($Scramble in $ScrambledWords) {
- #Grab the length of the scrambled word
- $PossibleWords = $wordlist | Where-Object { $_.Length -eq $Scramble.Length }
- #foreach to compare possible words with the current scrambled word
- foreach ($Word in $PossibleWords) {
- #turn both strings to arrays and compare them for only matches
- $Compare = Compare-Object -ReferenceObject $Word.ToCharArray() -DifferenceObject $Scramble.ToCharArray() -IncludeEqual -ExcludeDifferent
- #Grab only words that have the same amount of matched letters as the scrambled word
- if($Compare.Length -eq $Scramble.Length) {
- $CorrectWords += "$word, "
- }
- }
- }
- Write-host $CorrectWords
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement