Can anyone explain the solution of Problem 1(Robot Programming Strategy).
I have done exactly mentioned in analysis. First stored all the program of other robots in vector . Then accessed i-th character of all robot and put it in a set. Then I have checked for 3 cases.
If set size is 3 (R,P,S) it mean there cannot be any solution with our program can win.
If size of set is 1 it means that iteration only have 1 value and we can choose corresponding winning value and return the solution
If size of set is 2 then choose the stronger character (like “R” in “RS”) and proceed till we get size of set 3 or 1 , or our program length reaches 500 .
Here is my solution https://ideone.com/KJ8ovE It would be so grateful if anyone can help me debugging the solution.I have tried downloading working solution of other and tried random test cases but it is working fine.