News for hackers. Stuff that matters.
Re:Show HN: Astro-Bot – A programming question with every ne... by svet_0 on Tuesday October 30, 2018 @04:56AM (#18334851)
Pretty cool! However, some riddles are incorrect, for example this one has two errors:

  def foo( vals ):
    output = vals[0]
    for x in vals[1:]:
      if output < x:
        output = x
    return x
1. It should return output

2. The answer should be "The maximum value", not "The minimum value"

Also, it could be nice if after you solve a riddle you would get a new one.

Re:Show HN: Astro-Bot – A programming question with every ne... by hadeon on Tuesday October 30, 2018 @05:40AM (#18335040)
Thanks for pointing this out! It's fixed now
Re:Show HN: Astro-Bot – A programming question with every ne... by teddyh on Tuesday October 30, 2018 @05:52AM (#18335092)
Wouldn’t a better idea be to show a question on Stack Overflow which is somewhat upvoted but still without an accepted answer?
Re:Show HN: Astro-Bot – A programming question with every ne... by passwd on Tuesday October 30, 2018 @09:05AM (#18336066)
If the question is remaining unanswered for a while, it's probably beyond open-new-tab kind of timespan to answer it.
Re:Show HN: Astro-Bot – A programming question with every ne... by v01d4lph4 on Tuesday October 30, 2018 @06:07AM (#18335146)
Sounds good, doesn't work.
Re:Show HN: Astro-Bot – A programming question with every ne... by gitgud on Tuesday October 30, 2018 @09:04AM (#18336055)
Doesn't work as in technically? or the concept? or legally?
Re:Show HN: Astro-Bot – A programming question with every ne... by ngcazz on Wednesday October 31, 2018 @07:01AM (#18344676)

    $ git checkout -b feature
The answer to this is wrong -- got green on "merge two branches" rather than "create and then checkout a new branch called 'feature'".
Re:Show HN: Astro-Bot – A programming question with every ne... by hadeon on Wednesday October 31, 2018 @06:22PM (#18349719)
Ha whoops, thank you for noticing this -- I've updated the answer.
Re:Show HN: Astro-Bot – A programming question with every ne... by wink on Wednesday October 31, 2018 @01:12PM (#18347491)
Why would I want to be distracted while doing a task that serves a certain purpose? I must be the only one not just opening new tabs out of boredom :P
Re:Show HN: Astro-Bot – A programming question with every ne... by hadeon on Wednesday October 31, 2018 @06:19PM (#18349709)
That's actually why I made it so nothing happens after you answer a question. Ideally you open a tab and every now and then you take a minute or so to think one over and answer.
Re:Show HN: Astro-Bot – A programming question with every ne... by seg12 on Tuesday October 30, 2018 @05:29PM (#18341438)
The following is incorrect for finding a missing number in a sequence.

  func foo( _ nums: [Int] ) -> Int {
    var sum = 0
    var _ = nums.map {sum += $0}

    return (nums.count * ((nums.count+1) / 2)) - sum
  }

The last line should be

  return ((nums.count+1) * ((nums.count+2) / 2)) - sum
The count of nums will give the incorrect answer since it's already missing a value.
Re:Show HN: Astro-Bot – A programming question with every ne... by hadeon on Tuesday October 30, 2018 @09:31PM (#18342688)
You're absolutely right, thanks for noticing this. There was also a bug with the parentheses I hadn't caught.
Re:Show HN: Astro-Bot – A programming question with every ne... by anandkulkarni on Tuesday October 30, 2018 @09:38AM (#18336294)
I enjoyed it, but you should allow me to disable random HackerNews links. That's not the purpose of the extension.
Re:Show HN: Astro-Bot – A programming question with every ne... by hadeon on Tuesday October 30, 2018 @03:23PM (#18340417)
Great suggestion - I'll add an option to disable that.
Re:Show HN: Astro-Bot – A programming question with every ne... by nightraven97 on Tuesday October 30, 2018 @09:21AM (#18336182)
Nice! It would be cool if there was some kind of points to denote how many questions we have answered correctly.
Re:Show HN: Astro-Bot – A programming question with every ne... by hadeon on Tuesday October 30, 2018 @03:22PM (#18340414)
Scores will be coming in the next few days. I'm also planning on adding an (opt-in) leaderboard so you can see how you compare to other people.

Is a leaderboard something that would appeal to you?

Re:Show HN: Astro-Bot – A programming question with every ne... by cift on Tuesday October 30, 2018 @10:00AM (#18336506)
Is there a Firefox version?
Re:Show HN: Astro-Bot – A programming question with every ne... by hadeon on Tuesday October 30, 2018 @03:13PM (#18340333)
It will be coming this week or next - I'll reply here when I've released it.
Re:Show HN: Astro-Bot – A programming question with every ne... by grimoire_ghost on Tuesday October 30, 2018 @05:57AM (#18335107)
#include<stdio.h>

int main() { int array[] = { 1, 2, 3, 4, 5}; int *ptr; ptr = a; ptr++;

    return 0; 
}

This won't compile, but the answer says it should be 2

Re:Show HN: Astro-Bot – A programming question with every ne... by hadeon on Tuesday October 30, 2018 @03:21PM (#18340401)
Thank you, it's fixed now.