

HackerRank aims to build a fun place for programmers to hang out - rvivek
http://hackerrank.com

======
jaredsohn
A few things:

* I'm having issues with the terminal where what I type is not always on the bottom line. Also, the up/down arrows for getting command history don't always show what I would expect and I get latency fairly frequently.

Also _spoiler_ here's an algorithm that will let you win every time where it
is possible to win. I debated a bit about posting this, but if I didn't I'm
sure somebody else would.

1\. If number is divisible by 6, do not play since you'll always lose.

2\. If the number is less than 6, do not play since it doesn't allow you to
take them all in the first move, despite what the instructions suggest.

3\. Otherwise, your first pick should be a number that takes the remaining
number to a multiple of six (see rule #1). Then, you should look at what
number the computer picks and subtract it from six when you pick your number.

Getting to the top of the leaderboard is dependent on understanding this and
how much time you're willing to spend playing.

Or you could write a bot that plays the game for you. Then getting to the top
of the leaderboard depends on who started their bot first and the quality of
bots' network connections.

~~~
gms7777
I was about to post this exact thing. Its easy enough to figure out if you
watch the computer play. Using this its possible to win every single game as
long as the number you start with isn't divisible by 6.

~~~
rvivek
:) This was just a teaser page/warmup puzzle for fun. Thanks for trying out!

------
quandrum
Was able to sign up, but the challenge totally failed on me.

First it seemed to not be taking any input, and let me enter about 10
different numbers without response. Then, it showed me the back and forth
between me and the computer for about half of those numbers, but the total
never changed after that.

~~~
rvivek
The command is challenge <number>

~~~
quandrum
Yes, I started the challenge. My problems were encountered during the game
itself. It stopped working correctly.

------
whichdan
The game worked fine for me, just double check "challenge 1" since it asks for
a range between "1 and 0"

A few observations:

\- If you start <= 6, you will always lose, since you have to choose 1 less
than the starting number.

\- Whoever gets 6 on their turn will always lose.

\- If you start between 7 and 11, you'll always win.

\- If you start at 12 or higher, you'll usually lose, since the computer will
try to get you to 6.

Still fun for a few minutes atleast. No idea how people are winning 20+ games.

~~~
jaredsohn
>No idea how people are winning 20+ games.

I won over 20 games by just spending a few minutes manually running the
algorithm described elsewhere here and I imagine anyone who hasn't won
hundreds or thousands of games probably did the same. (If you're going to
write a bot, might as well let it run for awhile and see if you can max out
the leaderboard.)

------
recursive
The CLI seems to get into an inconsistent state easily in Chrome, only fixed
by reloading the page. I'm sure I know how to win the candy challenge based on
the english description of the rules, but I can't make any sense of the
output.

    
    
        recursive@hackerrank:~$  challenge 1
        Playing a game for N: 1
        Please provide a number between 1 or 0.
        How many candies you want to pick?:
    

At this point, I get stuck in a loop that I've only been able to get out of
with f5.

------
ayla
I am a novice programmer and I am always put off websites that rank users (and
programming competitions for that matter). Avoiding the competition seems
better than putting my relatively crappy code out there for all to see.

Would more seasoned people out there agree that a clean slate is better than a
low ranking on sites like InterviewStreet (or HackerRank if it gets big)?

~~~
rvivek
Hi Ayla, we want to build something that has fun stuff catering to different
set of programmers (hackers/programming contest enthusiasts/functional
programmers, etc.) Whether it's for pride or for learning new things, we want
to leave it to the user.

------
xiaoma
Well, I was trying to avoid spoilers, but since jaredsohn has already sailed
that boat out to sea...

How do you script something like this? I tried looking at the source and then
using the chrome console to input jQuery commands, but something really weird
happened. I could replace just about any element on the screen _except the one
that mattered_!

I could type "challenge 8" into the console and then running a
$('tester').text() would return "challenge 8" as expected. But
$('tester').text('challenge 9') wouldn't update the screen. I tried for a good
hour to find a way to update the text in that element, with no luck (short of
removing the whole thing from the dom).

(see <http://postimage.org/image/c3xkrg8y3/> )

Also how do you send a carriage return? Inserting a newline didn't seem to do
the trick. Anyone? As much as I love a challenge, beating my head against this
one issue doesn't yield much education / time spent.

~~~
jaredsohn
If you look at the JavaScript, you can see that it actually expects a
keystroke for the Enter key.

I'm not familiar with sending keystrokes in JavaScript (from some brief
searching I think it is possible; I just don't know the best practice), but
for something like this, you could just do it at the operating system level. A
long time ago I automated an annoying user interface for a program we had to
use at work by writing some vbscript that changes windows and does a
combination of sendkeys and sleep.

Unfortunately, just sending keystrokes isn't very robust since it isn't
reading what is going on in the UI and if something random happens (the site
behaves other than expected, you touch a key / move the mouse, a scheduled
program runs, etc) the script could get out of sync. Fortunately, the
consequences of an error are so low here that such a solution would be good
enough.

------
dxbydt
Vivek, Cannot access at the bank. Contacted friends at other banks. Same story
:( So some 1 million plus corporate programmers don't have access to your
website. Here's the message I get on Internet Explorer.

\--------- 403 Forbidden

This Web site is blocked: <http://hackerrank.com/> As part of our ongoing
effort to protect the bank and its information, the Web site you are trying to
reach is blocked because it is classified in a category the bank considers to
have certain risks. The bank blocks access to a number of Web site
classifications including but not limited to Web mail sites, Personal Network
Storage, and other categories to comply with regulations, protect customer and
company information, and to be consistent with industry standards and
practices.

This Web site is categorized as Games. \---------

~~~
jimminy
I'd say that's probably a good thing considering the passwords were being
transmitted in the clear[1]. To me this would seem a huge liability to be
accessible by bank employees.

[1]<https://gist.github.com/3020091/>

~~~
dxbydt
imho the reason is the name. If news.ycombinator.com was called
hackernews.com, it would be blocked in 15 seconds flat. That's corporate
america for you.

~~~
uiri
Hackerne.ws points to the same IP address as news.ycombinator.com. Is the
former blocked but the latter allowed?

------
ehaughee
Am I missing something? I type signup myemail myusername and I am then
prompted for a password which seems to refuse any input or at least not alert
me of submission.

~~~
mariocesar
The signup is broken, there is a 'login undefined property' exception.

Hope this will be fix soon, cool idea

~~~
rvivek
Sorry, it's fixed. Can you try now?

------
Nick5a1
I am a very novice programmer, but this challenge seems impossible. It asks
"Please provide a number between 1 or -1". That isn't even English. Do you
mean between 1 _and_ -1? Any number entered just results in the same "Please
provide a number between 1 or -1".

Did you not test this at all before promoting it? I am brand new to
programming and even I know that testing is important.

~~~
carb
The error is when the argument to the `challenge` command is anything other
than a number. Try `challenge monkey`. It then accepts zero for N, and the
computer always picks a positive number.

Resulting in a negative.

------
dwerthen
I most certainly enjoyed that! Was nice to find the apply command after poking
around in the help.

    
    
      == apply: Apply to join our awesome team.
      Usage: apply <a profile url> <why do you want to apply>
    

Does it have anything to do with my mad skillz in solving the puzzle perhaps?
;-)

------
obliojoe
This looks cool. But I'm getting a javascript error when trying to sign up.

TypeError: Cannot call method 'toLowerCase' of undefined
[[http://www.hackerrank.com/assets/application-18e8ea124a72677...](http://www.hackerrank.com/assets/application-18e8ea124a726771ae0f901e4094ee4f.js:16)]

~~~
rvivek
very sorry about it. Can you try now?

~~~
obliojoe
Works now. Very cool, thanks!

------
iambibhas
And just found a bug. I started from 2000 and it got stuck at 378. It is
miscalculating and thus going into an infinite loop.
<http://paste.ubuntu.com/1067434/> I mean come on, mathematical miscalculation
for a game like this?

------
calinet6
The algorithm is obviously pretty easy, as has been demonstrated...

but I can't believe I just spent 20 minutes trying to come up with a scripted
solution. Nerd sniped again!

<http://xkcd.com/356/>

~~~
rvivek
Congrats! There are 5 "scripted" solution till now.

------
gms7777
So maybe I just fail, but I attempted to sign up, typed in the command and
then it asked for a password. I assumed this was to make up a password, so I
tried that, and it didn't let me enter. Is this a you have to know a password
to sign up thing?

~~~
rvivek
Sorry about it. Can you try now? It's fixed. A js error

~~~
gms7777
Works now. Thanks.

------
rsobers
I'm going crazy or should I not have won here?

Playing a game for N: 10 Your move: '4'. Computer's move: '1'. Remaining
candies: '5' Please provide a number between 1 or 5. Your move: '5'.
Computer's move: '5'. Sorry! You lost the game.

~~~
sp332
I made the same moves and it said I won.

------
theonewolf
hey passwords are being sent plaintext (<https://gist.github.com/3020091/>).
be careful if you signup/when you log in. use a password you don't care about,
or use a throwaway.

------
llaxsll
Ha! I attempted this yesterday, after I saw the article in TC. It was a really
fun challenge! Good job guys! Hope I didn't cost you a lot of money.. by my
estimates i sent you something close to like a million requests .. give or
take.

------
kiennt
You guys rock !!!

I also write new bot by python for hackerrank challenge. Check out my code at
<https://github.com/kiennt/hackerrank-bot>

Happy hacking :)

~~~
think-large
Thanks soo much for posting your code. Just starting out with python and it's
nice to be able to learn from someone else's exploits.

------
manish_gill
There's a bug. The cursor sometimes shows up above the current prompt line and
I'm not able to type. Clicking on the prompt will just bring it back for a
second and then it goes up again.

------
gdi2290
$ Playing a game for N: 8 $ Your move: '2'. Computer's move: '2'. Remaining
candies: '4' $ Congrats! You won the game. Now go ahead and play for more
candies. Enjoy :)

------
think-large
Can you give solutions after the week is up? I really want to become a better
programmer and I think this would really help me learn.

~~~
rvivek
Yes, we'll be putting it up. Stay tuned. Thanks for trying

------
RegEx
"Username can only contain characters, numbers and underscore." _RegEx_
doesn't work :(

------
daguar
I'm getting a whole mess of "You can't play that game!" errors on legitimate
moves.

~~~
idefine
I am getting various errors - there are 4 remaining candies. I take 4. now
there are 6 remaining candies...something is wrong.

------
vemuruadi
Awesome stuff man...looking fwd to more challenges.

------
chimeracoder
I must say, this 'challenge' is a creative idea.

However, not to be a wet blanket, but it's rather simple to construct a
winning algorithm, particularly if you can both choose the same starting
number and always go first (and choose the same starting number multiple
times). If I had a few extra minutes at work right now, I'd take a stab at it.

...That is, unless that's the entire point?

