Input two unsorted lists of integers remarks you may

This preview shows page 3 - 5 out of 6 pages.

[3,5]. Input: Two (unsorted) lists of integers. Remarks: You may use every data-structure (e.g., set) for this task. Returns: A list of integers sorted in ascending order containing those integers that appear in exactly one of the input lists.
Image of page 3

Subscribe to view the full document.

6. Task: random_string Description: The function generates a random string of a given length. For example, calling random_string(4) could return “aaaa” or “avdg” or any other 4 lower -case characters string. Input: An integer N denoting the length of the output random string. Remarks: a. The output string must consist of ascii lower-case letters only! Returns: A random string of length N . 7. Task: word_mapper Description: The function returns a dictionary mapping from the words in the input text to their number appearances. Each word in the input text should appear only once in the output dictionary. Upper-case letters must be converted to lower-case letters. The order of words in the dictionary does not matter. For example, given the input text The cat. is the cAt ” a possible output is: {“the” : 2, “cat” : 2, “is” : 1} (Another option is: {“is” : 1 , “the” : 2, “cat” : 2} .) Input: A string of words separated by whitespace and/or punctuation marks. Remarks: a. You are not allowed to use the Counter container. b. The input string may contain multiple lines. For example, “aaa \ na” is a text with two lines, one co ntaining the word “aaa” and other containing the word “a”. The line-feed character `\n' is considered whitespace. c. The order of the words in the dictionary does not matter. For example, {“a” : 1, “b” : 2} and {“b” : 2 , “a” : 1} are considered to be the same output. d. You will earn up to 2 bonus points for solving this task using at most 2 code lines. You will earn full credit for using up to 3 code lines. e. Words may contain punctuat ions (e.g., “I ate an… apple!”), as in the example above, these should be ignored (they count as a space character). f. Words may contain numbers. e.g., given the text “12 monkeys” a possible output is {12 : 1, “monkeys” : 1}. Returns: A dictionary containing a mapping between words (as keys) and the number of times they appear in the original input string (as value). 8. Task: gimme_a_value Description: In this task you must create a generator that gets two inputs, a function and a starting point . The generator computes a sequence of values … of the function . For all The i -th call to the generator returns the value . The first call returns (the initial value). The second call returns . The Third call returns . This generator must run endlessly. (How can this happen?) Input: A function, f , and an initial value . Remarks: a. You should use the keyword yield in your generator, and not a generator expression. b. Check the slides of the Tirgul if you need a reminder.
Image of page 4
Image of page 5
  • Spring '14
  • Avraham
  • Quantification

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern