Username: 
Password: 
Restrict session to IP 

Javascript golf

Global Rank: 227
Totalscore: 94363
Posts: 1680
Thanks: 1358
UpVotes: 920
Registered: 16y 290d




Last Seen: 5d 23h
The User is Offline
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: 101922
Posts: 65
Thanks: 67
UpVotes: 44
Registered: 15y 316d
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: 101922
Posts: 65
Thanks: 67
UpVotes: 44
Registered: 15y 316d
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: 309768
Posts: 182
Thanks: 182
UpVotes: 205
Registered: 16y 273d
livinskull`s Avatar





Last Seen: 1d 20h
The User is Offline
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: 101922
Posts: 65
Thanks: 67
UpVotes: 44
Registered: 15y 316d
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: 104725
Posts: 24
Thanks: 41
UpVotes: 24
Registered: 16y 243d

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 6520 times.