Problem 5, Part 1

Draw the following pattern:

**..**..**..
..**..**..**
**..**..**..
..**..**..**
**..**..**..
..**..**..**

You are given the size of the image (as width).

Data:

ALLOWED_CHARS

Express every line of the pattern

Functions:

draw(width)

Draw the pattern with the size given as width and return the text lines.

ALLOWED_CHARS = re.compile('[.*]+')

Express every line of the pattern

draw(width: int) Lines[source]

Draw the pattern with the size given as width and return the text lines.

Requires
  • width % 4 == 0

  • width > 0

Ensures
  • len(result) == width / 2

  • all(len(line) == width for line in result)

  • result[0].endswith('.')

  • result[0].startswith('*')

  • result[-1].endswith('*')

  • result[-1].startswith('.')

  • all(
        ALLOWED_CHARS.fullmatch(line)
        for line in result
    )