Username: 
Password: 
Restrict session to IP 

Javascript golf

Global Rank: 229
Totalscore: 92743
Posts: 1680
Thanks: 1358
UpVotes: 920
Registered: 16y 280d




Last Seen: 1s
The User is Online
Javascript golf
Google/translate0Thank You!0Good Post!0Bad Post! link
A few years ago someone brought up javascript minigolf.

Here is another task:

GeSHi`ed javascript code
1
2
3
4
5
 
var input = 'some.tree.structure.to.parse';
 
var wantedOutput = ['some', 'some.tree', 'some.tree.structure', 'some.tree.structure.to', 'some.tree.structure.to.parse'];
 


Happy putting!
The geeks shall inherit the properties and methods of object earth.
Global Rank: 202
Totalscore: 101919
Posts: 65
Thanks: 67
UpVotes: 44
Registered: 15y 307d
xen`s Avatar






The User is Offline
RE: Javascript golf
Google/translate1Thank You!1Good Post!0Bad Post! link
i did indeed Smile
to get the ball rolling my first attempt: 94
GeSHi`ed javascript code for parse
1
function go(s){var l=n=s.split(".");l=n.length;for(i=1;i<l;i++){n[i]=n[i-1]+'.'+n[i]}return n}
chmod ---x--x--x,, i'm illiterate!
Global Rank: 202
Totalscore: 101919
Posts: 65
Thanks: 67
UpVotes: 44
Registered: 15y 307d
xen`s Avatar






The User is Offline
RE: Javascript golf
Google/translate1Thank You!1Good Post!0Bad Post! link
first one made tidy: 84

GeSHi`ed javascript code
1
function go(s,n=s.split(".")){for(i=1;i<n.length;i++){n[i]=n[i-1]+'.'+n[i]}return n}
chmod ---x--x--x,, i'm illiterate!
Global Rank: 33
Totalscore: 308602
Posts: 182
Thanks: 182
UpVotes: 204
Registered: 16y 263d
livinskull`s Avatar





Last Seen: 2s
The User is Online
RE: Javascript golf
Google/translate1Thank You!1Good Post!0Bad Post! link
xen's code 2 chars shorter: 82

GeSHi`ed javascript code
1
function go(s,n=s.split(d=".")){for(i=1;n.length-i;)n[i]=n[i-1]+d+n[i++];return n}


I'm trying to come up with sth on my own, but with that functional approach it keeps getting too long Drool
Speaking of functional, maybe sth recursive could be nice..
Global Rank: 202
Totalscore: 101919
Posts: 65
Thanks: 67
UpVotes: 44
Registered: 15y 307d
xen`s Avatar






The User is Offline
RE: Javascript golf
Google/translate0Thank You!0Good Post!0Bad Post! link
glad you didn't take cheap trick, function name 'g'<'go' one less.
chmod ---x--x--x,, i'm illiterate!
Global Rank: 199
Totalscore: 104743
Posts: 24
Thanks: 41
UpVotes: 24
Registered: 16y 234d

The User is Offline
RE: Javascript golf
Google/translate1Thank You!1Good Post!0Bad Post! link
75 chars here:

GeSHi`ed javascript code
1
function g(s){i=s.lastIndexOf('.');return~i?g(s.substr(0,i)).concat(s):[s]}
tunelko, awe, quangntenemy, TheHiveMind, Z, balicocat, Ge0, samuraiblanco, arraez, jcquinterov, hophuocthinh, alfamen2, burhanudinn123, Ben_Dover, stephanduran89, braddie0, SwolloW, dangarbri, csuquvq 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 6510 times.