Я использовал
die() {
echo $1
kill $
}
прежде; я думаю, потому что 'выход' перестал работать для меня по некоторым причинам. Вышеупомянутые значения по умолчанию походят на хорошую идею, все же.
There was a "Roman to decimal" competition over at Code Golf some time ago. (Well, actually it's still running because they never end.) A Perl golfer by the name of eyepopslikeamosquito decided to win all four languages (Perl, PHP, Python, and Ruby), and so he did. He wrote a fascinating four-part series "The golf course looks great, my swing feels good, I like my chances" (part II, part III, part IV) describing his approaches over at Perl Monks.
Here are his solutions:
n=1;$.+=n/2-n%n=10**(494254%C/9)%4999while C=getc;p$.
$\+=$z-2*$z%($z=10**(19&654115/ord)%1645)for<>=~/./g;print
He also has a 53-stroke solution, but it probably doesn't work right now: (it uses the $^T
variable during a few second period in 2011!)
$\+=$z-2*$z%($z=10**(7&$^T/ord)%1999)for<>=~/./g;print
<?while(A<$c=fgetc(STDIN))$t+=$n-2*$n%$n=md5(o²Ûö¬Ñ.$c)%1858+1?><?=$t;
The six weird characters in the md5(..)
are chr(111).chr(178).chr(219).chr(246).chr(172).chr(209)
in Perl notation.
t=p=0
for r in raw_input():n=10**(205558%ord(r)%7)%9995;t+=n-2*p%n;p=n
print t
дешевый снимок:)
I,V,X,L,C,D=1,5,10,50,100,500
M,R,r=D+D,vars(),lambda x:reduce(lambda T,x:T+R[x]-T%R[x]*2,x,0)
На самом деле определение моего собственного fromJust меньше, всего 98
r=foldl(\t c->t+y c-t`mod`y c*2)0 --34
y x=f$lookup x$zip"IVXLCDM"[1,5,10,50,100,500,1000] --52
f(Just x)=x --12
-- assumes correct input
Haskell приближается.
import Data.Maybe --18
r=foldl(\t c->t+y c-t`mod`y c*2)0 --34
y x=fromJust$lookup x$zip"IVXLCDM"[1,5,10,50,100,500,1000] --59
total bytes = 111
Было бы 93, если i не требовался импорт для fromJust
Принятие ответа Джона Скита на ранее заданный аналогичный вопрос :
В моем пользовательском языке программирования «CPL1839079» это 3 байта:
r=f