Skip to content

Instantly share code, notes, and snippets.

Khara Muniz kmandreza

Block or report user

Report or block kmandreza

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kmandreza
kmandreza / gist:6747571
Last active Mar 11, 2016
Let's Play 2
View gist:6747571
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?
View gist:6747393
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
View gist:6654798
# 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"
@kmandreza
kmandreza / flashcard.rb
Last active Dec 12, 2015
flashcard and sherif's notes
View flashcard.rb
class Flashcard #data structure
attr_accessor :term, :definition
def initialize(term,definition)
@term=term
@definition=definition
end
end
@kmandreza
kmandreza / gist:4743420
Last active Dec 12, 2015
Ruby Todos 1.0: Core Features
View gist:4743420
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
View todo.rb
class FileReadWrite
def initialize(filename)
@filename = filename
end
def read_file
File.open(@filename).readlines
end
@kmandreza
kmandreza / Flashcards
Created Feb 7, 2013
Ruby Flashcards 1: Single Deck Let's build a simple flashcard game in Ruby with a command-line interface. Here is an example of one possible implementation: $ ruby flashcards.rb Welcome to Ruby Flash Cards. To play, just enter the correct term for each definition. Ready? Go! Definition A file format in which values are delimited by commas. Guess…
View Flashcards
class Flashcard #data structure
attr_accessor :term, :definition
def initialize(term,definition)
@term=term
@definition=definition
end
end
View jsonyaml.rb
require 'csv'
require 'date'
require 'yaml'
require 'json'
FILENAME = "people.csv"
NEW_FILE = "new_people.csv"
YAML_FILE = "people.yaml"
JSON_FILE = "people.json"
View serialization.rb
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
View gist:4725226
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|
You can’t perform that action at this time.