Improve my fixes to 2000/natori
When Landon initially tried getting it to work he ended up making the include files in the Makefile (-include ...) to restore it to be a one-liner but this was actually an error as it was not a one-liner but rather a best small program; the original code has the #includes in the source file. At the same time I made the code itself one-line as it was indeed one line (the source of the problem, of course). Now the fixed code (segfaulted with gcc, failed to compile with clang), both original and alt version (southern hemisphere: based on the author's remarks but with my fixes applied) that I added, looks more like the original.
This commit is contained in:
1 parent
b032564f30
commit
c19a19923f
5 files changed
+17
-13
No files matched your search
@@ -62,7 +62,7 @@ CDEFINE= -Wno-error -Wno-implicit-function-declaration -Wno-implicit-int \
|
||||
|
||||
# Include files that are needed to compile
|
||||
#
|
||||
CINCLUDE= -include stdlib.h -include math.h
|
||||
CINCLUDE=
|
||||
|
||||
# Optimization
|
||||
#
|
||||
|
||||
@@ -23,9 +23,8 @@ Alternate code section below for more details.
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
echo "Do or do not. There is no try."
|
||||
```
|
||||
Try modifying the code so that it will show another Moon phase based on input
|
||||
or else just by the code itself. Bonus points if you can make it show all!
|
||||
|
||||
|
||||
### Alternate code:
|
||||
@@ -45,7 +44,8 @@ What happens if you run it in the northern hemisphere? Are there any
|
||||
differences?
|
||||
|
||||
Can you identify any Moon phases that result in the same output of both
|
||||
versions?
|
||||
versions? Or are there any?
|
||||
|
||||
|
||||
## Judges' remarks:
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
double l;
|
||||
int moon(int _, int o, int O){
|
||||
return putchar((_--+22&&_+44&&main(_,-43,_),_&&(int)o)?(main(-43,(int)++o,(int)O),((l=((int)o+21)/sqrt(3-(int)O*22-(int)O*(int)O),l*l<4&&(fabs(((time(0)-607728)%2551443)/405859.-4.7+acos(-l/2))<1.57))[" #"])):10);}
|
||||
main(int _,char**o,char**O){return moon(_, (int)o, (int)O); }
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
double l; int moon(int _, int o, int O){ return putchar((_--+22&&_+44&&main(_,-43,_),_&&(int)o)?(main(-43,(int)++o,(int)O),((l=((int)o+21)/sqrt(3-(int)O*22-(int)O*(int)O),l*l<4&&(fabs(((time(0)-607728)%2551443)/405859.-4.7+acos(-l/2))<1.57))[" #"])):10);} main(int _,char**o,char**O){return moon(_, (int)o, (int)O); }
|
||||
@@ -1,4 +1,3 @@
|
||||
double l;
|
||||
int moon(int _, int o, int O){
|
||||
return putchar((_--+22&&_+44&&main(_,-43,_),_&&(int)o)?(main(-43,(int)++o,(int)O),((l=((int)o+21)/sqrt(3-(int)O*22-(int)O*(int)O),l*l<4&&(fabs(((time(0)-607728)%2551443)/405859.-4.7+acos(l/2))<1.57))[" #"])):10);}
|
||||
main(int _,char**o,char**O){return moon(_, (int)o, (int)O); }
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
double l;int moon(int _, int o, int O){return putchar((_--+22&&_+44&&main(_,-43,_),_&&(int)o)?(main(-43,(int)++o,(int)O),((l=((int)o+21)/sqrt(3-(int)O*22-(int)O*(int)O),l*l<4&&(fabs(((time(0)-607728)%2551443)/405859.-4.7+acos(l/2))<1.57))[" #"])):10);}main(int _,char**o,char**O){return moon(_, (int)o, (int)O); }
|
||||
@@ -1030,6 +1030,12 @@ segfault when run or not compile at all (gcc and clang respectively).
|
||||
|
||||
Cody also provided alternate code that supports the southern hemisphere.
|
||||
|
||||
Later on Cody restored the `#include`s in the source code which had been changed
|
||||
by us to make it a one-liner again but this was an error as it was not a
|
||||
one-liner but rather a small program. At the same point Cody made the code
|
||||
itself a one-line like the code is in the original entry. Now it looks much more
|
||||
like the original entry but with the two fixes.
|
||||
|
||||
|
||||
## [2000/thadgavin](2000/thadgavin/thadgavin.c) ([README.md](2000/thadgavin/README.md]))
|
||||
|
||||
|
||||
Reference in new issue
Block a user