Write some code, that will flatten an array of arbitrarily nested arrays of integers into a flat array of integers. e.g. [[1,2,[3]],4] -> [1,2,3,4].
Excercise::Flattener is a class with a flatten function, that takes care of solving the exercise.
You need to have Ruby installed, as well as the bundler gem.
Then run:
bundle install
To run the test use:
rspec flattener_spec.rb
The project folder structure would change (similar to a gem layout) if it wasn't for the gist limitations.
There is not much to comment about the solution, a recursive function checking that the arguments match the prerequisites and raising exceptions if they are not.
I decided to use Array.reduce in favor of readability, code length and finally performance.