BEST代写-线上编程学术专家

Best代写-最专业靠谱代写IT | CS | 留学生作业 | 编程代写Java | Python |C/C++ | PHP | Matlab | Assignment Project Homework代写

编程代写|COMP202 – Foundations of Programming Assignment 2 Summer 2023

编程代写|COMP202 – Foundations of Programming Assignment 2 Summer 2023

这是一篇来自加拿大的关于编程基础的编程代写

 

Important notice

Make sure that all file names and function names are spelled exactly as described in this document. Otherwise, a 50% penalty per question will be applied. You may make as many submissions as you like prior to the deadline, but we will only grade your final submission (all prior ones are automatically deleted).

Word search

In this assignment, we will create a simpler version of the word search algorithm. Let’s say we have a list of letters:

’C’,‘W’,‘I’,‘K’,‘I’,‘P’,‘E’,‘D’,‘I’,‘A’,‘O’,‘M’,‘M’,‘O’,‘D’,‘N’,‘A’,‘R’,‘P’

And the following list of words:

‘WIKIPEDIA’, ‘RANDOM’

Then the program will find both words in the list of letters (they could be found from left to right or from right to left). Once all the words are found in the list, the program will search for free letters in the list sequentially (letters that do not belong to any of the words).

These letters will constitute the mystery word. So in this example, we can find the words ’WIKIPEDIA’ (from left to right) and ’RANDOM’ (from right to left) in the list:

’C’,‘W’,‘I’,‘K’,‘I’,‘P’,‘E’,‘D’,‘I’,‘A’,‘O’,‘M’,‘M’,‘O’,‘D’,‘N’,‘A’,‘R’,‘P’

Let’s strikethrough the words that we found:

’C’,‘W’,‘I’,‘K’,‘I’,‘P’,‘E’,‘D’,‘I’,‘A’,‘O’,‘M’,‘M’,‘O’,‘D’,‘N’,‘A’,‘R’,‘P’

There are 4 remaining letters (shown in orange) and if we assemble them from left to right it will give us the following magic word : ‘COMP’. In the following function descriptions:

  • Please read the entire assignment guidelines and this PDF before starting. You must do this assignment individually.
  • We assume that all the list of letters and words and are in capital letters.
  • Do not use functions that we didn’t mention in class.
  • You may use the built-in method: join, append and the functions len, range
  • Do not use the index() or find() or replace() or count() methods or any other method/function that we didn’t see in class. a 50% penalty will be applied to your total point value for the question,
  • You HAVE to use a loop to traverse a string or a list.
  • Make sure to follow all the programming standards and to add doscstrings with three examples for each function in the assignment (you may use only one example from this document and you should think of another two examples of your own).
  • It is forbidden to use the break and the continue keywords

Question 1: is outside list(letter list,index)[5 points]

  • Input parameters:

a list of letters letter list (a list of characters)

an index (integer)

  • Output parameter: a Boolean variable indicating if the given index corresponds to a position outside the list of letters or not.
  • Description: The function indicates whether the index is out of bounds with regards to the length of the list. It will return True if the index is out of the list or if it is negative.
  • Examples:

if letter list = [’A’,’B’,’C’,’D’] and index = 4, then the function will return True (the only valid indices are 0, 1, 2 and 3).

if letter list = [’A’,’B’,’C’,’D’], then the function will return False if index = 2 or index = 0

if letter list = [’A’,’B’,’C’,’D’] and index = -2, then the function returns True (even though in Python we can access indices of negative values, this function also considers negative indices as outside of the list)

Question 2: letter positions(letter list,character)[5 points]

  • Input parameters:

a list of letters letter list (a list of characters)

a character to search for in the list

  • Output parameter: A list of indices where the character has been found in the list
  • Description: The function will look for all the positive indices where the given character is found. If the character is not found in the list, then the function returns an empty list
  • Notes:

Do not use the index() or find() or count() methods or any other method/function that we didn’t see in class,

You HAVE to use a loop to traverse the list.

  • Examples:

if letter list= [’A’,’B’,’C’,’D’] and we are looking for character ’Z’, then the function will return an empty list []

if letter list= [’A’,’B’,’C’,’D’,’C’,’M’] and we are looking for character ’C’,then the function will return the following list: [2,4]

bestdaixie

评论已关闭。