News for hackers. Stuff that matters.
Re:Show HN: Speedsums by kornish on Monday June 29, 2015 @03:23AM (#9796809)

    (function() {
      var input = $('#answer'),
          question = $('#question'),
          solved = 0;

      var intvl = setInterval(function() {
        var questionText = question.text();
        questionText = questionText.replace('÷', '/').replace('x', '*').replace('=', '');
        input.val(eval(questionText));
        input.keyup();
        solved++

        if (solved == 119) clearTimeout(intvl);
      }, 50);
    })();

edit: seems to give an error if you solve >= 120 questions, so adjusted to stop at 119.
Re:Show HN: Speedsums by flaie on Monday June 29, 2015 @03:36AM (#9796840)
I could get to 118, but it doesn't want a 119th answer, or the UI gets completely broken.

http://imgur.com/HG0J9fN

Re:Show HN: Speedsums by kornish on Monday June 29, 2015 @03:38AM (#9796844)
Strange. The 119th answer is fine for me, but the 120th breaks it. I revised the script to not rely on interval multiplication, which can be flighty due to inconsistent latencies, but to rather keep a counter and cancel the interval after 119 solves.
Re:Show HN: Speedsums by flaie on Monday June 29, 2015 @03:52AM (#9796870)
This is the script I used, but yours blocks also on 119 for me.

    var answer = function() {
      var q = $("#question").text().replace(/x|÷|=/g, function(m) { return {'x':'*','÷':'/','=':''}[m]});
      $("#answer").val(eval(q)).keyup();
    };
    $('#question').bind("DOMSubtreeModified", function(){
      setTimeout(answer, 200);
    });
    answer();
Don't have much time to search why :-)
Re:Show HN: Speedsums by function_seven on Monday June 29, 2015 @02:56AM (#9796730)
Nice. More fun than I thought it'd be. One suggestion: mark the input field as a telephone input (?) so mobile users can get a nice fat numeric keypad.

(?) I know there are various ways to do this, they just escape me at the moment.

Re:Show HN: Speedsums by refrigerator on Monday June 29, 2015 @05:28AM (#9797126)
Great idea - I'll hopefully find time to make it mobile friendly in the next few days so will definitely implement this.
Re:Show HN: Speedsums by scraymer on Monday June 29, 2015 @11:01AM (#9798487)
<input id="answer" type="tel" autocomplete="off">
Re:Show HN: Speedsums by zaroth on Monday June 29, 2015 @01:16AM (#9796536)
Nice simple UI. I like not having to hit enter!

If you want to make it more "fair" consider bining the questions by difficulty and randomly select some number from each bin, versus a random selection / generation over the entire pool of possible questions, or actually timing each response individually and showing an average of the percentiles for each answer, instead of a percentile for the average time.

Total sums done: 3,816,583 -- really?

Re:Show HN: Speedsums by refrigerator on Monday June 29, 2015 @05:27AM (#9797121)
I thought about taking steps to make sure that tests are more fair and balanced, but decided against it because I think the small element of luck is part of what makes you want to play again :)
Re:Show HN: Speedsums by zaroth on Tuesday June 30, 2015 @05:09AM (#9803868)
I think you might be right about that! On second thought, yes, a very interesting element of the game design.
Re:Show HN: Speedsums by chillingeffect on Monday June 29, 2015 @10:20AM (#9798210)
Nice. I just ran through it along with http://www.keybr.com/#!game to spike my mental acuity. Anyone have other suggestions while I'm at it?
Re:Show HN: Speedsums by confiscate on Monday June 29, 2015 @02:55AM (#9796725)
Nice UI! I like the minions background at the end when the scoring page shows up.

For the timer, can it be a non-decimal number? Seems like I don't really care about decimal time (don't think most users care about fractions of a second)

Re:Show HN: Speedsums by AnkhMorporkian on Monday June 29, 2015 @12:49AM (#9796464)
I genuinely enjoy this. I haven't had to 'race' against simple math like that since I did my times tables in late elementary/middle school, so this was a lot of fun. Still got it apparently!
Re:Show HN: Speedsums by ams6110 on Monday June 29, 2015 @12:57AM (#9796491)
I hated it then, and don't like it any better now.

But that aside, this is nicely done.

Re:Show HN: Speedsums by jetbeau on Monday June 29, 2015 @12:24AM (#9796402)
Super handy, Ive applied for air traffic controlling in Australia and these mathematical albeit harder questions are part of the testing.

Can you make a large bank of harder questions?

Similar to the level of the calculation test on http://www.shldirect.com/en/practice-tests

Re:Show HN: Speedsums by goldenkey on Monday June 29, 2015 @12:58PM (#9799296)
Re:Show HN: Speedsums by nicklo on Monday June 29, 2015 @02:04AM (#9796639)
I think I won the game

http://imgur.com/qSerUAV

Re:Show HN: Speedsums by tylerpachal on Monday June 29, 2015 @03:23AM (#9796806)
The minions gif at the end made me laugh out loud in my office haha awesome
Re:Show HN: Speedsums by yitchelle on Monday June 29, 2015 @03:07AM (#9796765)
I came across a bug when it asked me for 11 x 12. I entered the answer but nothing happened. Pressing return, another digit or some other key failed. I just let the time run down.

I was on Firefox 38.0.5.

Re:Show HN: Speedsums by refrigerator on Monday June 29, 2015 @05:27AM (#9797124)
Thanks for letting me know - will look into it!
Re:Show HN: Speedsums by janjongboom on Monday June 29, 2015 @09:21AM (#9797857)
When you're typing and want to correct with BACKSPACE, but at the same time the timer runs out you'll be returned to previous page and can't see your score...
Re:Show HN: Speedsums by refrigerator on Monday June 29, 2015 @09:23AM (#9797870)
That's happened to me a couple of times and it's super annoying - will try and fix this.
Re:Show HN: Speedsums by rusbus on Monday June 29, 2015 @03:09AM (#9796772)
Experience on mobile isn't too great... Very laggy and the box doesn't default to numerical input.
Re:Show HN: Speedsums by refrigerator on Monday June 29, 2015 @05:24AM (#9797108)
Yeah apologies for this - I've been meaning to find time to make it mobile friendly
Re:Show HN: Speedsums by MaysonL on Monday June 29, 2015 @09:30AM (#9797906)
Try using / instead of ÷, as ÷ and + are easily mistaken by those with bad eyesight/astigmatism.
Re:Show HN: Speedsums by refrigerator on Monday June 29, 2015 @09:33AM (#9797926)
I did use / initially but a lot of people said that they don't instantly register / as meaning 'divided by'
Re:Show HN: Speedsums by 2manyredirects on Monday June 29, 2015 @11:41AM (#9798766)
Perhaps some wisely chosen (i.e. clear) SVGs - either inline or as part of an icon font - could be used instead?
Re:Show HN: Speedsums by willyyr on Monday June 29, 2015 @09:14AM (#9797823)
Reminds me of Dr. Kawashima on the Nintendo DS a few years back. Nice.
Re:Show HN: Speedsums by met0do on Monday June 29, 2015 @09:22PM (#9802258)
Great stuff