Skip to content

Instantly share code, notes, and snippets.

@LauraKirby
LauraKirby / main.cpp
Last active September 1, 2017 03:25
CCSF: CS 110C-Data Structures & Algorithms C++ (Class 2)
// C++ styleguide: https://google.github.io/styleguide/cppguide.html
// in class video: https://youtu.be/p60rN9JEapg
#include <iostream>
#include "namespace.h"
int main(int argc, const char * argv[]) {
// strings are immutable
std::string hello = "Hello, World!\n";
std::cout << hello;
@LauraKirby
LauraKirby / parenthesis_matcher.rb
Last active August 31, 2017 23:20
The Ruby Way, Third Edition
# use a stack to validate parenthesis completion
class Stack
def initialize
@store = []
end
def push(x)
@store.push(x)
end
@LauraKirby
LauraKirby / Deck of Cards
Last active August 26, 2017 17:05
Deck of Cards: Design the data structures for a generic deck of cards. Explain how you would subclass the data structures.
# Suit
# instance variables
# pip: club, heart, spade diamond
# rank: two, three, four... jack, queen...
# instance methods
# to_s
# Card
# instance variables
# suit: a Card has one Suit
@LauraKirby
LauraKirby / gist:661121382e3b8b61b092
Last active August 29, 2015 14:24
Temprature Convertor, Guessing Game, ASCII Triangle, Multiplication Table, Reverse a String
# ----------- Temprature Convertor -----------
puts "type 1 to convert from Celsius to Fahrenheit /n or type 2 to convert from Fahrenheit to Celsius"
scale_chosen = gets.chomp
def temp(arg)
if arg == '1'
puts "enter Celsius temprature"
temprature = gets.chomp
f_temp = temprature.to_f * 9/5 + 32
puts "#{temprature} degrees Celsius is #{f_temp.round(2)} degrees Fahrenheit"