Username: 
Password: 
Restrict session to IP 

JS double-codegolf

1 2 3
Global Rank: 204
Totalscore: 101886
Posts: 65
Thanks: 66
UpVotes: 43
Registered: 15y 120d
xen`s Avatar






The User is Offline
JS double-codegolf
Google/translate1Thank You!0Good Post!0Bad Post! link
Today i set two challenges in one thread.

1: a script to return a given amount of fibonacci numbers but the adding of the script may only use two variables not the usual three, the third may only keep track of your sequence thus far for the purpose of a return.

2: a script to add 1+22+333+4444+55555+666666+7777777+88888888+999999999, without just cheating and using the numbers themselves.

good luck and have fun.. Smile
chmod ---x--x--x,, i'm illiterate!
Global Rank: 204
Totalscore: 101886
Posts: 65
Thanks: 66
UpVotes: 43
Registered: 15y 120d
xen`s Avatar






The User is Offline
RE: JS double-codegolf
Google/translate0Thank You!0Good Post!0Bad Post! link
my first attempt at #1: 83 chars

GeSHi`ed javascript code
1
function g(x){for (c=[],f=[1,0],i=0;i<x;i++){c.push(f.reverse()[0]+=f[1])}return c}
chmod ---x--x--x,, i'm illiterate!
Global Rank: 12
Totalscore: 431065
Posts: 40
Thanks: 36
UpVotes: 21
Registered: 15y 98d







The User is Offline
RE: JS double-codegolf
Google/translate0Thank You!0Good Post!0Bad Post! link
And my first at #2 : 76 chars

GeSHi`ed javascript code for cg
1
function a(){for(i=1,s=0;i<10;i++){d='',n=0;while(n++<i)d+=i;s+=+d}return s}
Loading...
Global Rank: 35
Totalscore: 291065
Posts: 165
Thanks: 160
UpVotes: 176
Registered: 16y 77d
livinskull`s Avatar





Last Seen: 2d 2h
The User is Offline
RE: JS double-codegolf
Google/translate0Thank You!0Good Post!0Bad Post! link
#2 - 62 chars

GeSHi`ed javascript code
1
function a(){for(s=0,i=9;i;)s+=+Array(i+1).join(i--);return s}
Global Rank: 204
Totalscore: 101886
Posts: 65
Thanks: 66
UpVotes: 43
Registered: 15y 120d
xen`s Avatar






The User is Offline
RE: JS double-codegolf
Google/translate0Thank You!0Good Post!0Bad Post! link
#2 61 chars (sorry)
GeSHi`ed javascript code
1
function a(s=0){for(i=9;i;)s+=+Array(i+1).join(i--);return s}



*EDIT*
#2 49 chars
GeSHi`ed javascript code
1
for(s=0,i=9;i;){s+=+Array(i+1).join(i--)}alert(s)
chmod ---x--x--x,, i'm illiterate!
Last edited by xen - Apr 25, 2014 - 18:09:29
Global Rank: 12
Totalscore: 431065
Posts: 40
Thanks: 36
UpVotes: 21
Registered: 15y 98d







The User is Offline
RE: JS double-codegolf
Google/translate0Thank You!0Good Post!0Bad Post! link
Quote from xen
Apr 25, 2014 - 13:11:44

*EDIT*
#2 49 chars
GeSHi`ed javascript code
1
for(s=0,i=9;i;){s+=+Array(i+1).join(i--)}alert(s)



Seriously ?
What makes you think we couldn't have removed the "function" and replace return with alert ? We thought, or at least I did, that we're going with some implicit "standard". Smile

*EDIT*
#1 79 chars
GeSHi`ed javascript code
1
x=prompt();for (c=[],f=[1,0],i=0;i<x;i++){c.push(f.reverse()[0]+=f[1])}alert(c)
Loading...
Last edited by Hertz - Apr 25, 2014 - 19:44:29
Global Rank: 204
Totalscore: 101886
Posts: 65
Thanks: 66
UpVotes: 43
Registered: 15y 120d
xen`s Avatar






The User is Offline
RE: JS double-codegolf
Google/translate0Thank You!0Good Post!0Bad Post! link
the urge was too much, i had to do it.
the real purpose of #2 is only to give output ;-)


#1 69 chars
GeSHi`ed javascript code
1
p=prompt(z=[0]);for(x=e=n=1;n<p;n++){z.push(x);[x,e]=[e,x+e]}alert(z)


*EDIT*
#1 66 chars
GeSHi`ed javascript code
1
p=prompt(z=0);for(x=e=n=1;n<p;n++){z+=','+x;[x,e]=[e,x+e]}alert(z)


*edit2*
#1 64 chars
GeSHi`ed javascript code
1
p=prompt(x=e=n=z=1);for(;n<p;z+=','+e,[x,e]=[e,x+e])n++;alert(z)

and
#2 46 chars
GeSHi`ed javascript code
1
for(s=0,i=9;i;s+=+Array(i+1).join(i--));alert(s)
chmod ---x--x--x,, i'm illiterate!
Last edited by xen - Apr 28, 2014 - 12:16:59
Totalscore: 130251
Posts: 1
Thanks: 0
UpVotes: 1
Registered: 14y 312d

Last Seen: 179d 5h
The User is Offline
RE: JS double-codegolf
Google/translate0Thank You!1Good Post!0Bad Post! link
#2 - 57 chars
GeSHi`ed javascript code
1
for(p=prompt(x=e=z=1);--p;[x,e]=[e,x+e])z+=','+e;alert(z)

and one other char removed in
#1 - 47 chars
GeSHi`ed javascript code
1
for(s=0,i=10;i;s+=+Array(i).join(--i));alert(s)
Global Rank: 204
Totalscore: 101886
Posts: 65
Thanks: 66
UpVotes: 43
Registered: 15y 120d
xen`s Avatar






The User is Offline
RE: JS double-codegolf
Google/translate0Thank You!0Good Post!0Bad Post! link
#2 - 42 chars


GeSHi`ed javascript code
1
for(x=e=n=0;n<10;e+=++x*n++)x*=10;alert(e)

chmod ---x--x--x,, i'm illiterate!
Last edited by xen - May 23, 2014 - 16:52:18
Global Rank: 52
Totalscore: 259167
Posts: 47
Thanks: 36
UpVotes: 26
Registered: 16y 76d
alucardo`s Avatar




Last Seen: 5y 212d
The User is Offline
RE: JS double-codegolf
Google/translate0Thank You!0Good Post!0Bad Post! link
#2 - 18 chars
GeSHi`ed javascript code
1
alert(15*73159579)


What? Don't look at me this way.
1 2 3
tunelko, quangntenemy, TheHiveMind, Z, balicocat, Ge0, samuraiblanco, arraez, jcquinterov, hophuocthinh, alfamen2, burhanudinn123, Ben_Dover, stephanduran89, braddie0, JanLitwin17, SwolloW, dangarbri have subscribed to this thread and receive emails on new posts.
1 people are watching the thread at the moment.
This thread has been viewed 16090 times.