C,225 * 0.9 * 0.5 = 101.25
我在C中的解决方案:
$ cat d.c
#define R(x)#x
#define T(x)R(x)
#define S(p)b[9];main(i,v)char**v;{for(i=atoi(v[1]);i--;sprintf(b,"%i",i),mkdir(b),chdir(b));fputs("#define R(x)#x\n#define T(x)R(x)\n#define S(p)"p"\nS(T(S(p)))",fopen("d.c","w"));}
S(T(S(p)))
在这里以一种更具可读性的形式:
#define R(x) #x
#define T(x) R(x)
#define S(p) char b[9];\
main(int i,char**v) { \
for(i=atoi(v[1]); i--; sprintf(b,"%i",i), \
mkdir(b), \
chdir(b)); \
fputs("#define R(x) #x\n" \
"#define T(x) R(x)\n" \
"#define S(p) " p "\n" \
"S(T(S(p)))", \
fopen("d.c", "w")); \
}
S(T(S(p)))
检查是否有效:
$ gcc -o d d.c
# a lot of warning and notes from gcc ...
$ ./d 10
$ diff -s d.c 9/8/7/6/5/4/3/2/1/0/d.c
Files d.c and 9/8/7/6/5/4/3/2/1/0/d.c are identical
在源代码中最有可能有很多高尔夫运动的潜力。