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
numbers = Array(1..100) | |
numbers.each do |num| | |
if num % 15 == 0 | |
puts "FizzBuzz" | |
elsif num % 5 == 0 | |
puts "Buzz" | |
elsif num % 3 == 0 | |
puts "Fizz" | |
else | |
puts num |
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 'levenshtein' | |
def sorted_lev(word, werd_collection) | |
lev_result = fancy_lev(word, werd_collection) | |
lev_result.sort! do |a,b| | |
a[1] <=> b[1] | |
end | |
end | |
def fancy_lev(word, werd_collection) |
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
#!/usr/bin/env ruby | |
require "yaml" | |
require 'term/ansicolor' | |
class String | |
include Term::ANSIColor | |
end | |
class List | |
def initialize |
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 "./todo_item.rb" | |
class List | |
attr_reader :filename | |
attr_accessor :list | |
def initialize(filename) | |
@filename = filename | |
@list = [] | |
end | |
end |
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 Animal | |
attr_accessor :awake_at | |
def initialize | |
@awake_at = "day" | |
end | |
def winged? | |
false | |
end |
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
def linear_search(obj, array) #3, [4,5,1,2,3] => 4 | |
index = 0 | |
for elem in array | |
if elem == obj | |
break | |
else | |
index += 1 | |
end | |
end | |
index |
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
#linear search | |
def linear_search(object, array) | |
index = 0 | |
mismatch = 0 | |
while index < array.length | |
if object != array[index] | |
mismatch += 1 | |
end |
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
# Put your answers here! |
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
# Put your answers here! |
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 Array | |
#changes the array | |
def pad!(min_size, value = nil) | |
if min_size <= self.length | |
return self.clone | |
elsif min_size > self.length | |
(min_size - self.length).times do | |
self << value | |
end | |
return self.clone |