Username: 
Password: 
Restrict session to IP 

Javascript golf

Global Rank: 252
Totalscore: 87267
Posts: 1635
Thanks: 1337
UpVotes: 886
Registered: 16y 43d




Last Seen: 14h 15m
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: 201
Totalscore: 101922
Posts: 65
Thanks: 66
UpVotes: 43
Registered: 15y 69d
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: 201
Totalscore: 101922
Posts: 65
Thanks: 66
UpVotes: 43
Registered: 15y 69d
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: 34
Totalscore: 289886
Posts: 164
Thanks: 157
UpVotes: 171
Registered: 16y 26d
livinskull`s Avatar





Last Seen: 11s
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: 201
Totalscore: 101922
Posts: 65
Thanks: 66
UpVotes: 43
Registered: 15y 69d
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: 195
Totalscore: 105263
Posts: 24
Thanks: 41
UpVotes: 24
Registered: 15y 361d

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