This file contains hidden or 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
def mode(array) | |
array_of_modes = [] | |
#NOTE: | |
#Hash.new(0) differs from defining an empty hash by {} in that: | |
# 1. Hash.new(0) defines an empty hash with a default value of 0 for new keys with undefined values. | |
# 2. {} defines an empty hash that will default to nil for new keys with undefined values. | |
#Here, executing the block on nil will result in NoMethodError as + is undefined for nil, so must Hash.new(0) | |
##############CREATE OUR FREQUENCIES HASH######### |
This file contains hidden or 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
#######################################PSEUDOCODE################################### | |
# INPUT: a string | |
# OUPUT & PSEUDOCODE | |
# Contains SSN => OUTPUT: Return boolean true/false | |
# Test string for chars in SSN format | |
# Return SSN => OUTPUT: Return SSN extracted from input, as string | |
# Call Contains SSN method-test if a SSN in string | |
# If contains SSN, extract and return. |
This file contains hidden or 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
#######################################PSEUDOCODE################################### | |
# INPUT: a positive integer number formatted without commas | |
# OUPUT: the input number formatted with commas as a string | |
# [refactored solution] | |
# Convert the input number to string | |
# Reverse the string | |
# put a comma after each complete group of 3 characters | |
# reverse and return the string |
This file contains hidden or 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
#######################################PSEUDOCODE################################### | |
# INPUT: a positive integer | |
# OUPUT: boolean true/false if it is a fibonacci number | |
# generate fib numbers less than or equal to input | |
# test whether input one of the generated fib numbers | |
# return boolean true if is fib number | |
# return boolean false if not a fib number |
This file contains hidden or 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
########################IDENTIFY WHAT EACH LINE OF CODE IS DOING#################### | |
def north_korean_cipher(coded_message) | |
input = coded_message.downcase.split("") #any uppercase chars to lowercase; | |
#splits the string at each char and | |
#returns an array of chars. | |
decoded_sentence = [] #creates empty array to push our deciphered message chars into | |
cipher = {"e" => "a", #deciphers the alphabetical chars into NK key => EN value | |
"f" => "b", | |
"g" => "c", |
This file contains hidden or 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
#######################################PSEUDOCODE################################### | |
# INPUT, OUTPUT & PSEUDOCODE: | |
# Initialize => INPUT: number of sides = integer > 0 | |
# OUTPUT: new Die object | |
# # set instance variable sides to value of passed argument | |
# Die#sides => INPUT: none | |
# OUTPUT: number of sides | |
# getter/accessor method for sides | |
# Die#roll => INPUT: none |
This file contains hidden or 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
#######################################PSEUDOCODE################################### | |
# INPUT, OUTPUT & PSEUDOCODE: | |
# Initialize => INPUT: array of strings (labels) | |
# OUTPUT: new Die object | |
# a. raises argument error if passed an empty array | |
# b. Creates instance variabel for labels | |
# Die#sides => INPUT: none | |
# OUTPUT: number of sides | |
# a. calculate and return size of labels array |
This file contains hidden or 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
####################################### PSEUDOCODE ##################################### | |
# INPUT: initialize a game passing the correct integer answer to instantiate; | |
# pass a guess value to #guess | |
# OUPUT: #guess outputs symbol representing | |
# if the most recent guess is too high, too low, or correct | |
# #solved? outputs true if the most recent guess is correct and flase otherwise. | |
# STEPS: #initialize -> set answer to instance variable, answer | |
#guess -> return corresponding symbol for too high, too low, correct |
This file contains hidden or 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
####################################### PSEUDOCODE ##################################### | |
# INPUT: Initialize object with input 16-digit integer parameter | |
# OUPUT: #initialize outputs invalid ArgumentError for input integers not 16 digits | |
# #CreditCard#check_card outputs boolean true/false for | |
# valid/invalid digits as credit card number | |
# STEPS: #initialize raise ArgumentError if input parameter is not 16 digits | |
# set input to instance variable for card number | |
#card_number isolate digits to double and multiply them by 2 |
This file contains hidden or 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
#!/usr/bin/env ruby | |
require 'open-uri' | |
require 'net/http' | |
require 'iconv' | |
require 'optparse' | |
require 'fileutils' | |
require 'cgi' | |
$options = {} |