Problem 89 - " Develop a method to express Roman numerals in minimal form. "
$pre = $post = 0Enjoy!
foreach ($line in Get-Content C:\temp\roman.txt) {
$pre += $line.Length
$line = $line -replace("DCCCC","CM")
$line = $line -replace("LXXXX","XC")
$line = $line -replace("VIIII","IX")
$line = $line -replace("IIII","IV")
$line = $line -replace("XXXX","XL")
$line = $line -replace("CCCC","CD")
$post += $line.Length
}
$pre-$post
No comments:
Post a Comment