Ch 02 Quiz 5 - 2025

The first real quiz on Chapter 2 material.
  1. (dsq) Given two lists of Int that have the same length, make a list of the squares of the differences between corresponding elements.

    Example:

     dsq [10,20] [7,24] == [9,16]
    

    Explanation: the first element of the result is 9 because $10-7=3$ and $3^2 = 9$.

  2. (up) The up function “rounds” an integer up to a multiple of 19.

     up 1 == 19
     up 18 == 19
     up 19 == 19
     up 20 == 38
     up 190 == 190
    
  3. (badisqrt) Given a positive integer n, return the greatest integer whose square is less than or equal to n.

     badisqrt 36 == 6
     badisqrt 17 == 4
    
  4. (findpyth) Given a list of triples (Int,Int,Int), output a list containing all of the Pythagorean triples. That is, include (a,b,c) in the output if c*c=a*a+b*b.

     triples = [(5,12,13),(8,15,18),(7,24,25)]
     findpyth triples == [(5,12,13),(7,24,25)]
    
  5. (q5) Given a list of words, return all of the words that have between 4 and 7 letters, inclusive. Also include any word that contains an “x”.

     q5 ["apple","y","phoenix","green goat", "scrappy x","ape"] ==
        ["apple","phoenix","scrappy x"]