Username: 
Password: 
Restrict session to IP 

my js

Global Rank: 204
Totalscore: 101882
Posts: 65
Thanks: 66
UpVotes: 43
Registered: 15y 98d
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: 253
Totalscore: 87266
Posts: 1639
Thanks: 1338
UpVotes: 886
Registered: 16y 72d




Last Seen: 2d 14h
The User is Offline
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: 29
Totalscore: 313508
Posts: 54
Thanks: 79
UpVotes: 58
Registered: 16y 22d










Last Seen: 11h 57m
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: 253
Totalscore: 87266
Posts: 1639
Thanks: 1338
UpVotes: 886
Registered: 16y 72d




Last Seen: 2d 14h
The User is Offline
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: 35
Totalscore: 291078
Posts: 164
Thanks: 157
UpVotes: 172
Registered: 16y 55d
livinskull`s Avatar





Last Seen: 9h 13m
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: 53
Totalscore: 258450
Posts: 25
Thanks: 33
UpVotes: 30
Registered: 16y 60d
noother`s Avatar










Last Seen: 13h 30s
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: 253
Totalscore: 87266
Posts: 1639
Thanks: 1338
UpVotes: 886
Registered: 16y 72d




Last Seen: 2d 14h
The User is Offline
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: 29
Totalscore: 313508
Posts: 54
Thanks: 79
UpVotes: 58
Registered: 16y 22d










Last Seen: 11h 57m
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: 204
Totalscore: 101882
Posts: 65
Thanks: 66
UpVotes: 43
Registered: 15y 98d
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, 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 4163 times.