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
#write me a function stringy that takes a size and returns a string of alternating '1s' and '0s'. | |
#the string should start with a 1. | |
#a string with size 6 should return :'101010'. | |
#with size 4 should return : '1010'. | |
#with size 12 should return : '101010101010'. | |
#The size will always be positive and will only use whole numbers. | |
#My Solution: |
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
#Create a function with two arguments that will return a list of length (n) with multiples of (x). | |
#Assume both the given number and the number of times to count will be positive numbers greater than 0. | |
#Return the results as an array (or list in Python, Haskell or Elixir). | |
#Examples: | |
#count_by(1,10) should return [1,2,3,4,5,6,7,8,9,10] | |
#count_by(2,5) should return [2,4,6,8,10] | |
#My Solution: | |
def count_by(x, 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
#Jenny has written a function that returns a greeting for a user. However, she's in love with Johnny, and would | |
#like to greet him slightly different. She added a special case to her function, but she made a mistake. | |
#Can you help her? | |
#Initial Code with Error: | |
def greet(name) | |
return "Hello, #{name}!" | |
return "Hello, my love!" if name == "Johnny" | |
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 Array | |
def my_each(&block) | |
for i in self | |
yield i | |
end | |
end | |
def my_map(&block) | |
arr = [] | |
for i in self |
NewerOlder