[SOLVED] CS104 Homework 04

25.00 $

Programming resource
Digital learning resource
Category:
✓ Practical programming resource
✓ Suitable for guided study and reference
✓ Tutor guidance available when needed

Description

5/5 - (1 vote)

1.  Please implement a function that takes two lists as input and returns the sum of common elements (without repetition). For example when given [4, 16, 17, 8, 12, 14, 19] and [17, 7, 13, 11, 4, 19, 17, 6, 4, 1, 3, 6], it shall return 40 (4 + 17 + 19 = 40).
2.  ISBN stands for International Standard Book Number that is used for book identification and is unique for each book. ISBN-10 is a ten digit version of this standard. To verify an ISBN-10, you need to calculate 10 times the first digit from the left, calculate 9 times of second digit from left, 8 times of the third digit from left and go on like that until you reach the rightmost digit and then sum all these multiplications.
10 * <first_digit> + 9 * <second_digit> + 8 * <third_digit> ..
If the sum can be divided by 11 by no remainder than we say that the ISBN code is valid. For example: 0536000069 is a valid code, meanwhile 0321334877 is not. Please implement a method which can verify a given ISBN number by returning either a True or False. Assume that the ISBN number is given into the method as a string.
3.  Symmetric Matrix is a matrix where values on both side of the diagonal (marked by blue) are the same. For example A is a symmetric matrix where B is not. Please implement a method that takes a two-dimensional list (representing the matrix) and prints whether the matrix is symmetric or not and returns the elements in its diagonal as a list. For example, the method must print “True” for A and return [11, 10, 3, 44] and “False” for B and return [11, 10, 3, 47].
[
11 2 13 1 11 2 130 1
A=2 10 5 24],B=[ 4 10 5 4 ]
13 5 3 4 3 5 3 41
1 24 4 44 51 24 4 47
4. (25 pts) In chess, the knight can make only L-shaped moves. L-shaped moves mean two spaces in one direction and once space in a perpendicular direction. Implement a method when the location of knight is given, it will return a list of the possible locations the knight can move from that given location. For example, see the scenario below;

Knight is at (3,4), it can move to 8 possible locations which are marked 0,1,2..7. If we pass in 3 and 4 to the method it shall return a list containing all the possible coordinate pairs as sub-lists: [[2,6], [1,5], [1,3],…] etc. Please keep in mind that the knight can not get out of the board hence such a location can not be returned.

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.