Permutations And Combinations

Game of Life Notes

  • Use the Pendulum program as a base to build Game of Life upon
  • Coding Session tomorrow at 4PM, probably not in 206, probably in 203 West.
  • Use JFileChooser for the "load" button.
  • The header is the rows and columns of the life array.
  • NEW DUE DATE: Sunday at the end of spring break, monday at the latest.

Life Array

  • header is the rows & columns.
  • you read in each line as string, and where there are X's, that means that the cell is alive.
  • there should be some sample text files with the program.
    • contain glider gun, blinkers, etc
    • I guess these examples are on D2L somewhere...

Life Array Input

  • scanner, next int twice, get through the "metadata"
  • The sample inputs are in the "Assignments".zip file, named "Life1.txt" "Life2.txt"
  • the input probably needs to be in a try-catch block.
  • JFileChooser: Look at examples, it returns a file and you can send that file to another method to open it up and do stuff with it.

Printing Anagrams

  • Easy to do as recursive function, not so easy otherwise.

Subsets (Binary Counter)

  • Acts as a binary odometer.
  • lots of "bit twiddling" (probably should learn some)
  • Not recursive

Combinations from multiple sets

static String[][] someData = {
  {"A", "B"},
  {"1", "2"},
  {"X", "Y", "Z"}

Combinations (loopy)

for (i = 0; i < A[0].length; i++)
  for (j = 0; j < A[i].length; j++)
    for (k = 0; k < A[2].length; k++)
      String P = A[0][i] + A[i][j] + A[2][k];

Combinations (Recursive) (see lecture slides) compared to Combinations (Odometer) (see lecture slides)