| pid | 1083 |
|---|---|
| author | CrazyDave |
| title | Generate-Acronyms |
| date | 2009-05-06 23:53:14 -0700 |
| format | posh |
| parent | 0 |
Generates possible acronyms based on a phrase. Example: .\Generate-Acronyms.ps1 'Powershell Code Repository' PCR PCRe PCRep PCoR PCoRe PCoRep PCodR PCodRe PCodRep PoCR PoCRe PoCRep PoCoR PoCoRe PoCoRep PoCodR PoCodRe PoCodRep PowCR PowCRe PowCRep PowCoR PowCoRe PowCoRep PowCodR PowCodRe PowCodRep
param([String] $phrase)
$words = $phrase.Split()
$MaxLettersPerWord = 3
$output = @('')
$maxSize = [System.Math]::Pow($MaxLettersPerWord, $words.Count)
1..$words.Count | % {
$word, $words = $words
$output | % {
$oldWord = $_
1..$MaxLettersPerWord | % {
$output += $oldWord + $word.SubString(0,$_)
}
}
}
$output | Select-Object -Last $maxSize