2017-10-03

CodingBat problems to improve your problem-solving skills.
  1. (Previous class leftover.) Write only14 (source) that takes in a list of numbers and gives a boolean result. The result is true if every number in the list is either a 1 or a 4.

  2. Write isEverywhere(source). “We’ll say that a value is “everywhere” in an array if for every pair of adjacent elements in the array, at least one of the pair is that value. Return true if the given value is everywhere in the array.”

    We discussed how to program this one, including the tricky edge cases like stopping when there are two elements left in the list instead of one or zero.

  3. Write haveThree (source), which returns true if the number 3 appears three times in the list, and no threes are next to each other in the list.

      haveThree:: [Int] -> Bool
  1. (Homework) The cow signal. Briefly: take in a [[Int]] with every entry 0 or 1. Produce a [[Int]] with four entries in a square corresponding to every one entry in the original. If you made a picture with the rows of 0’s and 1’s, the new picture would be twice as wide and twice as high.
Last modified August 18, 2023: 2022-2023 End State (7352e87)