Haskell CW II.B2

Review questions:

  1. (b1) Make a list of ordered pairs which contain the square and cube of each counting number 1 through 10.

     b1 == [(1,1),(2^2,2^3),(3^2, 3^3),(4^2,4^3), etc. ]
    
  2. (b2) Given a number m, write a function b2 to make a list of all of the ordered pairs in b1 where mm is in the closed interval [x,y][x,y] . That means xmyx \le m \le y . As an example, think of m=20m=20 and the ordered pair (9,27)(9,27) from b1. Since m=20m=20 is between x=9x=9 and y=27y=27 , we would say yes, m=20m=20 is in the closed interval [x=9,y=27][x=9,y=27] . An example with a list of intervals is:

    b2 20 == [(9,27),(16,64)]
    
  3. (b3) Given a list of words, make a list of tuples numbering them in reverse order.

    b3 ["school","home","work","beach"] ==
        [(4,"school"), (3,"home"), (2, "work"), (1,"beach")]
    
  4. (b4) Using a trial and error method, find all of the integer solutions (x,y)(x,y) to the equation

    55x+34y=155x+34y=1

    that have 100y500-100\le y\le 500 . The list has 11 points and includes (123,199)(-123,199) .

  5. (b5) Given a list of words, extract the ones with at most 6 letters into a new list.

    b5 ["a","by","cap","deal","egret","furies","gallant","hieroglyphics","x"]
      == ["a","by","cap","deal","egret","furies","x"]
    
  6. (b6) Suppose a 10x10 rectangle has two radius 5 circles inside it, one centered at (7,5) and the other centered at (3,5). Estimate the probability that a random point will be inside at least one of the circles by making a grid of squares 0.1x0.1 covering the whole rectangle and counting how many points are inside at least one of the circles.

Last modified August 18, 2023: 2022-2023 End State (7352e87)