Objective
Write a function which returns a multi-line string that contains an ASCII representation of a caterpillar.
The caterpillar is determined by zero or more segments, and each segment can have zero or more pairs of legs.
Examples
Caterpillar with one segment and two pairs of legs per segment:
\_/__
(")oo)
^^
Caterpillar with two segments with two pairs of leg for each:
\_/__ __
(")oo)oo)
^^ ^^
Caterpillar with two segments with four pairs of legs for each:
\_/____ ____
(")oooo)oooo)
^^^^ ^^^^
A poor caterpillar without any segments (poor you!):
\_/
(")
Precision
- No trailing spaces.
- The return string must have 3 lines.
def caterpillar(segments, legpairs):
pass
import codewars_test as test
# TODO Write tests
import solution # or from solution import example
# test.assert_equals(actual, expected, [optional] message)
@test.describe("Example")
def test_group():
@test.it("test case")
def test_case():
caterpillar1 = "\n".join([
'\_/__',
'(")oo)',
' ^^'])
caterpillar2 = "\n".join([
'\_/__ __',
'(")oo)oo)',
' ^^ ^^'])
caterpillar3 = "\n".join([
'\_/',
'(")ooo)ooo)',
' ^^^ ^^^'])
caterpillar4 = "\n".join([
'\_/',
'(")',
''])
caterpillar5 = "\n".join([
'\_/',
'("))))))))',
''])
test.assert_equals(caterpillar(1,2), caterpillar1)
test.assert_equals(caterpillar(2,2), caterpillar2)
test.assert_equals(caterpillar(4,3), caterpillar3)
test.assert_equals(caterpillar(0,0), caterpillar4)
test.assert_equals(caterpillar(0,10), caterpillar4)
test.assert_equals(caterpillar(7,0), caterpillar5)