nice kumite
I think the test case for caterpillar3 was broken
def caterpillar(segments, legpairs): head = [ '\_/', '(")', ' ' ] segment = [ '_' * legpairs + ' ', 'o' * legpairs + ')', '^' * legpairs + ' ' ] return '\n'.join( (head_row + segment_row * segments).rstrip() for head_row, segment_row in zip(head, segment) )
- def caterpillar(segments, legpairs):
pass- head = [
- '\_/',
- '(")',
- ' '
- ]
- segment = [
- '_' * legpairs + ' ',
- 'o' * legpairs + ')',
- '^' * legpairs + ' '
- ]
- return '\n'.join(
- (head_row + segment_row * segments).rstrip()
- for head_row, segment_row in zip(head, segment)
- )
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)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)
- 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)',' ^^^ ^^^'])- '\_/___ ___ ___ ___',
- '(")ooo)ooo)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)