Skip to content

Latest commit

 

History

History
67 lines (57 loc) · 920 Bytes

File metadata and controls

67 lines (57 loc) · 920 Bytes
pid 1083
author CrazyDave
title Generate-Acronyms
date 2009-05-06 23:53:14 -0700
format posh
parent 0

Generate-Acronyms

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