- Prepare
- Algorithms
- Game Theory
- Stone Piles
- Discussions
Stone Piles
Stone Piles
+ 0 comments Grundy numbers for 0:0,1:0,2:0,3:1,4:0,5:2,6:3,7:4,8:0 Grundy number for n>=9 = n-4
Using Grundy Numbers following code:
def stonePiles(arr): maps = {0:0,1:0,2:0,3:1,4:0,5:2,6:3,7:4,8:0} res = 0 for ele in arr: if ele<=8: res^=maps[ele] else: res^=(ele-4) if res == 0: return 'BOB' else: return 'ALICE'
+ 0 comments Hi, I find the blog informative, though... nice work... do share such information. I’ll bookmark your website. Our website nirogayurved is an Ayurved-related website and on our website, you will get all information related to piles and the cure of ayurvedic medicine for piles Problem.
+ 0 comments Here is Stone Piles problem solution in Python java C++ and C programming - https://programs.programmingoneonone.com/2021/07/hackerrank-stone-piles-problem-solution.html
+ 0 comments With test case: 6 piles. If Alice divide to: 2,4 . So She will win. But if she divide to: 1,2,3. So she will lost.
+ 1 comment In the sample last test case:
1 8 The output says BOB win When Alice start: 8 -> 1,3, 4 Bob cannot break any and should loose Is it?
Sort 21 Discussions, By:
Please Login in order to post a comment