Getting Started

In this lab, you will write green predicate: is a magic square? that reports whether or not a set of numbers forms a magic square. In a magic square, the sum of the numbers in each row, column, and diagonal must be equal.

The data in this list: square_12,13,14,10,18,11,17,15,16 corresponds to this 3-by-3 grid of numbers:
square_12,13,14,10,18,11,17,15,16

  1. Don't try to code the block yet, just decide using the fact that the sum of the numbers in each row, column, and diagonal must be equal.
    For each of these, decide whether is a magic square? should report true or false.
    1. is 12,13,14,10,18,11,17,15,16 a magic square?
    2. is 80,10,60,30,50,70,40,90,20 a magic square?
    3. is 17,16,21,22,18,14,15,20,19 a magic square?
    4. is 10,10,10,10,10,10,10,10,10 a magic square?

Now that you've had some experience deciding what makes something a magic square, it's time to write an algorithm.

  1. Using as much detail as possible, you and your partner should each write down—in words, not in code—an algorithm that you can use to decide whether or not a list of 9 numbers forms a magic square.
  2. Exchange your algorithm with your partner. Follow your partner's algorithm on this list: square_3,2,1,1,3,2,2,1,3
  3. Talk with Your PartnerDiscuss any improvements or clarifications needed to make your algorithms as clear as possible.

One of the things that will be useful when you write is _ a magic square? is a reporter that picks off elements from a given list, like the first, fourth, and seventh element.

  1. Write an expression that reports (as a list) the fourth element of a given list.
  2. Write an expression that reports a list of the fourth and first elements of a given list.
  3. Write an expression that reports a list of the fourth, first, and seventh elements of a given list.
  4. Enough. Make a red block, red reporter: lookup items () from (). Here's how it starts:
    lookup items (item numbers) from (this list)

    And here it is in action:

    lookup items (1,4,7) from (nouns) = (a,b,c,d,e,f,g,h,i)
    If you need some inspiration, look again at this problem.