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
# Hello! Welcome to my proflie page! | |
![Profile photo](https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xpf1/v/t1.0-1/p148x148/10557217_956596701023839_259493446267133820_n.jpg?oh=2cd73da8d734e9292ba897bab9d60ff0&oe=560F32A7&__gda__=1445583048_633a65cf0907373987d35bc3011d3de9) | |
**Short Summary** | |
*Born in LA, self-studying mainly to be a software engineer. I would love to work for a company like JPL or SpaceX. I enjoy hiking, coding, and watching movies.* | |
*My Programming Background.** |
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 Rectangle | |
attr_reader :width, :height | |
def initialize (width, height) | |
@width = width | |
@height = height | |
end | |
def area | |
area = width * height |
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 Dog | |
def initialize name | |
@name = name | |
end | |
def teach_trick(trick, &code) | |
define_singleton_method(trick, &code) | |
end | |
def method_missing(trick) |
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 sort num | |
res= [] | |
res2= [] | |
arr = num.to_s.split("") | |
arr.each { |x| res << x.to_i } | |
big_array = res.permutation.to_a | |
big_array.each {|x| res2 << x.join.to_i } | |
p res2 | |
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 word_count(sentence) | |
hash = sentence.downcase.gsub(/\W+/, ' ').split(" ").group_by{ |item| item } | |
hash.each { |item| hash[item[0]] = item[1].length } | |
end | |
p word_count("The quick brown fox jumped over the moon. This mammal did not jump over the sun; it jumped over the moon. And it was quick about it.") |
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 array | |
a = (1..100).to_a | |
a.each_slice(10).to_a | |
end | |
p array |
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
Easy Starters | |
1) write a function that creates a 10 x 10 2d array that looks like this: | |
[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], | |
[11, 12, 13, 14, 15, 16, 17, 18, 19, 20], | |
[21, 22, 23, 24, 25, 26, 27, 28, 29, 30], | |
[31, 32, 33, 34, 35, 36, 37, 38, 39, 40], | |
[41, 42, 43, 44, 45, 46, 47, 48, 49, 50], |
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
# I think the problem lies in class Charlie not being able to inherit the instance variables from class Guitar. | |
#For example, when we run this code: | |
class Guitar | |
def initialize(brand, color) | |
@color = color | |
@brand = brand |
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 Charlie | |
def initialize(guitar) | |
@guitar = guitar | |
end | |
def play(guitar) | |
guitar.type == 'electric' ? guitar.sound.upcase : guitar.sound.downcase | |
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
I, [2015-11-11T12:43:21.813873 #53754] INFO -- random number: 7358696 | |
I, [2015-11-11T12:43:21.814242 #53754] INFO -- random number: 4563567 |
OlderNewer