Skip to content

Instantly share code, notes, and snippets.

@Cyan101
Last active June 1, 2017 12:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Cyan101/fbc543ac42b6b366896fe3d15bc6b210 to your computer and use it in GitHub Desktop.
Save Cyan101/fbc543ac42b6b366896fe3d15bc6b210 to your computer and use it in GitHub Desktop.
[2017-05-29] Challenge #317 [Easy] Collatz Tag System
#[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"
@Cyan101
Copy link
Author

Cyan101 commented Jun 1, 2017

Could use splice! and perhaps a Hash system instead of 2 arrays

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment