« first day (1089 days earlier)      last day (4084 days later) » 

09:00
jump around?
:12250053 It is
Ah nvm
How're the questions though?
A problem I see with this challenge is that I never code in blind without console.log, normally.
09:03
@Zirak I gave up on Q2
What's Q2 ? "sum the digits of the number x" ?
After a negative number failed the test
Yeah
@dystroy oh, should a logging mechanism be added? Sent to the output thing?
@DannyBeckett You suck
Think about it a bit more
Yup! Lol
Gonna give it another go..
@Zirak I just stopped at Q2 (done) but I think a logging feature could be helpful, especially if the following questions are harder.
09:06
Okay, the 2nd question is apparently a huge deterrent
I also think that displaying a test set (maybe not the real one) immediately from the start could be helpful.
was that dumb or smartass ?
Zirak, why did you remove alert and console.log? That's just mean!
@jAndy Please don't give the answer
Because it's run in a web worker
09:07
@Zirak It'd be fine if the difficulty ramped up uniformly
Shit, you can't test again a different version...
Going from x*x to that is quite a jump
When it's OK, hitting the button go to the next question.
So the first question should be hard as well?
YES
09:08
@Zirak No, it's OK
3rd question is just copied from the original challenge tho @Zirak lazy ass
No it's not
But you might remove the counter (and tell it) from the first question so that people see how it works
it pretty much is
"See how it works"? What's there to see? You have a function description, and a run button
So replace "bogus question" with "really easy one", keep the questions as they are?
I'll add that to the first one's outro text
09:11
He wants to test different solutions to the same question after he's already answered it
Then do it again. game.levels.splice(0, n) before it starts to go to level n+1
You can also take the test cases from game.levels and the testing code from js/evalWorker.js
the 2nd level is fun
You people were severely overthinking it
3rd question is killing me
I mean you can solve this.. ugly, but elegant these kind of reducing is badass
looks like I can't see all the tests
I have a RangeError: Maximum call stack size exceeded
09:17
I like the 3rd one
but no idea what the test was
huh, I'll add that indicator as well
It might be a bug in my equality testing
got this, but dunno what's wrong:
I feel really stupid here... I'm gonna blame that it's still morning.... but can somebody tell me why this is concatenating the digits instead of summing them?
Is it legal to change the prototype of the function ?
09:20
box.sumDigits = function sumDigits (x) {
    //sum the digits of the number x

    var y = x.toString().replace(/[^\d]/g, '').split();

    for(var sum = 0, i = 0; i < y.length; i++)
    {
        sum += +(y[i]);
    }

    return sum;
};
I did
(not very functional.)
box.flatten = function flatten (x, r) {
(ala reduce)
I'm wondering if there is a pure map + reduce solution for the 3rd
without any "helper" variable
@DannyBeckett You didn't declare sum
09:20
The third one can be written concisively
@jAndy yes
@Zirak I did, in the for
oh yes you did
anyone have an experience of using jtable jquery?
is that even close ?
09:23
@DannyBeckett oh yeah, split, you need to pass an empty string
@jAndy You're overthinking it
It's always something stupid ;)
@jAndy Try .toString() on a multidimensional array.
yea I know
but I'd like to solve it recursively with map/reduce
breaks my brain
09:24
@FlorianMargaine It fails on testing [[], 0, [[1]]]
@jAndy Do you still have your answer to Q2 on your clipboard? I noticed it was very different to my implementation.. would like to see it
@SomeGuy SMART! I didn't think of that!
+x.toString().split('').reduce(function(a,b) {
    return (+a > 0 ? +a : 0) + (+b > 0 ? +b : 0);
});
@DannyBeckett
@Zirak Thank you
09:25
@Zirak whats your original approach for 3rd please ?
return x.reduce(function (ret, i) {
    return ret.concat(i.map ? flatten(i) : i)
}, [])
wah
@Zirak Nice
I had that !!! didn't work
09:26
I was writing that
:p
return x.reduce(function(p, n) {
    return Array.isArray(n) ? p.concat(n) : p.push(n);
}, []);
I was there
Ah, ECMA v5... explains why I haven't heard of reduce before
Why is there a Array.isArray function ? What's wrong with instanceof ?
@DannyBeckett You can play js games without array functions
@dystroy cross-frame issues?
09:28
^
What's a cross-frame issue ?
I used instanceof without problem
instanceof doesn't work if you try it on an Array which was created in a different document
an array will be instance of object in cross-frame environments
[] instanceof window.open().Array
= different constructor function
09:29
Oh... I see
//And to the 2nd
return x.toString().match(/\d/g).reduce(function (ret, i) {
    return ret + Number(i)
}, 0)
I don't know where to start the 4th...
there I must say I like my non-regexp solution moar
Yours was butt ugly
stfu!
09:30
@Zirak Number(i) could be changed to +i for brevity
I know, but I don't think of that when writing fast. Habits.
I wish Chrome had voice API already. I want to feed it from this chat at realtime
The unary plus is a good, time-saving habit to get into
Disagreed
How come?
09:32
It's obscure and potentially confusing. Number expresses intent with great clarity
bah humbug!
i + +j looks like i++ j or i ++j, it's just weird
parseFloat is the clearest one here
Too lenient
@Zirak I love it
09:33
Even that has it's drawbacks though... i.e. having to specify the 2nd arg
for the radix
@JanDvorak parseInt you mean
!!~~(+a+ +b)
box.flatten = function flatten (x) {
    // x is an arbitrarily nested, multidimensional array.
    // return x flattened (all items in 1 dimension)

    return x.toString().split(',').filter(function (e){
        return e;
    }).map(Number);
};
That was my solution for 3
@JanDvorak That didn't make much sense. Use the help command to learn more.
I thought I'd like it more.
@SomeGuy That is quite awesome. Just for the future though, you can do .filter(Boolean)
09:34
Haha, yeah, I just realized that
Man, you're all going to love the last question...
@DannyBeckett depends. Both exist
Huh. The 4th is pretty cool
@Zirak Is there a command I can run to skip to the last question? :p
Yes, but I'm not going to tell you
09:35
In the main console I mean
lol
I'm gonna figure out that answer instead :p
there is. It's easy to find out
It's really easy to cheat in this game, I did absolutely nothing to stop you.
You should add that as question 6.... "skip this question" :p
/*
 __________________
< This is horrible >
 ------------------
  \                 __
   \               (oo)
    \              (  )  <--- @OctavianDamiean
     \             /--\
       __         / \  \
      UooU\.'@@@@@@`.\  )
      \__/(@@@@@@@@@@) /
           (@@@@@@@@)((
           `YY~~~~YY' \\
            ||    ||   >>
*/
hahahaha
@DannyBeckett game.nextLevel
09:36
@Zirak you could have wrapped the thing in an IIFE, though
nah
@SomeGuy Even easier than that
@OctavianDamiean did you see that? :D
@Zirak why your solution to 3rd crashes my browser O_o
Why does the timer start going at double/triple speed when you win?
Surely it should stop
HAMMERTIME!
09:37
woa
the last one is uuuugh
@DannyBeckett what
The timer turns green
and speeds up
It does?
@Zirak please include more obscure regexes in the bot :-)
Yeah lol
09:37
please post again
That said... I used game.nextLevel(); * 5
Might not do it if you don't cheat :p
oh well, got it, my bad
@DannyBeckett (@SomeGuy) game.levels.splice(0, 4)
@FlorianMargaine :D
@DannyBeckett Wwweeeiiirddd
@Zirak I like game.levels.splice(0, 5) better.... straight to 'Awesome, you win!' :p
Do you see the timer issue I was saying about? Is that what's wwwwwweeeeeiiiirdddddddd?
09:41
Last one's interesting
@DannyBeckett It's because you cheated
@Zirak What is this game of which you speak?
Seriously. nextLevel fires the timer again, making it tick faster.
Adding console.log soon
09:42
Brilliant
@Zirak can you do 4th without lookup/hash :P ?
@jAndy Doubt it
Not that I know of
@Zirak What is the vertical line for in the code editor about half-way?
I thought it was 2 panes to begin with
But the code overruns it
80 columns ruler
09:43
ah
Hahaha, I hadn't noticed that
The theme is a bit too dark for my screen
blasphemy @SomeGuy!
I can't figure out how to configure my screen correctly :/
Somebody once told me a dark IDE is better on your eyes
I just use Mac Classic
09:44
Whether that's true or not, idk
But this one is pretty good too
@SomeGuy ace.c9.io/build/kitchen-sink.html tell me if there's a dark theme which suits you
So that I can go "oh, ok" and do nothing more about it
Current one is Twilight
Hahahaha
idleFingers looks alright to me
Just as a general question on coding style, when squaring a number, would you use return x*x or return Math.pow(x, 2)?
The former looks prettier
I'd use the former
09:47
@SomeGuy oh, ok
Tomorrow Night Bright is good too
I wonder why zirak.github.io doesn't redirect to github.com/Zirak - just shows a 404 - when zirak.github.io/js-questions does work
Stupid github :p
That's not how gh-pages works
zirak.github.io will show up only if Zirak has a gh-pages repo for it
I don't use Git... still on SVN
I guess it makes sense
"Photoshop and Coding"
Just from the title of that question, I already know it's going to be a great one
09:52
@DannyBeckett unless math.pow(x, 2) is optimized, you only risk that it is slower than x*x
now x*x*x*x may not be faster than math.pow(x, 4).. but that's a different matter
@Neil That's interesting... going to benchmark it
@DannyBeckett Let me know what you find
09:53
So I changed my display settings to let me see everything on dark themes, and now everything else looks horribly bright
@SomeGuy I'm parseInting the shit outta it!
@monners Maybe you're not converting it to a number before adding it?
Math.pow is 72% slower
Surprising
@monners Haha, show us some code
@DannyBeckett Probably wasn't meant to be used for squaring as its optimal case.
09:56
Hmm, I wouldn't have guesesd
@FlorianMargaine Well?
Ah, wait, 72% slower..
That's misleading.. I assumed it was faster somehow :P
woah, 34 million ops/second!? How slow is that!? ...
That's with x*x*x*x*x
pow() is still 44% slower
09:58
Your tests are biased, and a smart engine can fold your multiplication
var y = x + '',
        result;

    for( var i=0; i<y.length; i++) {
        if (typeof parseInt(y[i]) === 'number') {
            result += parseInt(y[i]);
        }
    }
    return result;
hmm, multiplying is still faster.. I would have assumed pow was optimized for large powers
!!tell monners eval typeof NaN
@monners "number"
You never initialize result to be 0
09:59
@JakeHills Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
@Zirak So test Math.pow first, then multiply :P
It's not even a question. It's a vague request of a sort in the title and an HTML in the body - that you didn't even bother to format properly. — Jan Dvorak 24 secs ago
How do I find the height of the previous id on the page?
It's finally faster with ^10

« first day (1089 days earlier)      last day (4084 days later) »