A Pen by Cassandra Archibald on CodePen.
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 LRUCache | |
attr_reader :dll, :hash, :count, :capacity | |
def initialize(capacity) | |
@dll = DLL.new | |
@hash = Hash.new | |
@count = 0 | |
@capacity = capacity | |
end | |
def read(key) |
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
package com.linkedlists; | |
public class LinkedList { | |
Node head; | |
// static so main can access the inner class | |
static class Node { | |
int data; | |
Node next; |
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 'httparty' # If using Rails with a Gemfile, this require is not needed | |
require 'awesome_print' | |
# response = HTTParty.get('https://dog.ceo/api/breeds/image/random') | |
# puts response.code | |
# puts response.message | |
# puts response.body |
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 'httparty' | |
require 'awesome_print' | |
KEY = "AIzaSyBP30mYnbwKpZ0lCHtp6FuvcNSjNG0GsGM" | |
PLACE_FROM_TEXT_STRING = "https://maps.googleapis.com/maps/api/place/findplacefromtext/json?inputtype=textquery" | |
DETAIL_STRING = "https://maps.googleapis.com/maps/api/place/details/json" | |
#Starter Code: | |
seven_wonders = ["Great Pyramid of Giza", "The Ishtar Gate", "Colossus of Rhodes", "Pharos of Alexandria", "Statue of Zeus at Olympia", "Temple of Artemis", "Mausoleum at Halicarnassus"] |
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
# Array for student names | |
student_names = [] | |
# Array for student id numbers | |
student_id_numbers = [] | |
# Array for student email addresses | |
student_email_addresses = [] | |
# Getting student input/generating student information |
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
# Ask the user to enter the names, ages, and favorite colors of their | |
# closest friends (you may not assume that the user's close friends | |
# all have unique names). Output the total number of close friends | |
# under 18, followed by their names. Output the number of unique | |
# favorite colors, and then list them (Hint: Check out the uniq method | |
# of the Array class in Ruby). | |
# Your solution should use at least 1 hash and at least 1 array. | |
puts "Welcome to Hash Fun!. \nI will be asking your for the names, ages, and favorite colors of your closest friends.\n" |
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
# Adding astricks to help separate each problem | |
print "\n" + ("*" * 50) + "\n" | |
puts "Create an array to store 5 names. Have the user enter in the 5 names and then print out the 5 names in all UPPERCASE all on the same line. Note that the user may not enter all the names in uppercase." | |
##################################################### | |
# Creating an empty array to hold names | |
names = [] | |
# Running a times loop to get user input | |
5.times do | |
# Asking user for name |
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
# Requirements | |
# You will start by creating three arrays: | |
# An array that will contain student names | |
student_names = [] | |
# An array that will store student ID numbers | |
student_id_numbers = [] | |
# An array that will contain student email addresses | |
student_email_addresses = [] |
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 BankAccount | |
attr_reader :name | |
def initialize(name) | |
@name = name | |
@transactions = [] | |
add_transaction("Beginning Balance", 0) | |
end | |
def credit(description, amount) |
NewerOlder