https://github.com/vadim-geroim/collatz-sequence
Determining the Collatz sequence for a number.
https://github.com/vadim-geroim/collatz-sequence
algorithms collatz-sequences rspec ruby
Last synced: about 1 month ago
JSON representation
Determining the Collatz sequence for a number.
- Host: GitHub
- URL: https://github.com/vadim-geroim/collatz-sequence
- Owner: vadim-geroim
- Created: 2019-11-08T03:50:00.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-11-08T04:06:42.000Z (over 6 years ago)
- Last Synced: 2025-01-13T08:12:32.192Z (over 1 year ago)
- Topics: algorithms, collatz-sequences, rspec, ruby
- Language: Ruby
- Homepage:
- Size: 3.91 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Collatz Sequence
Solution and Tests to the Columbia University
## Project structure
- `lib/collatz_sequence.rb` - contains solution
- `spec/collatz_sequence_spec.rb` - includes tests
## Solution
- The method `determine_collatz_sequence` accepts as an argument number n and returns and an array with a sequence.
- The method `determine_collatz_sequence_print` accepts as an argument an array witha a sequence and prints it in a console.
- The method `collect_all_collatz_sequences_length_for` accepts as an argument number n and returns an array of hashes where
hash is a single key - value pair. Key is n - number and value is a length of the sequence.
- The method `find_the_longest_sequence` accepts as an argument an array with hashes and returns an array with two elements.
The first element is a n - number and the second a length of the sequence.
## Test execution
- Run `bundle install`
- Open terminal window
- From the project directory run `rspec`