Skip to content

Instantly share code, notes, and snippets.

View jdellinger's full-sized avatar

Jay Dellinger jdellinger

View GitHub Profile
@jbrechtel
jbrechtel / game_of_life.markdown
Last active June 19, 2017 01:35
Conway's Game of Life

Conway's Game of Life

Conway's Game of Life is a set of rules which define a cellular automata. Read more about it in Wikipedia. Your task is to write a Conway's Game of Life (GOL) simulation.

GOL consists of a two-dimensional grid of cells. Each cell is either alive or dead. Your simulation should calculate the grid over a user-specified number of generations. To calculate the next generation you apply the following rules to each cell in the grid and the resulting grid is the next generation.

Rules

  • Any live cell with fewer than two live neighbours dies, as if caused by under-population.
  • Any live cell with two or three live neighbours lives on to the next generation.
@jbrechtel
jbrechtel / deck_of_cards_2.markdown
Last active June 19, 2017 01:34
Dealing cards continued

Dealing cards to players

Using the classes built in the previous dealing cards problem, we're going to deal cards to players now.

Your program will deal cards to a user-specified number of players.

The program should ask for user input and respond to the following 3 commands

  • add_player
  • deal_cards
@jbrechtel
jbrechtel / deck_of_cards_1.markdown
Created January 31, 2013 14:57
Deck of cards problem part 1

Dealing cards

A deck comprises 52 cards of 4 suits (spades, hearts, clubs, and diamonds). Each suit has 13 cards of values from 2-10, Jack, Queen, King, and Ace.

Write a class to represent a card. The class should have a suit and value property indicating its suit and value.

Write a class that has a draw method.

  • The draw method should accept an integer as an argument.
  • The draw method should return an array of card objects.