├── README.md ├── Interesting Alphabets.py └── Total Salary.py /README.md: -------------------------------------------------------------------------------- 1 | # 6-Month-Code-Marathon---1 -------------------------------------------------------------------------------- /Interesting Alphabets.py: -------------------------------------------------------------------------------- 1 | """Problem statement 2 | As a part of its competition, the school will conduct a codeathon, Lock the Code, where it has been given a value, and the participants have to decode it. 3 | 4 | The participants are given a value denoting the number of rows in the matrix; they need to print the pattern. 5 | 6 | Example : 7 | 8 | For N=5, Pattern: 9 | E 10 | DE 11 | CDE 12 | BCDE 13 | ABCDE 14 | Among the participants, Ninja is new to programming and doesn’t have much experience; he asks you to solve the problem. Can you help solve this problem? 15 | 16 | Detailed explanation ( Input/output format, Notes, Images ) 17 | Constraints: 18 | 1 <= T <= 50 19 | 1 <= N <= 26 20 | 21 | Time Limit: 1 sec 22 | Sample Input 1: 23 | 2 24 | 5 25 | 4 26 | Sample Output 1: 27 | E 28 | DE 29 | CDE 30 | BCDE 31 | ABCDE 32 | 33 | D 34 | CD 35 | BCD 36 | ABCD 37 | Explanation for Sample Input 1: 38 | In the first test case, value of ‘N’ is 5, so print the ‘N’ rows from 1 to ‘N’ where in each row start from (N - i - 1)the character which goes on till ‘Nth character. Hence the answer is [‘E’,’DE’,’CDE,’ BCDE’,’ABCDE’]. 39 | 40 | In the second test case, the value of ‘N’ is 4, so print the ‘N’ rows from 1 to ‘N’ where each row starts from (N - i - 1)the character, which goes on till ‘Nth character. Hence the answer is [‘D’,’CD’,BCD’,’ABCD’]. 41 | Sample Input 2: 42 | 2 43 | 3 44 | 2 45 | Sample Output 2: 46 | C 47 | BC 48 | ABC 49 | 50 | B 51 | AB""" 52 | 53 | def interestingPattern(n): 54 | result = [] 55 | for i in range(n): 56 | start_char = chr(ord('A') + n - i - 1) 57 | row = ' '.join([chr(j) for j in range(ord(start_char), ord('A') + n)]) 58 | result.append(row) 59 | return result 60 | -------------------------------------------------------------------------------- /Total Salary.py: -------------------------------------------------------------------------------- 1 | """Problem statement 2 | Ninja just got an offer letter from a reputable company. The company sent him an offer letter along with the salary bifurcation. 3 | 4 | In that bifurcation,Total Salary was not mentioned but instead a ‘basicSalary’ and an upper case character representing grade was mentioned, depending on which the Total Salary is calculated. 5 | 6 | Help Ninja in calculating his total salary, where total salary is defined as: 7 | 8 | ‘totalSalary’ = ‘basic’ + ‘hra’ + ‘da’ + ‘allowance’ - ‘pf’ 9 | The above terms are as follows: 10 | 11 | ‘hra’ = 20% of ‘basic’ 12 | ‘da’ = 50% of ‘basic’ 13 | ‘allowance’ = 1700 if grade = ‘A’ 14 | ‘allowance’ = 1500 if grade = ‘B’ 15 | ‘allowance’ = 1300 if grade = ‘C' or any other character 16 | ‘pf’ = 11% of ‘basic’. 17 | Note : 18 | 19 | Round off the ‘totalSalary’ and then print the integral part only. 20 | 21 | 'x.5' type values will always be round up, for example, 1.5, 2.5 will be round off to 2, 3 respectively. 22 | Detailed explanation ( Input/output format, Notes, Images ) 23 | Constraints : 24 | 0 <= 'basicSalary' <= 7 * (10 ^ 5) 25 | 26 | Time Limit: 1 sec. 27 | Sample Input 1 : 28 | 2 29 | 10000 A 30 | 4567 B 31 | Sample Output 1 : 32 | 17600 33 | 8762 34 | Explanation for Sample Input 1: 35 | Test Case 1: 36 | We have been given the basic salary as Rs. 10000. We need to calculate the hra, da and pf. 37 | Now when we calculate each of the, it turns out to be: 38 | hra = 20% of Rs. 10000 = Rs. 2000 39 | da = 50% od Rs. 10000 = Rs. 5000 40 | pf = 11% of Rs. 10000 = Rs. 1100 41 | 42 | Since, the grade is 'A', we take an allowance of Rs. 1700. 43 | On substituting these values to the formula of totalSalary, we get Rs. 17600 and now rounding it off will result in Rs. 17600 and hence the Answer. 44 | 45 | Test Case 2: 46 | We have been given the basic salary as Rs. 4567. We need to calculate the hra, da and pf. 47 | Now when we calculate each of the, it turns out to be: 48 | hra = 20% of Rs. 4567 = Rs. 913.4 49 | da = 50% od Rs. 4567 = Rs. 2283.5 50 | pf = 11% of Rs. 4567 = Rs. 502.37 51 | 52 | Since, the grade is 'B', we take an allowance of Rs. 1500. 53 | On substituting these values to the formula of totalSalary, we get Rs. 8761.53 and now rounding it off will result in Rs. 8762 and hence the Answer. 54 | Sample Input 2 : 55 | 2 56 | 1500 B 57 | 5000 C 58 | Sample Output 2 : 59 | 3885 60 | 9250 """ 61 | 62 | 63 | 64 | 65 | from math import floor 66 | 67 | def totalSalary(basic, grade): 68 | hra = 0.2 * basic 69 | da = 0.5 * basic 70 | pf = 0.11 * basic 71 | 72 | if grade == 'A': 73 | allowance = 1700 74 | elif grade == 'B': 75 | allowance = 1500 76 | else: 77 | allowance = 1300 78 | 79 | total = basic + hra + da + allowance - pf 80 | return floor(total + 0.5) # Round .5 up 81 | --------------------------------------------------------------------------------