Diamond Crystal
Given an integer value
N, write a program to print a diamond pattern of 2*N rows as shown below.
You are given a word W as input. Print W by adding a hyphen (-) between each letter in the word.
In the given example, the word is
Hello.So, the output should be H-e-l-l-o.
Zig-Zag Order in Matrix
you are given a matrix of dimensions M * N . print the numbers of the matrix in the zig-zag order.
Zig-Zag order of the matrix.
start from the first element in the first row of the matrix and print all the numbers in the first row.
after reaching the end of the first row , move to the last element in the next row and start printing the numbers from the right side of the second line until you reach the first element in the second line .
Now jump to the first element in the third row and repeat the above process.
Sample input:
4 4
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
SAMPLE OUTPUT :
1 2 3 4 8 7 6 5 9 10 11 12 16 15 14 13
SAMPLE INPUT:
3 4
1 2 3 4
10 11 12 5
9 8 7 6
SAMPLE OUTPUT :
1 2 3 4 5 12 11 10 9 8 7 6
Diamond Crystal:
Given an integer value N, write a program to print a diamond pattern of 2*N rows as shown below.
Input
The first line of input is an integer N.
Explanation
In the given example, the number of rows in the diamond is
2*5 = 10.So, the output should be
/\
/ \
/ \
/ \
/ \
\ /
\ /
\ /
\ /
\/
Sample Input 1
5
Sample Output 1
/\
/ \
/ \
/ \
/ \
\ /
\ /
\ /
\ /
\/
Sample Input 2
3
Sample Output 2
/\
/ \
/ \
\ /
\ /
\/
Maximum:
You are given N number of inputs. Print the maximum of them after each input.
Input
The first line of input is an integer N. The next N lines each contain an integer as input.
Explanation
In the example, you are given
6 inputs 1, 0, 3, 2, 9, 8.
1 is maximum in the input 1.
1 is maximum in the input 1, 0.
3 is maximum in the input 1, 0, 3.
3 is maximum in the input 1, 0, 3, 2.
9 is maximum in the input 1, 0, 3, 2, 9.
9 is maximum in the input 1, 0, 3, 2, 9, 8.
So, the output should be
1
3
3
9
9
Sample Input 1
6
1
3
2
9
8
Sample Output 1
1
1
3
3
9
9
Sample Input 2
5
1
2
3
4
5
Sample Output 2
1
2
3
4
5
Hyphenate Letters:
You are given a word W as input. Print W by adding a hyphen (-) between each letter in the word.
Input
The first line of input is a string W.
Explanation
In the given example, the word is Hello.
So, the output should be
H-e-l-l-o.
Sample Input 1
Hello
Sample Output 1
H-e-l-l-o
Sample Input 2
Everyone
Sample Output 2
E-v-e-r-y-o-n-e
Last half of List:
You are given an integer N as input. Write a program to read N inputs and print a list containing the elements in the last half of the list.
Input:
The first line of input is an integer N. The second line contains N space-separated integers.
Explanation
In the example, we are given
6 numbers 1, 2, 3, 4, 5, 6 as input.
The last half of elements of the list are 4, 5, 6. So, the output should be [4, 5, 6].
Sample Output 2
In the example, we are given
5 numbers 1, 11, 13, 21, 19 as input. The last half of elements of the list are 21, 19. So, the output should be [21, 19].
Sample Input 1
6
1 2 3 4 5 6
Sample Output 1
[4, 5, 6]
Sample Input 2
5
1 11 13 21 19
Sample Output 2
[21, 19]
Trapezium Order
you are given an integer N . print N rows starting from 1 in the trapexium order as shown in the output of the below examples .
Input
the input contains an integer N
OUTPUT
the output should have N lines
each of the N lines should have space -seperated integers as per the trapezium order
SAMPLE INPUT 1
4
SAMPLE OUTPUT 1
1 2 3 4 17 18 19 20
5 6 7 14 15 16
8 9 12 13
10 11
Given an integer N, write a program which reads N inputs and prints the product of the given input integers.by using while loop
Given a string, write a program to return the sum and average of the digits of all numbers that appear in the string, ignoring all other characters.