-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Space - Diana #32
base: master
Are you sure you want to change the base?
Space - Diana #32
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work, you hit most of all the learning goals here. Well done.
Take a look at my comments and let me know if you have any questions.
intersection_array = list2.map do |num| | ||
num if lookup_hash[num] | ||
end | ||
|
||
return intersection_array.compact |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use map
if you want to do an operation on each element in the array. In this case you want to get only some of the elements of the array.
intersection_array = list2.map do |num| | |
num if lookup_hash[num] | |
end | |
return intersection_array.compact | |
intersection_array = list2.select do |num| | |
lookup_hash[num] | |
end | |
return intersection_array |
@@ -1,3 +1,25 @@ | |||
def intersection(list1, list2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
if number_of_odd > 1 | ||
return false | ||
else | ||
return true | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if number_of_odd > 1 | |
return false | |
else | |
return true | |
end | |
return number_of_odd > 1 |
@@ -1,4 +1,21 @@ | |||
|
|||
def permutations?(string1, string2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would fail for something like heelo
and hello
. Instead of making lookup_hash[letter] = true
instead count the number of times each letter appears.
No description provided.