Practice/mediumButterfly Pattern
⏱ 00:00
Best: 0/100
Symmetry & MirroringTarget Time: 15 mins

Butterfly Pattern

Given an integer N, print a symmetric butterfly pattern of 2*N rows. In row i of the top half, print i stars, 2*(N - i) spaces, and i stars. The bottom half is the vertical reflection.

Input Format
A single integer N.
Output Format
Print 2*N rows forming a butterfly.
Constraints:1 <= N <= 15
Concepts Required:
Dual wing symmetryMiddle shrinking space 2*(N - i)2*N rows structure
Expected Pattern PreviewASCII Monospace
*        *
**      **
***    ***
****  ****
**********
**********
****  ****
***    ***
**      **
*        *

Notice how character spacing and row counts scale systematically based on the input N.

Concrete Examples

Example 1
Input:
5
Output:
*        *
**      **
***    ***
****  ****
**********
**********
****  ****
***    ***
**      **
*        *

Explanation: Top 5 rows expand wings, bottom 5 rows contract wings.

← Back to All Challenges