Skip to content
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

Add solution for day 4 #1

Merged
merged 6 commits into from Dec 8, 2019
Merged

Add solution for day 4 #1

merged 6 commits into from Dec 8, 2019

Conversation

@zeitschlag
Copy link
Owner

zeitschlag commented Dec 4, 2019

No description provided.

@zeitschlag zeitschlag changed the title Add solution for 4.1 Add solution for day 4 Dec 4, 2019
2019/04/fourth_day.rb Outdated Show resolved Hide resolved

potential_passwords = []

(353096..843212).each { |current_number|

This comment has been minimized.

Copy link
@FlowFX

FlowFX Dec 4, 2019

Instead of each and then appending to the array, use map, which returns an array. The block should return the input number, if it's a potential password, and nil otherwise. Then put a .compact on the resulting array.

@FlowFX

This comment has been minimized.

Copy link

FlowFX commented on 2019/04/fourth_day.rb in c82c2c9 Dec 5, 2019

And now comes Ruby-ism:

two_adjacent_digits = number_string.chars.each_cons(2).any? { |a,b| a == b }

This comment has been minimized.

Copy link

FlowFX replied Dec 5, 2019

Plus, now you don't have to initialize two_adjacent_digits above.

This comment has been minimized.

Copy link
Owner Author

zeitschlag replied Dec 5, 2019

I think, I have to get used to that step by step. Looks a bit swift-y

This comment has been minimized.

Copy link

FlowFX replied Dec 5, 2019

I'm just happy I can boast with my Ruby knowledge. 🥇

@zeitschlag zeitschlag merged commit 637cc57 into master Dec 8, 2019
@zeitschlag zeitschlag deleted the 04 branch Dec 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.