Username: 
Password: 
Restrict session to IP 

JS double-codegolf

1 2 3
Global Rank: 1
Totalscore: 759079
Posts: 437
Thanks: 496
UpVotes: 469
Registered: 15y 121d












The User is Offline
RE: JS double-codegolf
Google/translate0Thank You!0Good Post!0Bad Post! link
Fine... (as I seem to be wasting my time anyway)

GeSHi`ed javascript code
1
2
3
4
56
7
8
9
1011
12
13
14
1516
17
18
19
2021
22
23
24
2526
27
28
29
3031
32
33
34
3536
37
38
39
4041
42
43
44
4546
47
48
49
50
 
function inc(n)
{
  return n + 1;
} 
function add(a, b)
{
  var carry = 0;
  var r = []; 
  for (var i = 0; i < Math.max(a.length, b.length); i++)
  {
    var tmp = carry;
    if (i < a.length)    {
      tmp += a[i];
    }
    if (i < b.length)
    {      tmp += b[i];
    }
    carry = Math.floor(tmp / 10);
    r.push(tmp % 10);
  } 
  if (carry !== 0)
  {
    r.push(carry);
  } 
  return r;
}
 
function f(n){
  var l = [];
  var r = [0];
 
  for (var i=1; i<=n; i++)  {
    l = l.map(inc);
    l.push(i);
    var s = l.join("").split("").map(Number).reverse();
    r = add(r, s);  }
 
  return r.reverse().join("");
}
 


Hopefully someone who does use JS can show why this is awful. Until then I'll take it as a confirmation that JS is awful. Smile
1 2 3
tunelko, 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 16847 times.