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
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 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 array | |
a = (1..100).to_a | |
a.each_slice(10).to_a | |
end | |
p 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
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 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 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 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
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 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
class Rectangle | |
attr_reader :width, :height | |
def initialize (width, height) | |
@width = width | |
@height = height | |
end | |
def area | |
area = width * height |
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
# Hello! Welcome to my proflie page! | |
 | |
**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.** |
NewerOlder