Last active
June 1, 2017 12:20
-
-
Save Cyan101/fbc543ac42b6b366896fe3d15bc6b210 to your computer and use it in GitHub Desktop.
[2017-05-29] Challenge #317 [Easy] Collatz Tag System
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
#[2017-05-29] Challenge #317 [Easy] Collatz Tag System | |
#https://www.reddit.com/r/dailyprogrammer/comments/6e08v6/20170529_challenge_317_easy_collatz_tag_system/ | |
tag_keys = %w(a b c) | |
tag_system = %w(bc a aaa) | |
puts "what do i start with? (at least 3 chars, combination of a/b/c)" | |
tag = gets.chomp | |
while tag.length > 2 | |
case tag.chr | |
when tag_keys[0] | |
tag = tag[2..-1] + tag_system[0] | |
when tag_keys[1] | |
tag = tag[2..-1] + tag_system[1] | |
when tag_keys[2] | |
tag = tag[2..-1] + tag_system[2] | |
end | |
puts tag | |
end | |
puts tag[1] | |
puts "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Could use
splice!
and perhaps a Hash system instead of 2 arrays