6 kyu

■□ Pattern □■ : Snake

Description:

# Task:

  • Complete the pattern, using the special character ■ □ ∷

  • In this kata, let's us draw a twisted snake.

# Rules:

  • parameter width: The snake's body swing width, a positive even number.
  • parameter height: The height of the snake's body from top to bottom, a positive even number.
  • return a string, looks like a snake twisting the body. In order to maintain the shape, pad on the left side or right side(if necessary).

# Example:

snake(2,2)        snake(4,2)         snake(2,4)              snake(8,4)
A snake egg?   A newborn snake?
   ■□            ■□■□            ■□           ■□■□■□■□
   □■            □■□■            □■           □■□■□■□■
                                       ■□           ∷∷∷∷∷∷■□
                                       □■           ∷∷∷∷∷∷□■
                                       
              According to the shape of the snake twisted
                ■□ is staggered pattern on the snake
              
snake(2,10)   snake(4,10)         snake(8,10)              snake(8,18)
   ■□         ■□■□       ■□■□■□■□         ■□■□■□■□
   □■         □■□■       □■□■□■□■         □■□■□■□■
   ■□         ∷∷■□       ∷∷∷∷∷∷■□         ∷∷∷∷∷∷■□
   □■         ∷∷□■       ∷∷∷∷∷∷□■         ∷∷∷∷∷∷□■
   ■□         ■□■□       ■□■□■□■□         ■□■□■□■□
   □■         □■□■       □■□■□■□■         □■□■□■□■
   ■□         ■□∷∷       ■□∷∷∷∷∷∷         ■□∷∷∷∷∷∷
   □■         □■∷∷       □■∷∷∷∷∷∷         □■∷∷∷∷∷∷
   ■□         ■□■□       ■□■□■□■□         ■□■□■□■□
   □■         □■□■       □■□■□■□■         □■□■□■□■
                                                        ∷∷∷∷∷∷■□
                                                        ∷∷∷∷∷∷□■
                                                        ■□■□■□■□
                                                        □■□■□■□■
                                                        ■□∷∷∷∷∷∷
                                                        □■∷∷∷∷∷∷
                                                        ■□■□■□■□
                                                        □■□■□■□■

ASCII Art
Puzzles

Stats:

CreatedMar 11, 2016
PublishedMar 14, 2016
Warriors Trained253
Total Skips80
Total Code Submissions176
Total Times Completed52
JavaScript Completions52
Total Stars3
% of votes with a positive feedback rating94% of 26
Total "Very Satisfied" Votes24
Total "Somewhat Satisfied" Votes1
Total "Not Satisfied" Votes1
Total Rank Assessments5
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
6 kyu
Ad
Contributors
  • myjinxin2015 Avatar
  • ZED.CWT Avatar
Ad