At the table are you, your roommate, and two stacks of pancakes, of height m and n. You and she, in turn, must eat from the larger stack a non-zero multiple of the number of pancakes in the smaller...

1 answer below »
At the table are you, your roommate, and two stacks of pancakes, of height m and n. You and she, in turn, must eat from the larger stack a non-zero multiple of the number of pancakes in the smaller stack. The bottom pancake of each stack is soggy, and thus whoever first finishes a stack is the loser.
For which pairs (m,n) do you, who happen to be playing first, have a winning strategy?


I need an r code program that solves this

Answered Same DayMar 23, 2022

Answer To: At the table are you, your roommate, and two stacks of pancakes, of height m and n. You and she, in...

Anandkumar answered on Mar 23 2022
103 Votes
R programming:
PancakesLeft = readline(prompt = "How many Pancakes do you want to remove?");
Panca
kesLeft = as.integer(PancakesLeft);
Pancake_stack2 = readline(prompt = "Second pancake stack size?");
Pancake_stack2 = as.integer(Pancake_stack2);
PancakesToRemove = 0
userTurn <- TRUE
while(PancakesLeft > 0)
{
while(userTurn == TRUE & PancakesLeft > 0)
{
PancakesToRemove = readline(prompt = "How many Pancakes do you want to remove?");
PancakesToRemove = as.integer(PancakesToRemove);
if ((PancakesToRemove %% Pancake_stack2) == 0)
{
PancakesLeft = PancakesLeft - PancakesToRemove
userTurn <- FALSE
print(PancakesLeft)
}
else ((PancakesToRemove %% Pancake_stack2) != 0)
{
print("Enter a pancake remove value which is a multiple of 5")
}
}
while(userTurn == FALSE & PancakesLeft > 0)
{
AIremoves = runif(1, min=1, max=Pancake_stack2)
AIremoves...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here