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
// Write a function charFreq() that takes a string and builds a frequency listing of the characters contained in it. | |
// Represent the frequency listing as a Javascript object. | |
// Try it with something like charFreq("abbabcbdbabdbdbabababcbcbab"). | |
// I got a lot help from stack on this one. I had no idea how to make a object from a string. | |
// and in doing research for that I found a solution to something similar to this. But I do understand | |
// how every line of code works and why! | |
function charFreq(source) { | |
var frequency = {}; |
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
// Represent a small bilingual lexicon as a Javascript object in the following fashion {"merry":"god", "christmas":"jul", "and":"och", "happy":gott", "new":"nytt", "year":"år"} and use it to translate your Christmas cards from English into Swedish. | |
var greetings = { | |
"merry": "god", | |
"christmas": "jul", | |
"and": "och", | |
"happy": "gott", | |
"new": "nytt", | |
"year": "ar" | |
}; |
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
# Your code here |
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
require 'minitest/autorun' | |
require 'minitest/spec' | |
def switcharoo(string, switch_point, second_switch_point = nil) | |
first = string.slice(0...switch_point) | |
second = string.slice(switch_point..-1) | |
second + first | |
end | |
describe "switcharoo" do |
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 initialize | |
class BankAccount | |
attr_reader :customer_name, :type, :acct_number | |
def initialize(customer_name, type, acct_number) | |
@customer_name = customer_name | |
@type = type | |
@acct_number = acct_number | |
end | |
end |
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
# Solution for Challenge: Implement from Pseudocode. Started 2012-10-02T04:28:05+00:00 | |
#Iteration One | |
def pig_latin | |
vowels = [ 'a', 'e', 'i', 'o', 'u' ] | |
puts "Please enter word to be translated:" | |
word = gets.chomp | |
split_word = word.chars.to_a | |
if vowels.include?(split_word[0]) | |
psuedo_vowel = word |
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 primes(num) | |
primes = [ ] | |
(2..num).each do |divider| | |
until num % divider != 0 | |
if num % divider == 0 | |
primes << divider | |
num = num/divider | |
end | |
end | |
end |