You are not logged in. Please login at www.codechef.com to post your questions!

×

Hackerrank Hack 101 Aug 2013 Contest .

Hello everybody , Yesterday night i participated in hacker rank contest and i solved one problem , VROOK My approach was something like this .

  1. Find a diff[n] ;
  2. where diff[i] = abs(p1[i]-p2[i]);
  3. Count the Odd number in diff array .
  4. if(count%2) {
  5. player 2 will win.
  6. }
  7. else {
  8. player 1 will win.
  9. }

I got Wrong answer , Please anybody who took participate in Last night Hackerrank contest please suggest me your approach . You can view my solution here

Happy Coding!!!

asked 25 Aug '13, 11:52

upendra1234's gravatar image

2★upendra1234
2.3k183069
accept rate: 1%


The solution is to consider each of the columns as a pile in a nim game . The pile size will be abs(p1[i]- p2[i])-1 , And answer will be xor of these values. If it is non zero , player 2 wins , else player 1 wins.

link

answered 26 Aug '13, 01:26

javadecoder's gravatar image

4★javadecoder
6271713
accept rate: 27%

edited 26 Aug '13, 10:01

upendra1234's gravatar image

2★upendra1234
2.3k183069

1

@javadecoder thanks a lot now i got it .. if you have any other questions links please share with us so we can practice on nim game problems.

(26 Aug '13, 10:03) upendra12342★
toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×310
×12

question asked: 25 Aug '13, 11:52

question was seen: 3,956 times

last updated: 26 Aug '13, 10:03