Lucy loves to play the Hop, Skip and Jump game. Given an N*M matrix and starting from cell (1,1), her challenge is to hop in an anti- clockwise direction and skip alternate cells. The goal is to find out the last cell she would hop onto. Write an algorithm to find the last cell Lucy would hop onto after moving anti-clockwise and skipping alternate cells. Input The first line of input consists of two integers- matrix row and matrix col, representing the number of rows (N) and the number of columns (M) in the matrix, respectively. The next M lines consist of N space-separated integers representing the elements in each cell of the matrix. Output Print an integer representing the last cell Lucy would hop onto after following the given instructions.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 24PE
icon
Related questions
Question
In python
Lucy loves to play the Hop, Skip and Jump
game. Given an N*M matrix and starting from
cell (1,1), her challenge is to hop in an anti-
clockwise direction and skip alternate cells. The
goal is to find out the last cell she would hop
onto.
Write an algorithm to find the last cell Lucy
would hop onto after moving anti-clockwise
and skipping alternate cells.
Input
The first line of input consists of two integers-
matrix row and matrix col, representing the
number of rows (N) and the number of
columns (M) in the matrix, respectively.
The next M lines consist of N space-separated
integers representing the elements in each cell
of the matrix.
Output
Print an integer representing the last cell Lucy
would hop onto after following the given
instructions.
Transcribed Image Text:Lucy loves to play the Hop, Skip and Jump game. Given an N*M matrix and starting from cell (1,1), her challenge is to hop in an anti- clockwise direction and skip alternate cells. The goal is to find out the last cell she would hop onto. Write an algorithm to find the last cell Lucy would hop onto after moving anti-clockwise and skipping alternate cells. Input The first line of input consists of two integers- matrix row and matrix col, representing the number of rows (N) and the number of columns (M) in the matrix, respectively. The next M lines consist of N space-separated integers representing the elements in each cell of the matrix. Output Print an integer representing the last cell Lucy would hop onto after following the given instructions.
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning