This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Exercise 1 Deaf Grandma | |
We're going to model something a little silly: an interaction between you and your imaginary deaf grandma. She exhibits the following inexplicable behavior: | |
1.She can only hear you if you shout at her. | |
2.If you say something but don't shout, she'll shout right back: "HUH?! SPEAK UP, SONNY!" | |
3.If you do shout you're also out of luck, because she'll misunderstand you and shout back "NO, NOT SINCE 1983!" | |
4.She won't let you leave the room unless you say, politely, "I love ya, Grandma, but I've got to go." She may be deaf, but she can smell rude a mile away. | |
How should these behaviors map to code? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PART 1 | |
By the end of the next two challenges you'll have a fully-functioning Sudoku solver that you can run from the command line. | |
Sudoku is a logic-based, combinatorial number-placement puzzle. The objective is to fill a 9×9 grid with digits so that each column, each row, and each of the nine 3×3 sub-grids that compose the grid (also called "boxes") contains all of the digits from 1 to 9. | |
The person who created the puzzle provides a partial solution so that some squares already have numbers. Typically, there are enough initial numbers to guarantee a unique solution. | |
Unsolved Solved Sudoku |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Exercise 1 | |
Define three local variables: home_address, home_city, and home_state. Define and assign them the values of your own personal home address, city, and state, respectively. | |
# Exercise 2 | |
Explain the difference between the following lines of code in plain English. "Plain English" means use language Edward, your non-programming second cousin from Ames, IA, would understand. | |
If any of the lines are invalid, explain why. | |
first_name = "Khara" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Flashcard #data structure | |
attr_accessor :term, :definition | |
def initialize(term,definition) | |
@term=term | |
@definition=definition | |
end | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require_relative 'view' | |
require_relative 'FileReadWrite' | |
class Parser | |
TODO_FILE = 'Todolist.txt' | |
def initialize(user_input) | |
@filerw = FileReadWrite.new(TODO_FILE) | |
@list = get_list | |
@viewer = Viewer.new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FileReadWrite | |
def initialize(filename) | |
@filename = filename | |
end | |
def read_file | |
File.open(@filename).readlines | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Flashcard #data structure | |
attr_accessor :term, :definition | |
def initialize(term,definition) | |
@term=term | |
@definition=definition | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'csv' | |
require 'date' | |
require 'yaml' | |
require 'json' | |
FILENAME = "people.csv" | |
NEW_FILE = "new_people.csv" | |
YAML_FILE = "people.yaml" | |
JSON_FILE = "people.json" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'csv' | |
require 'date' | |
FILENAME = "people.csv" | |
NEW_FILE = "new_people.csv" | |
class Person | |
attr_reader :id, :first_name, :last_name, :email, :phone, :created_at | |
# id,first_name,last_name,email,phone,created_at |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class InputError < StandardError | |
end | |
class RPNCalculator | |
DIGITS = /\A-?\d+\Z/ | |
ACCEPTABLE_INPUT = /\d+|[+*-\/]/ | |
def evaluate(list) | |
list_array = list.split | |
stack = [] | |
list_array.each do |element| |
NewerOlder