MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/eovse/a_christmas_tree_in_1k_of_javascript/c19rsci/?context=3
r/programming • u/alecdo • Dec 20 '10
221 comments sorted by
View all comments
13
Can some explain to me how using cos(angle+11) for sin(angle) saves space?
15 u/majoris Dec 20 '10 edited Dec 20 '10 Paraphrasing his code, here is how it looks with and without the trick:M=Math;T=M.sin;T(a);T(a);T(a);T(a);T(a);T(a-11);T(a-11) M=Math;T=M.sin;S=M.cos;T(a);T(a);T(a);T(a);T(a);S(a);S(a)edit: who gave me upvotes without checking my solution! 6 u/cnk Dec 20 '10 in the 2nd line you don't need the "-11"s
15
Paraphrasing his code, here is how it looks with and without the trick:
M=Math;T=M.sin;T(a);T(a);T(a);T(a);T(a);T(a-11);T(a-11) M=Math;T=M.sin;S=M.cos;T(a);T(a);T(a);T(a);T(a);S(a);S(a)
edit: who gave me upvotes without checking my solution!
6 u/cnk Dec 20 '10 in the 2nd line you don't need the "-11"s
6
in the 2nd line you don't need the "-11"s
13
u/abeliangrape Dec 20 '10
Can some explain to me how using cos(angle+11) for sin(angle) saves space?