0% found this document useful (0 votes)
2 views30 pages

Pattern Problems

The document provides a comprehensive guide on creating various star and number patterns using different input values, primarily focusing on the number 5. It includes detailed examples of solid shapes, triangles, pyramids, hourglasses, and hollow shapes, along with their respective outputs. Additionally, it covers number patterns such as squares, triangles, and matrices, showcasing different arrangements and styles.

Uploaded by

kh khalid hasan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views30 pages

Pattern Problems

The document provides a comprehensive guide on creating various star and number patterns using different input values, primarily focusing on the number 5. It includes detailed examples of solid shapes, triangles, pyramids, hourglasses, and hollow shapes, along with their respective outputs. Additionally, it covers number patterns such as squares, triangles, and matrices, showcasing different arrangements and styles.

Uploaded by

kh khalid hasan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1.

Star Patterns or Single character Patterns


In place of '*' it could be any character like 'A', 'B', '$', '#', '1', '7' etc.

1.1. Solid Square of Stars

1.1.1. Input: 5

1.1.2. Output:

*****
*****
*****
*****
*****

1.2. Right Triangle of Stars

1.2.1. Input: 5

1.2.2. Output:

*
**
***
****
*****

1.3. Right Triangle with Leading Spaces of Stars

1.3.1. Input: 5

1.3.2. Output:

*
**
***
****
*****

1.4. Inverted Right Triangle of Stars

1.4.1. Input: 5

1.4.2. Output:

*****
****
***
**
*

1.5. Inverted Right Triangle with Leading Spaces of Stars

1.5.1. Input: 5

1.5.2. Output:

*****
****
***
**
*

1.6. Pyramid of Stars

1.6.1. Input: 5

1.6.2. Output:

*
***
*****
*******
*********

1.7. Inverted Pyramid of Stars

1.7.1. Input: 5

1.7.2. Output:

*********
*******
*****
***
*

1.8. Right Pascal Triangle

1.8.1. Input: 5

1.8.2. Output:

*
**
***
****
*****
****
***
**
*

1.9. Left Pascal Triangle

1.9.1. Input: 5

1.9.2. Output:

*
**
***
****
*****
****
***
**
*

1.10. Right Half Hour Glass of Stars

1.10.1. Input: 5

1.10.2. Output:

*****
****
***
**
*
**
***
****
*****

1.11. Left Half Hour Glass of Stars

1.11.1. Input: 5

1.11.2. Output:

*****
****
***
**
*
**
***
****
*****
1.12. Diamond of Stars

1.12.1. Input: 5

1.12.2. Output:

*
***
*****
*******
*********
*******
*****
***
*

1.13. Hourglass of Stars

1.13.1. Input: 5

1.13.2. Output:

*********
*******
*****
***
*
***
*****
*******
*********

1.14. Twin Peaks of Stars

1.14.1. Input: 5

1.14.2. Output:

* *
** **
*** ***
**** ****
**********

1.15. Inverted Twin Peaks of Stars

1.15.1. Input: 5

1.15.2. Output:

**********
**** ****
*** ***
** **
* *

1.16. Butterfly of Stars

1.16.1. Input: 5

1.16.2. Output:

* *
** **
*** ***
**** ****
**********
**** ****
*** ***
** **
* *

1.17. Hollow Diamond of Stars

1.17.1. Input: 5

1.17.2. Output:

**********
**** ****
*** ***
** **
* *
* *
** **
*** ***
**** ****
**********

1.18. Hollow Square of Stars

1.18.1. Input: 5

1.18.2. Output:

*****
* *
* *
* *
*****

1.19. Hollow Right Triangle of Stars


1.19.1. Input: 5

1.19.2. Output:

*
**
* *
* *
*****

1.20. Hollow Right Triangle with Leading Spaces of Stars

1.20.1. Input: 5

1.20.2. Output:

*
**
* *
* *
*****

1.21. Hollow Inverted Right Triangle of Stars

1.21.1. Input: 5

1.21.2. Output:

*****
* *
* *
**
*

1.22. Hollow Inverted Right Triangle with Leading Spaces of Stars

1.22.1. Input: 5

1.22.2. Output:

*****
* *
* *
**
*

1.23. Hollow Pyramid of Stars

1.23.1. Input: 5

1.23.2. Output:
*
* *
* *
* *
*********

1.24. Hollow Inverted Pyramid of Stars

1.24.1. Input: 5

1.24.2. Output:

*********
* *
* *
* *
*

1.25. Hollow Right Pascal Triangle

1.25.1. Input: 5

1.25.2. Output:

*
**
* *
* *
* *
* *
* *
**
*

1.26. Hollow Left Pascal Triangle

1.26.1. Input: 5

1.26.2. Output:

*
**
* *
* *
* *
* *
* *
**
*

1.27. Hollow Right Half Hour Glass of Stars


1.27.1. Input: 5

1.27.2. Output:

*****
* *
* *
**
*
**
* *
* *
*****

1.28. Hollow Left Half Hour Glass of Stars

1.28.1. Input: 5

1.28.2. Output:

*****
* *
* *
**
*
**
* *
* *
*****

1.29. Hollow Diamond of Stars

1.29.1. Input: 5

1.29.2. Output:

*
* *
* *
* *
* *
* *
* *
* *
*

1.30. Hollow Hourglass of Stars

1.30.1. Input: 5

1.30.2. Output:
*********
* *
* *
* *
*
* *
* *
* *
*********

2. Number Patterns
Numbers could be any integer numbers.

2.1. Row Numbers Square

2.1.1. Input: 5

2.1.2. Output:

11111
22222
33333
44444
55555

2.2. Inverted Row Numbers Square

2.2.1. Input: 5

2.2.2. Output:

55555
44444
33333
22222
11111

2.3. Column Numbers Square

2.3.1. Input: 5

2.3.2. Output:

12345
12345
12345
12345
12345
2.4. Inverted Column Numbers Square

2.4.1. Input: 5

2.4.2. Output:

54321
54321
54321
54321
54321

2.5. Checkerboard Pattern

2.5.1. Input: 5

2.5.2. Output:

1 0 1 0 1
0 1 0 1 0
1 0 1 0 1
0 1 0 1 0
1 0 1 0 1

2.6. Hollow Square of Numbers

2.6.1. Input: 5

2.6.2. Output:

11111
10001
10001
10001
11111

2.7. Column Numbers Square with Leading Spaces

2.7.1. Input: 5

2.7.2. Output:

12345
12345
12345
12345
12345

2.8. Inverted Column Numbers Square with Leading Spaces

2.8.1. Input: 5
2.8.2. Output:

54321
54321
54321
54321
54321

2.9. Staircase Numbers

2.9.1. Input: 5

2.9.2. Output:

11
22
33
44
55

2.10. Double Column Numbers Square

2.10.1. Input: 5

2.10.2. Output:

1122334455
1122334455
1122334455
1122334455
1122334455

2.11. Right Triangle Of Column Numbers

2.11.1. Input: 5

2.11.2. Output:

1
12
123
1234
12345

2.12. Right Triangle Of Inverted Column Numbers

2.12.1. Input: 5

2.12.2. Output:
5
54
543
5432
54321

2.13. Inverted Right Triangle with Leading Spaces

2.13.1. Input: 5

2.13.2. Output:

1
12
123
1234
12345

2.14. Inverted Right Triangle with Leading Spaces Reversed

2.14.1. Input: 5

2.14.2. Output:

5
54
543
5432
54321

2.15. Inverted Right Triangle with Leading Spaces of Column Numbers

2.15.1. Input: 5

2.15.2. Output:

1
21
321
4321
54321

2.16. Pyramid Numbers

2.16.1. Input: 5

2.16.2. Output:

1
121
12321
1234321
123454321

2.17. Inverted Pyramid Numbers

2.17.1. Input: 5

2.17.2. Output:

5
545
54345
5432345
543212345

2.18. Odd Numbers Triangle

2.18.1. Input: 5

2.18.2. Output:

1
3 5
7 9 11
13 15 17 19
21 23 25 27 29

2.19. Even Numbers Triangle

2.19.1. Input: 5

2.19.2. Output:

2
4 6
8 10 12
14 16 18 20
22 24 26 28 30

2.20. Inverted Pyramid of Palindrome Numbers

2.20.1. Input: 5

2.20.2. Output:

123454321
1234321
12321
121
1

2.21. Inverted Pyramid of Reverse Palindrome Numbers

2.21.1. Input: 5

2.21.2. Output:

543212345
5432345
54345
545
5

2.22. Palindrome Diamond

2.22.1. Input: 5

2.22.2. Output:

1
121
12321
1234321
123454321
1234321
12321
121
1

2.23. Inverted Palindrome Diamond

2.23.1. Input: 5

2.23.2. Output:

5
545
54345
5432345
543212345
5432345
54345
545
5

2.24. Twin Peaks of Numbers

2.24.1. Input: 5
2.24.2. Output:

5 5
54 45
543 345
5432 2345
543212345

2.25. Inverted Twin Peaks of Numbers

2.25.1. Input: 5

2.25.2. Output:

543212345
5432 2345
543 345
54 45
5 5

2.26. Alternating Rows in Square of Numbers

2.26.1. Input: 5

2.26.2. Output:

54321
12345
54321
12345
54321

2.27. Alternating Columns in Square of Numbers

2.27.1. Input: 5

2.27.2. Output:

15151
24242
33333
42424
51515

2.28. Matrix Numbers

2.28.1. Input: 5

2.28.2. Output:
11 12 13 14 15
21 22 23 24 25
31 32 33 34 35
41 42 43 44 45
51 52 53 54 55

2.29. Continuous Matrix Numbers

2.29.1. Input: 5

2.29.2. Output:

11 12 13 14 15
16 17 18 19 20
21 22 23 24 25
26 27 28 29 30
31 32 33 34 35
36 37 38 39 40

2.30. Rectangle of Column Numbers

2.30.1. Input: 4 5

2.30.2. Output:

12345
12345
12345
12345

2.31. Rectangle of Index Numbers

2.31.1. Input: 4 5

2.31.2. Output:

11 12 13 14 15
21 22 23 24 25
31 32 33 34 35
41 42 43 44 45

2.32. Cyclic Rectangle of Numbers

2.32.1. Input: 4 10

2.32.2. Output:

1234567891
2345678912
3456789123
4567891234

2.33. Hollow Square with Row Numbers

2.33.1. Input: 5

2.33.2. Output:

12345
1 5
1 5
1 5
12345

2.34. The Concentric Number Square

2.34.1. Input: 5

2.34.2. Output:

5555555
5444445
5433345
5432345
5433345
5444445
5555555

2.35. Hollow Pyramid of Numbers

2.35.1. Input: 5

2.35.2. Output:

1
2 2
3 3
4 4
543212345

2.36. Hollow Diamond of Numbers

2.36.1. Input: 5

2.36.2. Output:

1
2 2
3 3
4 4
5 5
4 4
3 3
2 2
1

2.37. X Shape Numbers

2.37.1. Input: 5

2.37.2. Output:

1 1
2 2
3
4 4
5 5

3. Letter Patterns
Letters could be A-Z or a-z.

3.1. Solid Square of Letters

3.1.1. Input: 5

3.1.2. Output:

AAAAA
BBBBB
CCCCC
DDDDD
EEEEE

3.2. Rectangle of Letters

3.2.1. Input: 4 3

3.2.2. Output:

AAA
BBB
CCC
DDD

3.3. Row Letters Square

3.3.1. Input: 5

3.3.2. Output:
ABCDE
ABCDE
ABCDE
ABCDE
ABCDE

3.4. Inverted Row Letters Square

3.4.1. Input: 5

3.4.2. Output:

EDCBA
EDCBA
EDCBA
EDCBA
EDCBA

3.5. Alternating Rows of Letters

3.5.1. Input: 5

3.5.2. Output:

ABCDE
EDCBA
ABCDE
EDCBA
ABCDE

3.6. Alternating Columns of Letters

3.6.1. Input: 5

3.6.2. Output:

AEAEA
BDBDB
CCCCC
DBDBD
EAEAE

3.7. Inverted Row Letters Z

3.7.1. Input: 5

3.7.2. Output:

ZYXWV
ZYXWV
ZYXWV
ZYXWV
ZYXWV

3.8. Alternating Rows of Letters Z

3.8.1. Input: 5

3.8.2. Output:

ABCDE
ZYXWV
ABCDE
ZYXWV
ABCDE

3.9. Matrix Letters

3.9.1. Input: 5

3.9.2. Output:

AA AB AC AD AE
BA BB BC BD BE
CA CB CC CD CE
DA DB DC DD DE
EA EB EC ED EE

3.10. Alternating Matrix Letters

3.10.1. Input: 5

3.10.2. Output:

AZ BY CX DW EV
AZ BY CX DW EV
AZ BY CX DW EV
AZ BY CX DW EV
AZ BY CX DW EV

3.11. Alternating Matrix Letters Vertical

3.11.1. Input: 5

3.11.2. Output:

AZ AZ AZ AZ AZ
BY BY BY BY BY
CX CX CX CX CX
DW DW DW DW DW
EV EV EV EV EV

3.12. Right Square of Row Letters with Leading Spaces

3.12.1. Input: 5

3.12.2. Output:

ABCDE
ABCDE
ABCDE
ABCDE
ABCDE

3.13. Inverted Right Square of Row Letters with Leading Spaces

3.13.1. Input: 5

3.13.2. Output:

EDCBA
EDCBA
EDCBA
EDCBA
EDCBA

3.14. Rectangle of Row Letters

3.14.1. Input: 4 5

3.14.2. Output:

ABCDE
ABCDE
ABCDE
ABCDE

3.15. Right Triangle of Letters

3.15.1. Input: 5

3.15.2. Output:

A
AB
ABC
ABCD
ABCDE
3.16. Right Triangle of Letters with Leading Spaces

3.16.1. Input: 5

3.16.2. Output:

A
AB
ABC
ABCD
ABCDE

3.17. Inverted Right Triangle of Letters

3.17.1. Input: 5

3.17.2. Output:

ABCDE
ABCD
ABC
AB
A

3.18. Inverted Right Triangle with Leading Spaces

3.18.1. Input: 5

3.18.2. Output:

ABCDE
ABCD
ABC
AB
A

3.19. Inverted Right Triangle with Leading Spaces E

3.19.1. Input: 5

3.19.2. Output:

EDCBA
DCBA
CBA
BA
A

3.20. Pyramid Letters

3.20.1. Input: 5
3.20.2. Output:

A
ABA
ABCBA
ABCDCBA
ABCDEDCBA

3.21. Inverted Pyramid Letters

3.21.1. Input: 5

3.21.2. Output:

ABCDEDCBA
ABCDCBA
ABCBA
ABA
A

3.22. Diamond Letters

3.22.1. Input: 5

3.22.2. Output:

A
ABA
ABCBA
ABCDCBA
ABCDEDCBA
ABCDCBA
ABCBA
ABA
A

3.23. The Concentric Letter Square

3.23.1. Input: 5

3.23.2. Output:

DDDDDD
DCCCCD
DCBBCD
DCBACD
DCBBCD
DCCCCD
DDDDDD

3.24. Continuous Letter Rectangle


3.24.1. Input: 4 5

3.24.2. Output:

ABCDE
FGHIJ
KLMNO
PQRST

3.25. Continuous Letter Rectangle Reversed

3.25.1. Input: 4 5

3.25.2. Output:

ZYXWV
UTSRQ
PONML
KJIHG

3.26. Alternating Continuous Letter Rectangle

3.26.1. Input: 4 5

3.26.2. Output:

A B C D E
J I H G F
K L M N O
T S R Q P

3.27. Twin Picks of Letter

3.27.1. Input: 5

3.27.2. Output:

A A
AB BA
ABC CBA
ABCD DCBA
ABCDEDCBA

3.28. Inverted Twin Picks of Letter

3.28.1. Input: 5

3.28.2. Output:

ABCDEDCBA
ABCD DCBA
ABC CBA
AB BA
A A

3.29. Hollow Diamond of Letter Rectangle

3.29.1. Input: 5

3.29.2. Output:

ABCDEDCBA
ABCD DCBA
ABC CBA
AB BA
A A
AB BA
ABC CBA
ABCD DCBA
ABCDEDCBA

3.30. Hollow Letter Square

3.30.1. Input: 5

3.30.2. Output:

ABCDE
F G
H I
J K
LMNOP

3.31. Hollow Reversed Letter Square

3.31.1. Input: 5

3.31.2. Output:

ZYXWV
U T
S R
Q P
ONMLK

3.32. Pyramid with Hollow

3.32.1. Input: 5

3.32.2. Output:
A
B C
D E
F G
HIJKLMNOP

3.33. Inverted Pyramid with Hollow

3.33.1. Input: 5

3.33.2. Output:

ABCDEFGHI
J K
L M
N O
P

3.34. Hollow Diamond Letters

3.34.1. Input: 5

3.34.2. Output:

A
B C
D E
F G
H I
J K
L M
N O
P

3.35. Hollow Diamond Letters Reversed

3.35.1. Input: 5

3.35.2. Output:

Z
Y X
W V
U T
S R
Q P
O N
M L
K

3.36. Checkerboard Letters


3.36.1. Input: 5

3.36.2. Output:

A B A B A
B A B A B
A B A B A
B A B A B
A B A B A

3.37. Continuous Rectangle Letters

3.37.1. Input: 3 12

3.37.2. Output:

ABCDEFGHIJKL
MNOPQRSTUVWX
YZABCDEFGHIJ

3.38. X Shaped Letters

3.38.1. Input: 5

3.38.2. Output:

A E
B D
C
B D
A E

4. Mixed Patterns
Numbers, Letters and Other characters are mixed.

4.1. Alternating Letters and Numbers

4.1.1. Input: 5

4.1.2. Output:

ABCDE
12345
ABCDE
12345
ABCDE

4.2. Alternating Letters and Symbols


4.2.1. Input: 9

4.2.2. Output:

ABCDEFGHI
#########
ABCDEFGHI
$$$$$$$$$
ABCDEFGHI
#########
ABCDEFGHI
$$$$$$$$$
ABCDEFGHI

4.3. Diagonal Numbers and Symbols

4.3.1. Input: 5

4.3.2. Output:

1@@@@
@2@@@
@@3@@
@@@4@
@@@@5

4.4. Diagonal Letters and Symbols

4.4.1. Input: 5

4.4.2. Output:

A....
.B...
..C..
...D.
....E

4.5. Matrix with Letters and Numbers

4.5.1. Input: 5

4.5.2. Output:

1A 2B 3C 4D 5E
1A 2B 3C 4D 5E
1A 2B 3C 4D 5E
1A 2B 3C 4D 5E
1A 2B 3C 4D 5E

4.6. Matrix with Inverted Letters and Numbers


4.6.1. Input: 5

4.6.2. Output:

5A 4B 3C 2D 1E
5A 4B 3C 2D 1E
5A 4B 3C 2D 1E
5A 4B 3C 2D 1E
5A 4B 3C 2D 1E

4.7. Matrix with Letters and Numbers Incrementing

4.7.1. Input: 5

4.7.2. Output:

A1 B2 C3 D4 E5
A2 B3 C4 D5 E6
A3 B4 C5 D6 E7
A4 B5 C6 D7 E8
A5 B6 C7 D7 E9

4.8. Diagonal Letters and Numbers

4.8.1. Input: 5

4.8.2. Output:

1BCDE
A2CDE
AB3DE
ABC4E
ABCD5

4.9. Diagonal Letters and Numbers Inverted

4.9.1. Input: 5

4.9.2. Output:

ABCD1
ABC2E
AB3DE
A4CDE
5BCDE

4.10. Rectangle with Letters and Numbers

4.10.1. Input: 3 6

4.10.2. Output:
A 1 B 2 C 3
D 4 E 5 F 6
G 7 H 8 I 9

4.11. Sparse Letters and Numbers

4.11.1. Input: 5

4.11.2. Output:

EDCBA
5DCBA
54CBA
543BA
5432A

4.12. Pyramid with Letters and Numbers

4.12.1. Input: 5

4.12.2. Output:

A
B4B
C434C
D43234D
E4321234E

4.13. Diamond with Letters and Numbers

4.13.1. Input: 5

4.13.2. Output:

ABCDEDCBA
ABCD1DCBA
ABC212CBA
AB32123BA
A4321234A
AB32123BA
ABC212CBA
ABCD1DCBA
ABCDEDCBA

You might also like