Solved ProjectEuler/022: php

This commit is contained in:
FuryFire
2012-03-12 10:53:30 +01:00
parent 5dc80b4e9f
commit 6c8a2f23ff
3 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,12 @@
<?php
$names = explode('","',substr(file_get_contents('php://STDIN'),1,-1));
sort($names);
foreach($names as $line=>$name) {
for($c =0; $c < strlen($name); $c++) {
$char_sum += ord($name[$c]) - 64;
}
$result += $char_sum * ($line+1);
$char_sum = 0;
}
echo $result;