Week 7 Programming Assignment 1
Due on 2021-03-11, 23:59 IST
List Prefix
Given two lists, write a program to check if one list is a prefix of the other.
Input Format
The first line contains space separated integers
The second line contains space separated integers
The second line contains space separated integers
Output Format
Print Yes or No
Example:
Input:
1 2
1 2 3 2 1
1 2
1 2 3 2 1
Output
Yes
Yes
Input:
1 2
1 3 2 1
1 2
1 3 2 1
Output:
No
No
Explanation
In the first case, first list is a prefix of the second list. In the second case first list is not a prefix of the second
Week 7 Programming Assignment 2
Due on 2021-03-11, 23:59 IST
Snakes and Ladders-1
Given a configuration of a Snakes and Ladders board, determine the number of snakes and ladders.
Given a configuration of a Snakes and Ladders board, determine the number of snakes and ladders.
Input Format
First line of the input contains the board configuration in the form of mapping of snakes and ladders
Output Format
Print two space separated integers indicating the number of snakes and ladders respectively.
Print two space separated integers indicating the number of snakes and ladders respectively.
Example:
Input:
6: 14,11: 28,17: 74,22: 7,38: 59,49: 12,57: 76,61: 54,81: 98,88: 4
Output:
4 6
6: 14,11: 28,17: 74,22: 7,38: 59,49: 12,57: 76,61: 54,81: 98,88: 4
Output:
4 6
Explanation
In the given configuration, 6:14 indicates a ladder and 22:7 indicates a snake. there are 4 snakes and 6 ladders.
In the given configuration, 6:14 indicates a ladder and 22:7 indicates a snake. there are 4 snakes and 6 ladders.
Week 7 Programming Assignment 3
Due on 2021-03-11, 23:59 IST
Snakes and Ladders-2
Given a configuration of a Snakes and Ladders board and a series of numbers obtained when the die is rolled, determine if the sequence of the die rolls lead to a win.
Given a configuration of a Snakes and Ladders board and a series of numbers obtained when the die is rolled, determine if the sequence of the die rolls lead to a win.
Input Format
First line of the input contains the board configuration in the form of mapping of snakes and ladders
Second line of the input contains comma separated integers indicating the values obtained on rolling a die.
Output Format
Print Yes if the sequence of roll die leads to a winning combination, No otherwise.
Example:Input:
6: 14, 11: 28, 17: 74, 22: 7, 38: 59, 49: 12, 57: 76, 61: 54, 81: 98, 88: 4
6, 3, 4, 3, 2
Output:Yes
Explanation
As per the given configuration, the above set of moves indicate that the winning number 100 is reached. Hence this is a winning combination. (It is a winning combination if the set of die rolls lead to a number equal to100 or exceeds 100).