Username: 
Password: 
Restrict session to IP 

my js

Global Rank: 202
Totalscore: 101920
Posts: 65
Thanks: 67
UpVotes: 44
Registered: 15y 298d
xen`s Avatar






The User is Offline
my js
Google/translate3Thank You!1Good Post!2Bad Post! link
can this be made smaller?
GeSHi`ed javascript code for js
1
2
javascript:x=20;for(i=0;i<=5;i++){x*=2;x+=i}alert(x)
 


also try running without the = before the 5.
chmod ---x--x--x,, i'm illiterate!
Global Rank: 243
Totalscore: 89476
Posts: 1675
Thanks: 1356
UpVotes: 913
Registered: 16y 272d




Last Seen: 4s
The User is Online
RE: my js
Google/translate2Thank You!0Good Post!2Bad Post! link
The script is not valid javascript and will throw warnings, because you need to declare your vars with "var" like that:

GeSHi`ed javascript code for askimet
1
2
3
4
5
 
var x = 20;
for (var i = 0; i < 6; i++;x+=i) x*=2;
alert(x);
 
The geeks shall inherit the properties and methods of object earth.
Global Rank: 32
Totalscore: 313447
Posts: 54
Thanks: 79
UpVotes: 58
Registered: 16y 222d










Last Seen: 1d 3h
The User is Offline
RE: my js
Google/translate2Thank You!0Good Post!2Bad Post! link
if by smaller you mean shorter then yes it can..i did the same with 46 chars instead of 52 in yours and with keeping the same logic..
Global Rank: 243
Totalscore: 89476
Posts: 1675
Thanks: 1356
UpVotes: 913
Registered: 16y 272d




Last Seen: 4s
The User is Online
RE: my js
Google/translate2Thank You!0Good Post!2Bad Post! link
I can see how to safe 3 chars {}=
... but 6... nice codegolf..
Here is how to save 3 chars:
GeSHi`ed javascript code for akismet
1
javascript:for(i=0,x=20;i<6;i++,x+=i)x*=2;alert(x)

cripple_ripper: Please pm me your solution Smile

EDIT: I can see 3 instead of 2 chars... but 6... hmm

EDIT2: seeing 5 now? ,i
GeSHi`ed javascript code for akismet
1
javascript:for(i=0,x=20;i<6;x+=i++)x*=2;alert(x)


EDIT3: livinskull won the golf against me, because my code above generated wrong output ;)

EDIT4: and noother won!
The geeks shall inherit the properties and methods of object earth.
Last edited by gizmore - Apr 23, 2011 - 00:06:25
Global Rank: 33
Totalscore: 307842
Posts: 181
Thanks: 181
UpVotes: 203
Registered: 16y 255d
livinskull`s Avatar





Last Seen: 2d 13h
The User is Offline
RE: my js
Google/translate2Thank You!0Good Post!2Bad Post! link
one less:
GeSHi`ed javascript code
1
javascript:for(i=0,x=20;i<6;x+=i++)x*=2;alert(x)

EDIT: woah to slow
Last edited by livinskull - Apr 22, 2011 - 23:49:08
Global Rank: 27
Totalscore: 334729
Posts: 28
Thanks: 36
UpVotes: 33
Registered: 16y 260d
noother`s Avatar










Last Seen: 1d 3h
The User is Offline
RE: my js
Google/translate3Thank You!1Good Post!2Bad Post! link
Apart from the obvious javascript:alert(1337)

GeSHi`ed javascript code
1
javascript:for(i=0,x=20;i<6;x+=x+i++);alert(x)


2 less
Last edited by noother - Apr 22, 2011 - 23:53:25
Global Rank: 243
Totalscore: 89476
Posts: 1675
Thanks: 1356
UpVotes: 913
Registered: 16y 272d




Last Seen: 4s
The User is Online
RE: my js
Google/translate3Thank You!0Good Post!2Bad Post! link
First i thought, what a crap post... but now cudos to this funny function....
This number sequence seems unknown to this website:

http://oeis.org/search?q=20%2C40%2C81%2C164%2C331%2C666%2C1337&sort=&language=english&go=Search

Edit: And grats to noother for beating the golf to us!
The geeks shall inherit the properties and methods of object earth.
Last edited by gizmore - Apr 23, 2011 - 00:17:14
Global Rank: 32
Totalscore: 313447
Posts: 54
Thanks: 79
UpVotes: 58
Registered: 16y 222d










Last Seen: 1d 3h
The User is Offline
RE: my js
Google/translate2Thank You!0Good Post!2Bad Post! link
Quote from noother
Apr 22, 2011 - 23:52:32

Apart from the obvious javascript:alert(1337)

GeSHi`ed javascript code
1
javascript:for(i=0,x=20;i<6;x+=x+i++);alert(x)


2 less


that was my 46-length solution too Smile too bad that i was away to win Drool
Global Rank: 202
Totalscore: 101920
Posts: 65
Thanks: 67
UpVotes: 44
Registered: 15y 298d
xen`s Avatar






The User is Offline
RE: my js
Google/translate2Thank You!1Good Post!2Bad Post! link
i thought of the loop a few months ago while bored driving between jobs,
started with 1337 and worked backwards to see what would fit,
you can alter x and start from i=-1 but that doesnt make much of a difference to its length,,, also 'x' will start to go higher the lower 'i' starts from, e.g. i=-8

thank you to everyone giving me fresh ideas, will have another play next week.

but for now i need to get ready for my stag do Smile wish me luck.
chmod ---x--x--x,, i'm illiterate!
tunelko, noother, quangntenemy, TheHiveMind, Z, balicocat, Ge0, samuraiblanco, arraez, jcquinterov, hophuocthinh, alfamen2, burhanudinn123, Ben_Dover, stephanduran89, braddie0, 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 4429 times.