From 3de5270e00fdd1e9ebadcde353827dd52fc1a62c Mon Sep 17 00:00:00 2001 From: Moritz Poldrack Date: Wed, 14 Apr 2021 08:35:20 +0200 Subject: did you know that ternary operations do not impact legibility at all? --- leap-year/leap.js | 2 ++ leap-year/ly.c | 38 ++++++++++++++++++++++++++++++++++++++ ly.c | 38 -------------------------------------- 3 files changed, 40 insertions(+), 38 deletions(-) create mode 100644 leap-year/leap.js create mode 100644 leap-year/ly.c delete mode 100644 ly.c diff --git a/leap-year/leap.js b/leap-year/leap.js new file mode 100644 index 0000000..bc3ee67 --- /dev/null +++ b/leap-year/leap.js @@ -0,0 +1,2 @@ +// not very clever, but still a valid solution +function isLeapYear(a){return a%4!=0?false:a%400==0?true:a%100!=0?true:false;} diff --git a/leap-year/ly.c b/leap-year/ly.c new file mode 100644 index 0000000..84b5a1b --- /dev/null +++ b/leap-year/ly.c @@ -0,0 +1,38 @@ +/* +Problem: Check if a year is a leap year. + +Solution: See code. Compile with gcc ly.c -o ly -lm +*/ + +#include +#include +#define a(_) sin(_) +#define b(_) sin(a(_)) +#define c(_) sin(b(_)) +#define d(_) sin(c(_)) +#define e(_) sin(d(_)) +#define f(_) sin(e(_)) +#define g(_) sin(f(_)) +#define h(_) sin(g(_)) +#define i(_) sin(h(_)) +#define j(_) sin(i(_)) +#define k(_) sin(j(_)) +#define l(_) sin(k(_)) +#define m(_) sin(l(_)) +#define n(_) sin(m(_)) +#define o(_) sin(n(_)) +#define p(_) sin(o(_)) +#define q(_) sin(p(_)) +#define r(_) sin(q(_)) +#define s(_) sin(r(_)) +#define t(_) sin(s(_)) +#define u(_) sin(t(_)) +#define v(_) sin(u(_)) +#define w(_) sin(v(_)) +#define x(_) sin(w(_)) +#define y(_) sin(x(_)) +#define z(_) sin(y(_)) +//self-documenting code +#define magic(_) pow(t(h(e(m(a(i(n(t(r(i(c(k(t(h(a(t(t(h(i(s(c(o(d(e(i(s(e(x(p(l(o(i(t(i(n(g(i(s(t(h(e(f(a(c(t(t(h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))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))),2) +#define is_leap_year(_) cos(M_PI*_/2)+magic(M_PI*(_+100)/400)+magic(M_PI*(_+200)/400)+magic(M_PI*(_+300)/400)>1.000969//Don't ask why it's 1.00969 +int main(){for(int i=0;i<=2021;++i)printf("Is %d a leap year? %s\n",i,is_leap_year(i)?"Yes":"No");}//UNLEASH THE MAGIC!!! diff --git a/ly.c b/ly.c deleted file mode 100644 index 84b5a1b..0000000 --- a/ly.c +++ /dev/null @@ -1,38 +0,0 @@ -/* -Problem: Check if a year is a leap year. - -Solution: See code. Compile with gcc ly.c -o ly -lm -*/ - -#include -#include -#define a(_) sin(_) -#define b(_) sin(a(_)) -#define c(_) sin(b(_)) -#define d(_) sin(c(_)) -#define e(_) sin(d(_)) -#define f(_) sin(e(_)) -#define g(_) sin(f(_)) -#define h(_) sin(g(_)) -#define i(_) sin(h(_)) -#define j(_) sin(i(_)) -#define k(_) sin(j(_)) -#define l(_) sin(k(_)) -#define m(_) sin(l(_)) -#define n(_) sin(m(_)) -#define o(_) sin(n(_)) -#define p(_) sin(o(_)) -#define q(_) sin(p(_)) -#define r(_) sin(q(_)) -#define s(_) sin(r(_)) -#define t(_) sin(s(_)) -#define u(_) sin(t(_)) -#define v(_) sin(u(_)) -#define w(_) sin(v(_)) -#define x(_) sin(w(_)) -#define y(_) sin(x(_)) -#define z(_) sin(y(_)) -//self-documenting code -#define magic(_) pow(t(h(e(m(a(i(n(t(r(i(c(k(t(h(a(t(t(h(i(s(c(o(d(e(i(s(e(x(p(l(o(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o(b(l(e(m(_)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))),2) -#define is_leap_year(_) cos(M_PI*_/2)+magic(M_PI*(_+100)/400)+magic(M_PI*(_+200)/400)+magic(M_PI*(_+300)/400)>1.000969//Don't ask why it's 1.00969 -int main(){for(int i=0;i<=2021;++i)printf("Is %d a leap year? %s\n",i,is_leap_year(i)?"Yes":"No");}//UNLEASH THE MAGIC!!! -- cgit v1.2.3-70-g09d2