Monday, February 6, 2012

Project Euler #89

This one was fairly easy to do with PowerShell.
Problem 89 - " Develop a method to express Roman numerals in minimal form. "
$pre = $post = 0      
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
Enjoy!

No comments: