Username: 
Password: 
Restrict session to IP 

Javascript golf

Global Rank: 253
Totalscore: 87266
Posts: 1639
Thanks: 1338
UpVotes: 886
Registered: 16y 71d




Last Seen: 1d 12h
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: 204
Totalscore: 101883
Posts: 65
Thanks: 66
UpVotes: 43
Registered: 15y 97d
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: 204
Totalscore: 101883
Posts: 65
Thanks: 66
UpVotes: 43
Registered: 15y 97d
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: 35
Totalscore: 291082
Posts: 164
Thanks: 157
UpVotes: 172
Registered: 16y 54d
livinskull`s Avatar





Last Seen: 14s
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: 204
Totalscore: 101883
Posts: 65
Thanks: 66
UpVotes: 43
Registered: 15y 97d
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: 198
Totalscore: 105255
Posts: 24
Thanks: 41
UpVotes: 24
Registered: 16y 24d

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, 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 6239 times.