This is good stuff. Your code does the job and passes all of the tests. Here are some notes:
- One of your variable names is too vague. Instead of
new_array
how aboutdup_of_array
or something that indicates what the array is holding/why you need it. - You are creating a duplicate array in a very unconventional manner. Check out clone and dup for a better way to do this. (Hint: one of these will be better than the other.)
- Good use of
until
andrand
and<<
andlength
and especiallyslice!
, which is taking care of two needs simultaneously (removing and returning the desired array object). - Watch your indentation. Specifically, lines 7 to 11 should be indented. Readability is vital!
- Be sure to delete unused/extra code from your final product. Specifically, this line should not be in your final code, since the
runner.rb
file is taking care of the running and printing.
Good work! Any questions let me know.
-Phil