You are given an integer, M. Your task is to print a pattern of alphabets.
Different sizes of the pattern are shown below:
#size 2
--b--
b-a-b
--b--
#size 5
--------e--------
------e-d-e------
----e-d-c-d-e----
--e-d-c-b-c-d-e--
e-d-c-b-a-b-c-d-e
--e-d-c-b-c-d-e--
----e-d-c-d-e----
------e-d-e------
--------e--------
#size 9
----------------i----------------
--------------i-h-i--------------
------------i-h-g-h-i------------
----------i-h-g-f-g-h-i----------
--------i-h-g-f-e-f-g-h-i--------
------i-h-g-f-e-d-e-f-g-h-i------
----i-h-g-f-e-d-c-d-e-f-g-h-i----
--i-h-g-f-e-d-c-b-c-d-e-f-g-h-i--
i-h-g-f-e-d-c-b-a-b-c-d-e-f-g-h-i
--i-h-g-f-e-d-c-b-c-d-e-f-g-h-i--
----i-h-g-f-e-d-c-d-e-f-g-h-i----
------i-h-g-f-e-d-e-f-g-h-i------
--------i-h-g-f-e-f-g-h-i--------
----------i-h-g-f-g-h-i----------
------------i-h-g-h-i------------
--------------i-h-i--------------
----------------i----------------
The center of the pattern has the first alphabet letter a, and the boundary has the Mᵗʰ alphabet letter (in alphabetical order).
Input Format
Only one line of input containing M, the size of the pattern.
Constraints
0 < M < 27
Output Format
Print the alphabet pattern in the format explained above.
Sample Input
5
Sample Output
--------e--------
------e-d-e------
----e-d-c-d-e----
--e-d-c-b-c-d-e--
e-d-c-b-a-b-c-d-e
--e-d-c-b-c-d-e--
----e-d-c-d-e----
------e-d-e------
--------e--------
Kabir and you are friends. Yesterday, Kabir received N credit cards from The State Bank of India. He wants to check whether his credit card numbers are valid or not. You happen to be great at regex so he is asking for your help!
A valid credit card from The State Bank of India has the following criteria:
Must start with a 4, 5 or 6.
Must contain exactly 16 digits.
Must comprise only digits (0-9). May have digits in groups of 4, separated by one hyphen "-".
Must begin and end with a digit (NOT hyphen).
Must NOT use any other separator like ' ', '_', etc.
Must NOT have 4 or more consecutive repeated digits.
Examples:
Valid Credit Card Numbers
4654783974552373
6766689007007890
5986-4447-7784-9087
Invalid Credit Card Numbers
0648392645488373 #Does not start with 4, 5 or 6 → Invalid
54638397473839447 #17 digits in card number → Invalid
99455567v8889888 #Contains non-digit characters → Invalid
4567-8743-2345 - 1234 #Separators (“ “) other than '-' are used → Invalid
4567-7779-6589-6838 #Same digit(7) is being repeated 4 or more times consecutively → Invalid
Input Format
The first line contains an integer N.
The next N lines contain credit card numbers.
Constraints
0<N<100
Output Format
Print 'Valid' if the credit card number is valid. Otherwise, print 'Invalid'.
Do not print the quotes.
Sample Input
7
4547382364748736
5746-5467-8826-8378
54678-768-8560-5432
5756849474553445
6299-9976-8790-3245
4567 - 5678 - 9876 – 4322
74647364363664747
Sample Output
Valid
Valid
Invalid
Valid
Invalid
Invalid
Invalid
Explanation
4547382364748736: Valid
5746-5467-8826-8378: Valid
54678-768-8560-5432: Invalid (because the card number is not divided into equal groups of 4 digits).
5756849474553445: Valid
6299-9976-8790-3245: Invalid (because consecutive digits 9999 is repeating 4 times).
4567 - 5678 - 9876 – 4322: Invalid (because space ' ' and -- are used as separators).
74647364363664747: Invalid (because it has 17 digits).
PQR is a right triangle, 90⁰ at Q.
Therefore, Angle PQR= 90⁰.
Point M is the midpoint of hypotenuse PR.
The lengths of PQ and QR are given.
You have to find Angle MQR (angle Θ, as shown in the figure) in degrees.
Note: QM is the median. Angle QMR may or may not be equal to 90⁰
Input Format
The first line contains the length of side PQ.
The second line contains the length of side QR.
Constraints
0< PQ ≤ 100
0< QR ≤ 100
Lengths PQ and QR are natural numbers.
Output Format
Angle MQR in degrees.
Note: Round the angle to the nearest integer.
Examples:
If angle is 45.50001°, then output 46°.
If angle is 66.50000°, then output 67°.
If angle is 22.49999°, then output 22°.
0⁰ < θ⁰ < 90⁰
Sample Input 1
10
10
Sample Output 1
45
Sample Input 2
6
8
Sample Output 2
37
HINT: 1. The median drawn to the hypotenuse of a right angled triangle equals half the hypotenuse.
2. Cosine law: cos(A) = (b² + c² - a²)/(2bc)
[a= side opposite angle A, b= side opposite angle B, c= side opposite angle C]
You are given three integers x, y and z representing the dimensions of a cuboid along with an integer, N.
TASK
Print a list of all possible coordinates given by (i, j, k) where the sum, (i + j + k) is not equal to N.
Here,
0 ≤ i ≤ x
0 ≤ j ≤ y
0 ≤ k ≤ z.
[HINT: Use List Comprehensions]
Example
x = 1
y = 1
z = 3
n = 3
All permutations of [i, j, k] are:
[[0, 0, 0], [0, 0, 1], [0, 0, 2], [0, 0, 3], [0, 1, 0], [0, 1, 1], [0, 1, 2], [0, 1, 3], [1, 0, 0], [1, 0, 1], [1, 0, 2], [1, 0, 3], [1, 1, 0], [1, 1, 1], [1, 1, 2], [1, 1, 3]]
Print an array of the elements that do not sum to N = 3.
[[0, 0, 0], [0, 0, 1], [0, 0, 2], [0, 1, 0], [0, 1, 1], [0, 1, 3], [1, 0, 0], [1, 0, 1], [1, 0, 3], [1, 1, 0], [1, 1, 2], [1, 1, 3]]
Input Format
Four integers x, y, z and N, each on a separate line.
Constraints
Print the list in lexicographic increasing order.
Sample Input 0
1
1
0
2
Sample Output 0
[[0, 0, 0], [0, 1, 0], [1, 0, 0]]
Explanation 0
Each variable x, y and z will have values of 0 or 1. All permutations of lists in the form
[i, j, k] = [[0, 0, 0], [0, 1, 0], [1, 0, 0], [1, 1, 0]]
Remove all lists that sum to N=2 to leave only the valid permutations.
Sample Input 1
2
2
2
2
Sample Output 1
[[0, 0, 0], [0, 0, 1], [0, 1, 0], [0, 1, 2], [0, 2, 1], [0, 2, 2], [1, 0, 0], [1, 0, 2], [1, 1, 1], [1, 1, 2], [1, 2, 0], [1, 2, 1], [1, 2, 2], [2, 0, 1], [2, 0, 2], [2, 1, 0], [2, 1, 1], [2, 1, 2], [2, 2, 0], [2, 2, 1], [2, 2, 2]]
You are given a function f(x) = x².
You are also given P lists/arrays.
The i ͭ ͪ list/array consists of Ni elements.
You have to pick one element from each list/array so that the value from the equation below is maximized:
A = (f(x1) + f(x2) + … + f(xP) ) % Q
Xi denotes the element picked from the i ͭ ͪ list .
Find the maximized value, Amax obtained.
% denotes the modulo operator.
NOTE: You need to take exactly one element from each list/array.
You add the squares of the chosen elements and perform the modulo operation.
The maximum value that you can obtain, will be the answer to the problem.
Input Format
The first line contains 2 space separated integers P and Q.
The next P lines each contains:
An integer Ni, denoting the number of elements in the i ͭ ͪlist,
followed by Ni space separated integers denoting the elements in the list/array.
Constraints
1 ≤ P ≤ 7
1 ≤ Q ≤ 100
1 ≤ Ni ≤ 7
1 ≤ Magnitude of elements in list ≤ 10^3
Output Format
A single integer denoting the value Amax.
Sample Input
3 100
2 6 7
3 8 0 3
6 5 7 8 11 10 20
Sample Output
13
Explanation
Picking 7 from the 1st list/array, 8 from the 2nd list/array and 20 from the 3rd list/array gives the maximum A value equal to (7² + 8² + 20²) % 100 = 13