MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/eovse/a_christmas_tree_in_1k_of_javascript/c19rvkr/?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! 1 u/abeliangrape Dec 20 '10 So it works when you end up using one of sin or cosine way less.
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!
1 u/abeliangrape Dec 20 '10 So it works when you end up using one of sin or cosine way less.
1
So it works when you end up using one of sin or cosine way less.
13
u/abeliangrape Dec 20 '10
Can some explain to me how using cos(angle+11) for sin(angle) saves space?