SarthakKeshari / CPP-Questions-and-Solutions

This repository aims to solve and create new problems from different spheres of coding. A path to help students to get access to solutions and discuss their doubts.
MIT License
47 stars 132 forks source link

added solution to alice vs bob faceoff problem #360

Closed satkar2001 closed 2 years ago

satkar2001 commented 2 years ago

Issue Id you have worked upon -

357

Briefly explain your program logic -

since we need to predict winner if the game is played optimally,and alice makes the first move we need to find if there is a winning state(n) in the game so, whichever player lands at an odd state has no chance of winning the game, the second case can be if n is divisible even but maximum by 2, here too there is no chance so the only option is if n is divisible by even number maximum 4 . so the solution is to implement this using recursion

Screenshots(Attach 2 screenshots of your own input and output) -

Attach here alicebob1 alicebob2


Checklist:

Eg - If your code follow the below guidelines. Kindly change [] to [x]

All the conditions should be fulfilled for considering your code for merging -

satkar2001 commented 2 years ago

since i didnt know where to upload the images i provided a online link . please accept the PR if its ok

SarthakKeshari commented 2 years ago

@satkar2001, You may directly upload the images in the PR template itself. Kindly have a look at the attached screenshot.

image

satkar2001 commented 2 years ago

@SarthakKeshari done