Skip to content

Instantly share code, notes, and snippets.

@havenwood

havenwood/intelo.rb Secret

Last active Sep 7, 2019
Embed
What would you like to do?
# frozen_string_literal: true
require 'minitest/autorun'
def intelo(foo, bar)
head = foo.flat_map.with_index do |n, i|
[n, bar[i * 2, 2]]
end
tail = bar[head.size..-1].to_a
(head + tail).flatten.compact
end
describe "Intelo's problem" do
it 'is as desired' do
assert_equal [], intelo([], [])
assert_equal [1, 2, 3, 4], intelo([], [1, 2, 3, 4])
assert_equal [1, 2, 3, 4], intelo([1], [2, 3, 4])
assert_equal [1, 3, 4, 2], intelo([1, 2], [3, 4])
assert_equal [1, 4, 2, 3], intelo([1, 2, 3], [4])
assert_equal [1, 2, 3, 4], intelo([1, 2, 3, 4], [])
end
end
@havenwood

This comment has been minimized.

Copy link
Owner Author

@havenwood havenwood commented Sep 7, 2019

Running:

.

Finished in 0.000796s, 1256.2814 runs/s, 7537.6884 assertions/s.
1 runs, 6 assertions, 0 failures, 0 errors, 0 skips

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.