Friday, March 2, 2018

Patterns are heart of algorithmic programming. Code 100 problems in python.

Patterns are heart of programming algorithms. They are not difficult program. All you have to do is study relationships and occurrences. Write a programs to produce given outputs using python.


Q.1    structure:
$$$$$
$$$$$
$$$$$
$$$$$
$$$$$

Q.2    #'s triangle:
# # # # #
# # # #
# # #
# #
#

Q.3    $'s triangle:
$ $ $ $ $
$ $ $ $
$ $ $
$ $
$

Q.4    #'s triangle:-       
#
## 
### 
#### 
#####

Q.5    $'s triangle:  




$
$ $
$ $ $
$ $ $ $
$ $ $ $ $

Q.6    numbers structure:
12345
12345
12345
12345
12345

Q.7    numbers structure:
54321
54321
54321
54321
54321

Q.8    numbers structure:
55555
44444
33333
22222
11111

Q.9    numbers structure:
11111
22222
33333
44444
55555

Q.10    numbers structure:
1
12
123
1234
12345

Q.11    numbers structure:
12345
1234
123
12
1

Q.12    numbers structure:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5

Q.13    numbers structure:
54321
4321
321
21
1

Q.14    numbers structure:
1
21
321
4321
54321

Q.15    numbers structure:
12345
1234
123
12
1

Q.16    numbers structure:
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1

Q.17    numbers structure:
1 
1 2 1 
1 2 3 2 1 
1 2 3 4 3 2 1 
1 2 3 4 5 4 3 2 1

Q.18    numbers structure:
1 2 3 4 5 4 3 2 1
1 2 3 4 3 2 1 
1 2 3 2 1 
1 2 1 
1    


Q.19    triangle
* 
* * * 
* * * * * 
* * * * * * * 
* * * * * * * * * 
* * * * * * * * * * *

Q.20  Floyd's triangle: 
1
2 3
4 5 6
7 8 9 10

Q.21  Pascal triangle:
     1
    1 1
   1 2 1
  1 3 3 1

Q.22  character triangle:
A
B B
C C C
D D D D

Q.23   character triangle:
    A
         A B A
       A B C B A
     A B C D C B A
   A B C D E D C B A

Q.24   character triangle:
A B C D E D C B A
  B C D E D C B
    C D E D C
      D E D
        E

Q.25  number structure:
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1

Q.26 :

S
SR
SRI
SRIL 
SRILA
SRILAN
SRILANK
SRILANKA

Q.27  character structure:
A
BB
CCC
DDDD
CCC
BB
A

Q.28  number triangle:

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

Q. 29  number structure:

123454321
 2345432
  34543
   454
    5


Q.30.  number triangle structure:-

     1
    21
   321
  4321
 54321

Q.31.  number triangle structure:

 54321
  4321
   321
    21
     1

Q.32    number pyramid:

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

Q.33    number structure:

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



Q. 34  rhombus symbol structure:

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

Q. 35  number rhombus structure:

     1
    212
   32123
  4321234
   32123
    212
     1

Q. 36 number rhombus structure:

     1
    121
   12321
  1234321
   12321
    121
     1

Q.37  character rhombus structure:

     A
    ABA
   ABCBA
  ABCDCBA
   ABCBA
    ABA
     A

Q.38  square character triangle:

      A
     ABA
    ABCBA
   ABCDCBA

Q.39  square character triangle:

  ABCDCBA
   ABCBA
    ABA
     A


Q.40  square character triangle:

     A
    AB
   ABC
  ABCD
 ABCDE
  ABCD
   ABC
    AB 
     A 

Q.41  square character triangle:


A
BA
CBA
DCBA
EDCBA
DCBA
CBA
BA
A

Q.42    character triangle:


EDCBA
DCBA
CBA
BA
A

Q.43    number design/triangle:

9
0 1
2 3 4
5 6 7 8
9 0 1 2 3

Q. 44    number rectangle:

12344321
123__321
12____21
1______1

Q. 45    number pyramid or number structure:

            1
          1 2 3
        1 2 3 4 5
      1 2 3 4 5 6 7
    1 2 3 4 5 6 7 8 9

Q. 46 number pyramid:

123456654321
1234554321
12344321
123321
1221
11

Q. 47 character pyramid:

ABCDEFFEDCBA
ABCDEEDCBA
ABCDDCBA
ABCCBA
ABBA
AA

Q. 48    number pyramid:

       1
      222
     33333
    4444444
   555555555

Q. 49   number triangle:

 9
 898
 78987
 6789876


Q. 50   number triangle:

 5
 45
 345
 2345
 12345



Q. 51   number triangle:


 5
 454
 34543
 2345432
 123454321

Q. 52   star structure/fashion:

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

Q. 53    rectangle number pyramid:

33333
32223
32123
32223
33333

Q. 54  the star triangle frame pyramid like :

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

Q. 55    star pattern pyramid:

*
***
******

Q. 56  reverse star pyramid :

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

Q. 57  odd number series pyramid :

1
3  5  7
9 11 13 15 17 19

Q.58   number pyramid/triangle:

54321
5432
543
54
5

Q.59  the number character pyramid :

1
AB
123
ABCD
12345

Q. 60   Floyd triangle :

       1
      2 3
     4 5 6
    7 8 9 10

Q.61   number pyramid:

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

Q.62   character pyramid:

A
BA
ABA
BABA
ABABA

Q.63 rows input pyramid :

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

Q.64   number pyramid:

1
232
34543
4567654

Q.65   number rectangle structure:

12321
12 21
1   1
12 21
12321

Q.66   character rectangle design:

ABCBA
AB BA
A   A
AB BA
ABCBA

Q.67   star triangle structure:

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

Q.68   number rectangle program:

1234
2341
3412
4123

Q.69   character rectangle program:

ABCD
BCDA
CDAB
DABC

Q.70   number pyramid program:

1234
341
12
3

Q.71   character pyramid program:

ABCD
CDA
AB
C

Q.72   number pyramid using function:

 1
 2 3
 4 5 6
 7 8 9 1
 2 3 4 5 6

Q.73   number pyramid:

1
123
12345
1234567

Q.74   number pyramid:

1333
2222
3331

Q.75  number character pyramid :

1      a
21     ba
321    cba
4321   dcba
54321  edcba

Q.76  0 and 1 number triangle :

1
01
010
1010
10101

Q.77 1 and 0 pyramid :

1
01
101
0101
10101

Q.78 Square star pyramid :

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

Q.79 Rectangle star pyramid :

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

Q.80 Even-odd number star pyramid :

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

Q.81  character number pyramid :

1
A B
2 3 4
C D E F
5 6 7 8 9

Q.82 nested star pyramid :

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

Q.83 random number pyramid :

4572
572
72
2

Q.84 number design:

 1
 23
 4
 56
 7
 89
 10

Q.85 number pyramid:

1
121
1231
12341
123451

Q.86 continues number pyramid:

1
121
12321
1234321
123454321

Q.87 alternative number-star pyramid :

1
2*2
3*3*3
4*4*4*4
4*4*4*4
3*3*3
2*2
1

Q.88 diagonal star-zero pyramid :

*000000
0*00000
00*0000
000*000
0000*00
00000*0
000000*

Q.89 geometric sequence pyramid :

 7
 14 15
 28 29 30 31
 56 57 58 59 60 61 62 63

Q.90 nested pyramid :

#####*#####
####*#*####
###*###*###
##*#####*##
#*#######*#
*#########*

Q.91 half-square number triangle :

543212345
 4321234
  32123
   212
    1

Q.92 equilateral triangle number :

     5
    454
   34543
  2345432
 123454321

Q.93 positive-negative number triangle :

9 
8  6
7  5  3
4  2  0 -2
1 -1 -3 -5 -7

Q.94 Star-Zero nested pattern:

*000*000*
0*00*00*0
00*0*0*00
000***000

Q.95 continuous vertical number pyramid:

1
2  7
3  8 13
4  9 14 19 
5 10 15 20 25

Q.96 Nested number character pyramid:

A
1
BB
22
CCC
333

Q.97 two symbol pyramid:

$
#
$$
##
$$$
###

Q.98 Square number pyramid :

1
1 4 9
1 4 9 16 25
1 4 9 16 25 36 49
1 4 9 16 25 36 49 64 81

Q.99 Arrow head pyramid :

1234
 12345
   123456
    1234567
   123456
 12345
1234

Q.100 The hexagon pattern

  ____        ____        ____
 /    \      /    \      /    \
/      \____/      \____/      \
\      /    \      /    \      /  
 \____/      \____/      \____/ 
 /    \      /    \      /    \
/      \____/      \____/      \
\      /    \      /    \      /    
 \____/      \____/      \____/  
 /    \      /    \      /    \ 
/      \____/      \____/      \
\      /    \      /    \      /
 \____/      \____/      \____/    

Source : cprogrammingcodes.blogspot.com