├── .gitignore
├── Alexander_theGreat
├── README.md
├── alexanderTheGreat.pdf
└── alexanderTheGreat.py
├── Bank_Compare
├── README.md
├── bankCompare.pdf
└── bankCompare.py
├── Bride_Hunting
├── README.md
├── brideHunting.pdf
└── brideHunting.py
├── Chakravyuha
├── README.md
├── chakravyuha.pdf
└── chakravyuha.py
├── Coin_required
├── README.md
├── coinRequired.pdf
└── coinRequired.py
├── Colliding_Canons
├── README.md
├── collidingCanons.pdf
└── collidingCanons.py
├── Distribute_books
├── README.md
├── distributeBooks.pdf
└── distributeBooks.py
├── Hospital_Revenue
├── README.md
├── hospitalRevenue.pdf
└── hospitalRevenue.py
├── Jurassic_Park
├── README.md
├── jurassicPark.pdf
└── jurassicPark.py
├── Lexi_string
├── README.md
├── lexiString.pdf
└── lexiString.py
├── Philaland_coins
├── README.md
├── philalandCoins.pdf
└── philalandCoins.py
├── README.md
├── String_Rotation
├── README.md
├── stringRotation.pdf
└── stringRotation.py
├── accicoEquiPairs
├── README.md
├── accicoEquiPairs.py
└── accioEquiPairs.pdf
├── catch22
├── README.md
├── catch22.pdf
└── catch22.py
├── christmasTree
├── README.md
├── christmasTree.pdf
└── christmasTree.py
├── collectingCandies
├── README.md
├── collectingCandies.pdf
└── collectingCandies.py
├── islSchedule
├── README.md
├── islSchedule.pdf
└── islSchedule.py
├── isotopeFusion
├── isotopeFusion.pdf
└── isotopeFusion.py
├── logicPyramid
├── README.md
├── logicPyramid.pdf
└── logicPyramid.py
├── mfTracker
├── README.md
├── mfTracker.pdf
└── mfTracker.py
├── minProductArray
├── README.md
├── minProductArray.pdf
└── minProductArray.py
├── minimumDistance
├── README.md
├── minimumDistance.pdf
└── minimumDistance.py
├── reverseGear
├── README.md
├── reverseGear.pdf
└── reverseGear.py
├── sheldonCooper
├── README.md
├── sheldonCooper.pdf
└── sheldonCooper.py
├── skateBoard
├── README.md
├── skateBoard.pdf
└── skateBoard.py
├── stoneGame
├── README.md
├── stoneGame.pdf
└── stoneGame.py
├── superAsciiStringChecker
├── README.md
├── superAsciiStringChecker.pdf
└── superAsciiStringChecker.py
├── theGameOfMarbles
├── README.md
├── theGameOfMarbles.pdf
└── theGameOfMarbles.py
├── theMysteryOfSky
├── README.md
├── theMysteryOfSky.pdf
└── theMysteryOfSky.py
├── theVitaSum
├── README.md
├── theVitaSum.pdf
└── theVitaSum.py
├── traceTheRats
├── README.md
├── tempCodeRunnerFile.py
├── traceTheRats.pdf
└── traceTheRats.py
├── whereMyCar
├── README.md
├── wheresMyCar.pdf
└── wheresMyCar.py
└── zombieWorld
├── README.md
├── zombieWorld.pdf
└── zombieWorld.py
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | build/
12 | develop-eggs/
13 | dist/
14 | downloads/
15 | eggs/
16 | .eggs/
17 | lib/
18 | lib64/
19 | parts/
20 | sdist/
21 | var/
22 | wheels/
23 | pip-wheel-metadata/
24 | share/python-wheels/
25 | *.egg-info/
26 | .installed.cfg
27 | *.egg
28 | MANIFEST
29 |
30 | # PyInstaller
31 | # Usually these files are written by a python script from a template
32 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
33 | *.manifest
34 | *.spec
35 |
36 | # Installer logs
37 | pip-log.txt
38 | pip-delete-this-directory.txt
39 |
40 | # Unit test / coverage reports
41 | htmlcov/
42 | .tox/
43 | .nox/
44 | .coverage
45 | .coverage.*
46 | .cache
47 | nosetests.xml
48 | coverage.xml
49 | *.cover
50 | *.py,cover
51 | .hypothesis/
52 | .pytest_cache/
53 |
54 | # Translations
55 | *.mo
56 | *.pot
57 |
58 | # Django stuff:
59 | *.log
60 | local_settings.py
61 | db.sqlite3
62 | db.sqlite3-journal
63 |
64 | # Flask stuff:
65 | instance/
66 | .webassets-cache
67 |
68 | # Scrapy stuff:
69 | .scrapy
70 |
71 | # Sphinx documentation
72 | docs/_build/
73 |
74 | # PyBuilder
75 | target/
76 |
77 | # Jupyter Notebook
78 | .ipynb_checkpoints
79 |
80 | # IPython
81 | profile_default/
82 | ipython_config.py
83 |
84 | # pyenv
85 | .python-version
86 |
87 | # pipenv
88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not
91 | # install all needed dependencies.
92 | #Pipfile.lock
93 |
94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow
95 | __pypackages__/
96 |
97 | # Celery stuff
98 | celerybeat-schedule
99 | celerybeat.pid
100 |
101 | # SageMath parsed files
102 | *.sage.py
103 |
104 | # Environments
105 | .env
106 | .venv
107 | env/
108 | venv/
109 | ENV/
110 | env.bak/
111 | venv.bak/
112 |
113 | # Spyder project settings
114 | .spyderproject
115 | .spyproject
116 |
117 | # Rope project settings
118 | .ropeproject
119 |
120 | # mkdocs documentation
121 | /site
122 |
123 | # mypy
124 | .mypy_cache/
125 | .dmypy.json
126 | dmypy.json
127 |
128 | # Pyre type checker
129 | .pyre/
130 |
--------------------------------------------------------------------------------
/Alexander_theGreat/README.md:
--------------------------------------------------------------------------------
1 | # Alexander The Great
2 |
3 | The question was asked in Codevita Examination 2019
4 |
5 | ## Problem Statement
6 |
7 | Alexander The great, while roaming the stretch of Turkey, came across a wise man. He asked the wise man, "Who is the greatest conqueror of all?". The wise man replied, "A person with great strength and intelligence. Whosoever can solve my puzzle will go on to become the greatest!".
8 |
9 | The puzzle is as follows:
10 |
11 | Given two integers **'n1'** and **'n2'**, select two integers **'a'** and **'b'**, such as to solve the equation **(n1 * a + n2 * b = x)**. But there is a catch, **'x'** is the smallest positive integer which satisfies the equation. Can you help Alexander become the greatest?
12 |
13 | ## Explanation
14 |
15 | The question is the linear Diophantine equation. The diophantine equation is the equation in which only the equation is provided and two or more unknowns are needed to find. But, the Diophantine equation is solvable only when the **x** is multiple of **gcd** of **a** ( intercept of n1 ) and **b** ( intercept of n2 ). Either **smallest multiple** is the required solution of the given question or **gcd** is the solution ( whichever is the smallest ).
16 |
17 | ```\Alexander_theGreat> python alexanderTheGreat.py```
18 |
19 | ```784525```
20 |
21 | ```09645```
22 |
23 | Output :
24 |
25 | ```5```
26 |
27 |
28 | ### [For More details](https://en.wikipedia.org/wiki/Diophantine_equation)
--------------------------------------------------------------------------------
/Alexander_theGreat/alexanderTheGreat.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deepspraj/CodeVita-Exam/513274f1e9733e5b96a78de0f3a65a30df9d9284/Alexander_theGreat/alexanderTheGreat.pdf
--------------------------------------------------------------------------------
/Alexander_theGreat/alexanderTheGreat.py:
--------------------------------------------------------------------------------
1 | ##
2 | # @author Deepak Prajapati
3 | # @email deepprajapati01@gmail.com
4 | # @create date 2020-06-27 13:21:08
5 | # @modify date 2020-06-27 13:21:08
6 | ##
7 |
8 | import math
9 | import os
10 |
11 |
12 | a = int(input())
13 | b = int (input())
14 |
15 | result = math.gcd(a,b)
16 |
17 | print(result)
18 |
19 | os.system("Pause")
20 |
--------------------------------------------------------------------------------
/Bank_Compare/README.md:
--------------------------------------------------------------------------------
1 | # Bank Comparison
2 |
3 | The question was asked in Codevita Examination 2019
4 |
5 | ## Problem Statement
6 |
7 | There are two banks; Bank A and Bank B. Their interest rates vary. You have received offers from both bank in terms of annual rate of interest, tenure and variations of rate of interest over the entire tenure.
8 |
9 | You have to choose the offer which costs you least interest and reject the other.
10 |
11 | Do the computation and make a wise choice.
12 |
13 | The loan repayment happens at a monthly frequency and Equated Monthly Installment (EMI) is calculated using the formula given below :
14 |
15 | EMI = (loanAmount * monthlyInterestRate )/( 1 - 1 / (1 + monthlyInterestRate)^(numberOfYears * 12))
16 |
17 | ## Explanation
18 |
19 | Find EMI for every slot of bank A and bank B.
20 |
21 | Sum all the EMI's for bank A and bank B respectively.
22 |
23 | Compare both the EMI and get the result.
24 |
25 |
26 |
27 |
28 | ```\Bank_Compare>python bankCompare.py```
29 |
30 | ```500000```
31 |
32 | ```20```
33 |
34 | ```3```
35 |
36 | ```10 9.5```
37 |
38 | ```5 9.0```
39 |
40 | ```5 6.8```
41 |
42 | ```2```
43 |
44 | ```10 9.2```
45 |
46 | ```10 5.6```
47 |
48 | Output :
49 |
50 | ```Bank B```
51 |
--------------------------------------------------------------------------------
/Bank_Compare/bankCompare.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deepspraj/CodeVita-Exam/513274f1e9733e5b96a78de0f3a65a30df9d9284/Bank_Compare/bankCompare.pdf
--------------------------------------------------------------------------------
/Bank_Compare/bankCompare.py:
--------------------------------------------------------------------------------
1 | ##
2 | # @author Deepak Prajapati
3 | # @email deepprajapati01@gmail.com
4 | # @create date 2020-07-01 15:28:22
5 | # @modify date 2020-07-01 15:28:22
6 | ##
7 |
8 |
9 | import os
10 |
11 | principal = int(input())
12 | tenure = int(input())
13 |
14 | def emi_calcultor (principal,years,rate):
15 | factor = pow(1+(rate/1200),(years*12))
16 | emi = (principal *(rate/1200))/(1 - (1/factor))
17 | return emi
18 |
19 | def calculator(principal, tenure):
20 | interest_slabs_bank_a = interest_slabs_bank_b = []
21 | sum = [0 , 0]
22 | slabs_of_bank_a = int(input())
23 | for i in range (0 , slabs_of_bank_a):
24 | interest_slabs_bank_a = interest_slabs_bank_a + input().split(" ")
25 |
26 | slabs_of_bank_b = int(input())
27 | for i in range (0 , slabs_of_bank_b):
28 | interest_slabs_bank_b = interest_slabs_bank_b + input().split(" ")
29 |
30 | interest_slabs_bank_a = list(map(float,interest_slabs_bank_a))
31 | interest_slabs_bank_b = list(map(float,interest_slabs_bank_b))
32 |
33 | for i in range (0,2):
34 | if(i == 0):
35 | count = slabs_of_bank_a
36 | rater = interest_slabs_bank_a
37 | else:
38 | count = slabs_of_bank_b
39 | rater = interest_slabs_bank_b
40 | for j in range (0,count):
41 | temp = emi_calcultor(principal,rater[(2*j)],rater[(2*j)+1])
42 | sum[i] = sum[i] + temp
43 | return sum
44 |
45 | emis = calculator(principal , tenure)
46 |
47 | if (emis[0] python brideHunting.py```
37 |
38 | ```6 6```
39 |
40 | ```1 0 0 0 0 0```
41 |
42 | ```0 0 1 1 1 0```
43 |
44 | ```0 0 1 1 1 0```
45 |
46 | ```0 0 1 1 1 0```
47 |
48 | ```0 0 1 1 1 0```
49 |
50 | ```0 0 1 1 1 0```
51 |
52 | Output :
53 |
54 | ```3:4:8```
55 |
--------------------------------------------------------------------------------
/Bride_Hunting/brideHunting.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deepspraj/CodeVita-Exam/513274f1e9733e5b96a78de0f3a65a30df9d9284/Bride_Hunting/brideHunting.pdf
--------------------------------------------------------------------------------
/Bride_Hunting/brideHunting.py:
--------------------------------------------------------------------------------
1 | ##
2 | # @author Deepak Prajapati
3 | # @email deepprajapati01@gmail.com
4 | # @create date 2020-06-28 14:47:35
5 | # @modify date 2020-06-28 14:47:35
6 | ##
7 |
8 | import os
9 |
10 | no_of_row, no_of_col = map(int,input().split(" "))
11 | matrix = []
12 | my_dict = {}
13 |
14 | def total_qualities(matrix,row,col,my_dict):
15 | count = temp = 0
16 | if(matrix[row][col]==1):
17 | for i in range (row -1 , row +2):
18 | for j in range (col -1, col +2 ):
19 | if(i>=0 and j>=0):
20 | try:
21 | if (i==row and j==col):
22 | temp = 0
23 | else:
24 | temp = matrix[i][j]
25 | except:
26 | temp = 0
27 | else:
28 | temp = 0
29 | count = count + temp
30 | index = str(row+1) + ":" + str(col+1) + ":" + str(count)
31 | my_dict[index] = count
32 |
33 | def calculator(no_of_row,no_of_col,matrix,my_dict):
34 | for i in range (0,no_of_row):
35 | arr = input().split(" ")
36 | arr = list(map(int,arr))
37 | matrix.append(arr)
38 |
39 | for row in range(0,no_of_row):
40 | for col in range (0,no_of_col):
41 | total_qualities(matrix,row,col,my_dict)
42 |
43 | ans = max(my_dict, key=my_dict.get)
44 | print(ans)
45 |
46 |
47 | if ((0
26 |
27 |
28 | ```\Chakravyuha> python chakravyuha.py```
29 |
30 | ```4```
31 |
32 | Output :
33 |
34 | ```1 2 3 4```
35 |
36 | ```12 13 14 5```
37 |
38 | ```11 16 15 6```
39 |
40 | ```10 9 8 7```
41 |
42 | ```Total Power points : 2```
43 |
44 | ```(0,0)```
45 |
46 | ```(2,0)```
47 |
--------------------------------------------------------------------------------
/Chakravyuha/chakravyuha.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deepspraj/CodeVita-Exam/513274f1e9733e5b96a78de0f3a65a30df9d9284/Chakravyuha/chakravyuha.pdf
--------------------------------------------------------------------------------
/Chakravyuha/chakravyuha.py:
--------------------------------------------------------------------------------
1 | ##
2 | # @author Deepak Prajapati
3 | # @email deepprajapati01@gmail.com
4 | # @create date 2020-07-07 16:15:06
5 | # @modify date 2020-07-07 16:15:06
6 | ##
7 |
8 |
9 |
10 | import os
11 |
12 | n = int(input())
13 |
14 | def chakravyuha(n):
15 | points = 0
16 | points_location = []
17 | b = d = n
18 | matrix = [[0 for j in range(b)] for i in range(b)]
19 | num = 1
20 |
21 | # a - starting index of row
22 | # b - ending index of row
23 | # c - starting index of column
24 | # d - ending index of column
25 |
26 | a, c = 0, 0
27 | while (a < b and c < d):
28 | # Print the first row from the remaining rows.
29 | for i in range (c, d):
30 | matrix[a][i] = num
31 | num += 1
32 |
33 | a += 1
34 |
35 | # Print the last column from the remaining columns.
36 | for j in range (a, b):
37 | matrix[j][d-1] = num
38 | num += 1
39 | d -= 1
40 |
41 | # Print the last row from the remaining rows.
42 | if (a < b):
43 | for i in range (d-1,c-1, -1):
44 | matrix[b-1][i] = num
45 | num += 1
46 | b -= 1
47 |
48 | # Print the first column from the remaining columns.
49 | if (c < d):
50 | for i in range (b-1,a-1,-1):
51 | matrix[i][c] = num
52 | num += 1
53 | c += 1
54 |
55 |
56 | for i in range (0 , n):
57 | for j in range (0, n):
58 | value = matrix [i][j]
59 | if((value%11) == 0):
60 | points += 1
61 | location = "(" + str(i) + "," + str(j) + ")"
62 | points_location.append(location)
63 | elif( i == j == 0):
64 | points += 1
65 | location = "(" + str(i) + "," + str(j) + ")"
66 | points_location.append(location)
67 |
68 | for i in range (0 , n):
69 | for j in range (0,n):
70 | print(matrix[i][j], end=' ')
71 | print()
72 |
73 | print()
74 | print("Total Power points : " + str(points))
75 | print()
76 |
77 | for i in range (0, len(points_location)):
78 | print(points_location[i])
79 | i += 1
80 |
81 | if (0 < n <= 100):
82 | chakravyuha(n)
83 | os.system('Pause')
84 | else:
85 | exit()
--------------------------------------------------------------------------------
/Coin_required/README.md:
--------------------------------------------------------------------------------
1 | # Coins Required
2 |
3 | The question was asked in Codevita Examination 2019
4 |
5 | ## Problem Statement
6 |
7 | Find minimum number of coins required to form any value between **1** to **N**, both inclusive. Cumulative value of coins should not exceed **N**. Coin denominations are **1 Rupee**, **2 Rupee** and **5 Rupee**.
8 |
9 | ## Explanation
10 |
11 | Consider value of **N** is **13**, then the minimum number of coins required to formulate any value between **1** and **13**, is **6**. **One 5 Rupee**, **three 2 Rupee** and **two 1 Rupee** coins are required to realize any value between **1** and **13**.
12 |
13 | ```\Coin_required>python coinRequired.py```
14 |
15 | ```3```
16 |
17 | ```65```
18 |
19 | ```98```
20 |
21 | ```53```
22 |
23 | Output :
24 |
25 | ```15 12 2 1```
26 |
27 | ```23 18 3 2```
28 |
29 | ```14 9 3 2 ```
--------------------------------------------------------------------------------
/Coin_required/coinRequired.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deepspraj/CodeVita-Exam/513274f1e9733e5b96a78de0f3a65a30df9d9284/Coin_required/coinRequired.pdf
--------------------------------------------------------------------------------
/Coin_required/coinRequired.py:
--------------------------------------------------------------------------------
1 | ##
2 | # @author Deepak Prajapati
3 | # @email deepprajapati01@gmail.com
4 | # @create date 2020-06-27 13:19:14
5 | # @modify date 2020-06-27 13:19:14
6 | ##
7 |
8 | import os
9 | no_of_cases = int(input())
10 | amount = []
11 |
12 |
13 | def calculator(amount):
14 | no_of_fives = (amount-5)//5
15 |
16 | if ((amount - 5 * no_of_fives)%2 == 0):
17 | no_of_ones = 2
18 | else:
19 | no_of_ones = 1
20 |
21 | no_of_twos = ((amount - 5 * no_of_fives) - no_of_ones )/2
22 | no_of_twos = int(no_of_twos)
23 | total_coins = (no_of_fives + no_of_twos + no_of_ones)
24 | print(total_coins,no_of_fives,no_of_twos,no_of_ones, end=" ")
25 | print("")
26 |
27 | for i in range (0,no_of_cases):
28 | temp = int(input())
29 | amount.append(temp)
30 |
31 | for i in range (0,no_of_cases):
32 | calculator(amount[i])
33 |
34 | os.system("Pause")
35 |
--------------------------------------------------------------------------------
/Colliding_Canons/README.md:
--------------------------------------------------------------------------------
1 | # Colliding Canons
2 |
3 | The question was asked in Codevita Examination 2017
4 |
5 | ## Problem Statement
6 |
7 | We have seen in many mythological movies, the arrows shot, by the opponents collide mid-air and one devour the other.
8 | You wanted to simulate a similar situation for the video game you are designing. In the game, the opponents are in a tunnel and have a gun each. They can shoot bullets in any direction (within limits). The roof and floor of the tunnel are perfect surfaces and any object hitting them are bounced off according to the law of reflection (angle of incidence equals the angle of reflection), with unchanged speed. For simplicity, we can assume that the tunnel is a two-dimensional horizontal strip. Of course, this being the mythological world, gravity does not exist, and the bullets travel in straight lines at constant speed until being reflected (or they collide).
9 |
10 | The two guns are positioned at half the height ( h ) of the tunnel, at a distance ( D ) apart. The two guns fire simultaneously. The trajectories of the bullets ( if extended ) will meet at a maximum of one point. They are said to collide if their trajectories meet, and the two bullets arrive at that point within 0.5 seconds of each other.
11 |
12 | ## Explanation
13 |
14 | From inputs provided by the user, we can find the coordinates of the guns.
15 |
16 | And based on provided angles by the user of the guns, we can find the angle of collision.
17 |
18 | By using, **Sine Rule** on the triangle formed between points a, b, and c we can find the hypotenuse1 and hypotenuse2.
19 |
20 | Now divide the triangle into two right-angled triangles, from the newly formed triangle we can find the coordinates of the point of collision and get the desired result.
21 |
22 | ### For more explaination look for image below
23 |
24 |
25 |
26 |
27 |
28 | ```\Colliding_Canons> python Colliding_Canons.py```
29 |
30 | ```3000,700```
31 |
32 | ```60,120,56,130```
33 |
34 | Output :
35 |
36 | ```Yes,27.164,559.169```
37 |
--------------------------------------------------------------------------------
/Colliding_Canons/collidingCanons.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deepspraj/CodeVita-Exam/513274f1e9733e5b96a78de0f3a65a30df9d9284/Colliding_Canons/collidingCanons.pdf
--------------------------------------------------------------------------------
/Colliding_Canons/collidingCanons.py:
--------------------------------------------------------------------------------
1 | ##
2 | # @author Deepak Prajapati
3 | # @email deepprajapati01@gmail.com
4 | # @create date 2020-07-04 13:05:06
5 | # @modify date 2020-07-04 13:05:06
6 | ##
7 |
8 | import os
9 | import math
10 |
11 | def ans_calculator (h,d,la,ls,ra,rs):
12 | angle3 = (180 - la - ra)
13 | angle3 = math.radians(angle3)
14 | la = math.radians(la)
15 | ra = math.radians(ra)
16 |
17 | hypo1 = (d * math.sin(ra) / math.sin(angle3))
18 | hypo2 = (d * math.sin(la) / math.sin(angle3))
19 | velo1 = (hypo1/ls)
20 | velo2 = (hypo2/rs)
21 |
22 | isit = 'No'
23 | if(abs(velo1-velo2)<=0.5):
24 | isit = 'Yes'
25 |
26 | yint = (hypo2*math.sin(ra))
27 |
28 | if (yint>int(h/2)):
29 | y = abs(yint - h)
30 | else:
31 | y = yint
32 | temp = pow(hypo2,2) - pow(yint,2)
33 | x = math.sqrt(temp)
34 |
35 | if(x<(d/2)):
36 | x = (d/2) - x
37 | else:
38 | x= x - (d/2)
39 | if(isit == 'Yes'):
40 | ans = isit + ',' + str(round(x,3)) + ',' + str(round(y,3))
41 | else:
42 | ans = isit
43 | print(ans)
44 | h , d = map(int, input().split(','))
45 | la, ls, ra, rs = map(int, input().split(','))
46 |
47 | if((-85<=la<=85) and (-85<=ra<=85) and (0
28 |
29 | ```\Distribute_books> python distributeBooks.py```
30 |
31 | ```6```
32 |
33 | Output :
34 |
35 | ```265```
36 |
37 | ### [For More details](https://en.wikipedia.org/wiki/Derangement)
--------------------------------------------------------------------------------
/Distribute_books/distributeBooks.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deepspraj/CodeVita-Exam/513274f1e9733e5b96a78de0f3a65a30df9d9284/Distribute_books/distributeBooks.pdf
--------------------------------------------------------------------------------
/Distribute_books/distributeBooks.py:
--------------------------------------------------------------------------------
1 | ##
2 | # @author Deepak Prajapati
3 | # @email deepprajapati01@gmail.com
4 | # @create date 2020-06-27 13:18:37
5 | # @modify date 2020-06-27 13:18:37
6 | ##
7 |
8 |
9 | import math
10 | import os
11 |
12 |
13 | num = int(input())
14 | num = math.factorial(num)
15 | expo =math.exp(1)
16 |
17 | temp = float(num)/float(expo)
18 | ans =round(temp)
19 |
20 | print(ans)
21 |
22 | os.system("Pause")
23 |
--------------------------------------------------------------------------------
/Hospital_Revenue/README.md:
--------------------------------------------------------------------------------
1 | # Hospital Revenue
2 |
3 | The question was asked in TCS Codevita Examination
4 |
5 | ## Problem Statement
6 |
7 | Dr. Vishnu is opening a new world-class hospital in a small town designed to be the first preference of the patients in the city. Hospital has N rooms of two types – with TV and without TV, with daily rates of R1 and R2 respectively. However, from his experience Dr. Vishnu knows that the number of patients is not constant throughout the year, instead, it follows a pattern.
8 |
9 | The number of patients on any given day of the year is given by the following formula – (6-M)2 + | D-15 |, where M is the number of the month (1 for Jan, 2 for Feb …12 for Dec) and D is the date (1,2…31).
10 |
11 | All patients prefer without TV rooms as they are cheaper but will opt for with TV rooms only if without TV rooms are not available. Hospital has a revenue target for the first year of operation. Given this target and the values of N, R1, and R2 you need to identify the number of TVs the hospital should buy so that it meets the revenue target. Assume the Hospital opens on 1st Jan and year is a non-leap year.
12 |
13 | ## Explanation
14 |
15 | Firstly, We need to assume the fact that the patient gets discharged on the same day only.
16 |
17 | Then, count the number of patients visited every day if the visited patient is more than the number of rooms we can have the only same count of patients.
18 |
19 | If patients are less than the number of r0oms then we need to allow the non TV rooms and thereafter TV rooms.
20 |
21 | By considering that there are **'x'** TV rooms and **'(n-x)'** are non TV rooms we need to calculate total revenue, if the calculated revenue just exceeds the targeted revenue or is equal to targeted revenue then the count is correct else we need to increase the number of TV rooms and recalculate the revenue.
22 |
23 |
24 |
25 |
26 | ```\Hospital_Revenue> python hospitalRevenue.py```
27 |
28 | ```30```
29 |
30 | ```2000 1000```
31 |
32 | ```10000000```
33 |
34 | ```16```
35 |
36 | Output :
37 |
38 | ```5```
39 |
--------------------------------------------------------------------------------
/Hospital_Revenue/hospitalRevenue.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deepspraj/CodeVita-Exam/513274f1e9733e5b96a78de0f3a65a30df9d9284/Hospital_Revenue/hospitalRevenue.pdf
--------------------------------------------------------------------------------
/Hospital_Revenue/hospitalRevenue.py:
--------------------------------------------------------------------------------
1 | ##
2 | # @author Deepak Prajapati
3 | # @email deepprajapati01@gmail.com
4 | # @create date 2020-06-27 13:16:43
5 | # @modify date 2020-06-27 13:16:43
6 | # @desc [description]
7 | ##
8 | import os
9 |
10 | no_of_rooms = int(input())
11 | sp_price, nor_price = input().split(" ")
12 | target_revenue = int(input())
13 | sp_price = int(sp_price)
14 | nor_price = int(nor_price)
15 | month = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
16 | days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
17 | total_patients = 0
18 |
19 |
20 | def price_calculator(rooms, count_of_month, no_of_days):
21 | patients = 0
22 | for i in range(1, no_of_days + 1):
23 | patients_on_day = (6 - count_of_month) ** 2 + abs(i - 15)
24 | if patients_on_day >= rooms:
25 | patients_on_day = rooms
26 | patients = patients + patients_on_day
27 | return patients
28 |
29 |
30 | def calulator(no_of_rooms, sp_price, nor_price, target_revenue, month, days, total_patients):
31 | for i in range(0, len(month)):
32 | patient_per_month = price_calculator(no_of_rooms, month[i], days[i])
33 | total_patients = total_patients + patient_per_month
34 |
35 | for i in range(0, no_of_rooms + 1):
36 | nor_rooms = no_of_rooms - i
37 | sp_rooms = i
38 | income = (nor_rooms * nor_price) + (sp_rooms * sp_price)
39 | avg_income = income / no_of_rooms
40 | total_revenue = avg_income * total_patients
41 | if total_revenue > target_revenue:
42 | print(sp_rooms)
43 | exit()
44 |
45 | print(no_of_rooms)
46 | os.system("Pause")
47 |
48 | if 5 <= no_of_rooms <= 100:
49 | if 0 <= sp_price <= 5000 or 0 <= nor_price <= 5000:
50 | if 0 <= target_revenue < 90000000:
51 | calulator(no_of_rooms, sp_price, nor_price, target_revenue, month, days, total_patients)
52 | else:
53 | exit()
54 | else:
55 | exit()
56 | else:
57 | exit()
58 |
--------------------------------------------------------------------------------
/Jurassic_Park/README.md:
--------------------------------------------------------------------------------
1 | # Jurassic Park
2 |
3 | The question was asked in Codevita Examination 2018
4 |
5 | ## Problem Statement
6 |
7 | Smilodon is a ferocious animal that used to live during the Pleistocene epoch (2.5 mya–10,000 years ago). Scientists successfully created few smilodons in experimental DNA research. A park is established and those smilodons are kept in a cage for visitors.
8 | This park consists of Grasslands(G), Mountains(M), and Waterbodies(W) and it has three gates (situated in grasslands only). Below is a sample layout.
9 |
10 | Before opening the park, the club authority decides to calculate the Safety index of the park. The procedure of the calculation is described below. Please help them to calculate.
11 | Safety Index calculation
12 |
13 | Assume a person stands on grassland(x) and a Smilodon escapes from the cage situated on grassland (y). If the person can escape from any of those three gates before the Smilodon able to catch him, then the grassland (x) is called safe else it is unsafe. A person and a Smilodon both take 1 second to move from one area to another adjacent area (top, bottom, left, or right) but a person can move only over grasslands through Smilodon can move over grasslands and mountains.
14 |
15 | If any grassland is unreachable for Smilodon (maybe it is unreachable for any person also), to increase the safe index value Club Authority use to mark those grasslands as safe land.
16 |
17 | ## Explanation
18 |
19 | For solving the problem we need to state two things that grassland is safe only in two possible ways.
20 |
21 | 1. When grassland is surrounded by water.
22 | 2. And if any other grassland is present in the neighbor.
23 |
24 | As soon as we get the coordinates of the cage. Change the notation of the cage to 'C'. By using the above two ways, we can calculate the number of safe grasslands. Once, we get the count of safe grasslands we can obtain the safety index from the given formula.
25 |
26 |
27 |
28 |
29 | ```\Jurassic_Park> python jurassicPark.py```
30 |
31 | ```5 5```
32 |
33 | ```3 5 5 2 5 3 4 1```
34 |
35 | ```w g w m g```
36 |
37 | ```g g g w m```
38 |
39 | ```m m g m g```
40 |
41 | ```g g w m w```
42 |
43 | ```w g g w m```
44 |
45 | Output :
46 |
47 | ```72.73```
48 |
--------------------------------------------------------------------------------
/Jurassic_Park/jurassicPark.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deepspraj/CodeVita-Exam/513274f1e9733e5b96a78de0f3a65a30df9d9284/Jurassic_Park/jurassicPark.pdf
--------------------------------------------------------------------------------
/Jurassic_Park/jurassicPark.py:
--------------------------------------------------------------------------------
1 | ##
2 | # @author Deepak Prajapati
3 | # @email deepprajapati01@gmail.com
4 | # @create date 2020-06-28 13:47:21
5 | # @modify date 2020-06-28 20:46:06
6 | ##
7 |
8 | import os
9 |
10 | row, col = map(int,input().split(" "))
11 |
12 | def checker (matrix,row,col,count_of_safe_places,last_row,last_col):
13 | if(matrix[row][col] == 'G'):
14 | temp1 = temp2 = temp3 = temp4 = 'W'
15 | if((col-1)>=0):
16 | temp1 = matrix[row][col-1]
17 | if((row-1)>=0):
18 | temp2 = matrix[row-1][col]
19 | if((row+1)<=(last_row-1)):
20 | temp3 = matrix[row+1][col]
21 | if((col+1)<=(last_col-1)):
22 | temp4 = matrix[row][col+1]
23 | if(temp1 == 'G' or temp2 == 'G' or temp3 == 'G' or temp4 == 'G'):
24 | count_of_safe_places.append(1)
25 | elif(temp1 == 'W' and temp2 == 'W' and temp3 == 'W' and temp4 == 'W'):
26 | count_of_safe_places.append(1)
27 | else:
28 | count_of_safe_places.append(0)
29 |
30 | return count_of_safe_places
31 |
32 | def get_inputs(row,col):
33 | matrix = []
34 | count_of_safe_places = []
35 | gates_cages = input().split(" ")
36 | gates_cages = list(map(int,gates_cages))
37 |
38 | for i in range (0,row):
39 | arr = input().split(" ")
40 | lst = [x.upper() for x in arr]
41 | matrix.append(lst)
42 |
43 | total_grasslands = sum([i.count('G') for i in matrix])
44 | matrix[gates_cages[6]-1][gates_cages[7]-1] = 'C'
45 |
46 | for i in range (0,row):
47 | for j in range (0,col):
48 | checker(matrix,i,j,count_of_safe_places,row,col)
49 |
50 | count = count_of_safe_places.count(1)
51 | si = (float(count)/float(total_grasslands))*100
52 | print(round(si, 2))
53 |
54 | if((3<=row<=1000) and (3<=col<=1000)):
55 | get_inputs(row,col)
56 | else:
57 | exit()
--------------------------------------------------------------------------------
/Lexi_string/README.md:
--------------------------------------------------------------------------------
1 | # Lexi String
2 |
3 | The question was asked in TCS Codevita Examination.
4 |
5 | ## Problem Statement
6 |
7 | Little Jill jumbled up the order of the letters in our dictionary. Now, Jack uses this list to find the smallest lexicographical string that can be made out of this new order. Can you help him?
8 |
9 | You are given a string P that denotes the new order of letters in the English dictionary.
10 |
11 | You need to print the smallest lexicographic string made from the given string S.
12 |
13 | ## Explanation
14 |
15 | A whole alphabetical order and a word will be provided by the user as an input.
16 |
17 | After the inputs are received we need to give each character of the order sequential number.
18 |
19 | Then sort the given word according to the sequential order and get the desired results.
20 |
21 |
22 |
23 |
24 | ```\Lexi_string> python lexiString.py```
25 |
26 | ```2```
27 |
28 | ```zxcvbnmqwertyuiopasdfghjkl```
29 |
30 | ```primeminister```
31 |
32 | ```mnbvcxzqawsedrftgyhujikolp```
33 |
34 | ```cruiseship```
35 |
36 | Output :
37 |
38 | ```nmmeerrtiiips```
39 |
40 | ```csserhuiip```
41 |
--------------------------------------------------------------------------------
/Lexi_string/lexiString.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deepspraj/CodeVita-Exam/513274f1e9733e5b96a78de0f3a65a30df9d9284/Lexi_string/lexiString.pdf
--------------------------------------------------------------------------------
/Lexi_string/lexiString.py:
--------------------------------------------------------------------------------
1 | ##
2 | # @author Deepak Prajapati
3 | # @email deepprajapati01@gmail.com
4 | # @create date 2020-06-27 13:17:20
5 | # @modify date 2020-06-27 13:17:20
6 | ##
7 | test_cases = int(input())
8 | string_list = {}
9 | word_list = {}
10 | for case in range (0,test_cases):
11 | string_list[case+1] = input()
12 | word_list[case+1] = input()
13 |
14 | def cal(user_word,string):
15 | word = []
16 | direct=[]
17 | sub_dict = {}
18 |
19 | for i in range (0,26):
20 | sub_dict[i+1] = string[i]
21 |
22 | for i in range (0,len(user_word)):
23 | temp1 = user_word[i]
24 | for j in range (0,26):
25 | temp2 = sub_dict[j+1]
26 | if (temp1 == temp2):
27 | word.append(j+1)
28 |
29 | word.sort()
30 | for i in range (0,len(user_word)):
31 | temp = word[i]
32 | direct.append(sub_dict[temp])
33 |
34 | for i in range (0,len(direct)):
35 | print(direct[i],end="")
36 | print()
37 |
38 | for result in range (0,test_cases):
39 | if (len(word_list[result+1])< 101 and len(string_list[result+1])<27 ):
40 | cal(word_list[result+1],string_list[result+1])
41 | else:
42 | print("ERRO")
--------------------------------------------------------------------------------
/Philaland_coins/README.md:
--------------------------------------------------------------------------------
1 | # Philaland Coins
2 |
3 | The question was asked in Codevita Examination 2019
4 |
5 | ## Problem Statement
6 |
7 | The problem solvers have found a new Island for coding and named it as Philaland.
8 |
9 | These smart people were given a task to make purchase of items at the Island easier by distributing various coins with different value.
10 |
11 | Manish has come up with a solution that if we make coins category starting from $1 till the maximum price of item present on Island, then we can purchase any item easily. He added following example to prove his point.
12 |
13 | Let’s suppose the maximum price of an item is 5$ then we can make coins of {$1, $2, $3, $4, $5} to purchase any item ranging from $1 till $5.
14 |
15 | Now Manisha, being a keen observer suggested that we could actually minimize the number of coins required and gave following distribution {$1, $2, $3}.
16 |
17 | According to him any item can be purchased one time ranging from $1 to $5. Everyone was impressed with both of them.
18 |
19 | Your task is to help Manisha come up with minimum number of denominations for any arbitrary max price in Philaland.
20 |
21 | ## Explanation
22 |
23 | The problem wants us to find the minimum numbers of coins required to satisfy all the count from 0 to N (maximum price).
24 | So here the solution, we need to configure that in our daily life we have only **10 rupees coin**, **5 rupees coin**, **2 rupees coin**, and **1 rupee coin**. That means, our solution will be having only **10 rupees coin**, **5 rupees coin**, **2 rupees coin**, and **1 rupee coin**.
25 |
26 | Firstly, we need to find the **count of 10 rupees coin**. This can be configured by **dividing the N (maximum price) by 10** and get the quotient but **the count of 10 rupees coin will be always 1 less** than the quotient which we obtained.
27 |
28 | Next, **5 rupees coin can be obtained by dividing the remainder** (i.e the amount left after removing the total amount made by 10 rupees coins) **by 5**. If the quotient is **odd then we have two 5 rupees coins** else **one 5 rupees coin**.
29 |
30 | Now, we can have a **count of 1 rupee coin** by extracting the whole amount contributed by 10 rupees coins and 5 rupees coins. Once, the amount is extracted then the left amount will be either odd or even. If the amount is **odd then the number of 1 rupee coins is 1 and 2 if it is even**.
31 |
32 | Lastly, extract the total amount contributed 10 rupees coins, 5 rupees coins, and 1 rupee coins. Then **divide the remaining amount by 2 the quotient obtained will be the count of 2 rupee coins**.
33 |
34 |
35 |
36 |
37 | ```\Philaland_coins> python philalandCoins.py```
38 |
39 | ```3```
40 |
41 | ```123```
42 |
43 | ```531```
44 |
45 | ```951```
46 |
47 | Output :
48 |
49 | ```17```
50 |
51 | ```57```
52 |
53 | ```99```
54 |
--------------------------------------------------------------------------------
/Philaland_coins/philalandCoins.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deepspraj/CodeVita-Exam/513274f1e9733e5b96a78de0f3a65a30df9d9284/Philaland_coins/philalandCoins.pdf
--------------------------------------------------------------------------------
/Philaland_coins/philalandCoins.py:
--------------------------------------------------------------------------------
1 | ##
2 | # @author Deepak Prajapati
3 | # @email deepprajapati01@gmail.com
4 | # @create date 2020-06-27 13:17:59
5 | # @modify date 2020-06-27 13:17:59
6 | ##
7 | import os
8 |
9 | num = int(input())
10 | inputs = []
11 |
12 |
13 | def coins_calculator(amount):
14 | no_of_tens = int(amount / 10) - 1
15 | if no_of_tens <= 0:
16 | no_of_tens = 0
17 | temp1 = int(amount / 5)
18 | if temp1 > 1:
19 | if temp1 % 2 == 0:
20 | no_of_fives = 1
21 | else:
22 | no_of_fives = 2
23 | else:
24 | no_of_fives = 0
25 |
26 | temp2 = int(amount - 10 * no_of_tens - 5 * no_of_fives)
27 | if temp2 % 2 == 0:
28 | no_of_ones = 2
29 | else:
30 | no_of_ones = 1
31 |
32 | no_of_twos = int(amount - 10 * no_of_tens - 5 * no_of_fives - 1 * no_of_ones) / 2
33 | total_coins = int(no_of_tens + no_of_fives + no_of_twos + no_of_ones)
34 | print(total_coins)
35 |
36 |
37 | for i in range(0, num):
38 | temp = input()
39 | inputs.append(temp)
40 |
41 | inputs = list(map(int, inputs))
42 |
43 | for i in range(0, num):
44 | coins_calculator(inputs[i])
45 |
46 | os.system("Pause")
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CodeVita-Exam
2 |
3 | Problems from code vita exams are solved and shared in public with problem description and source code in python.
4 |
5 | Source Code is solely solved by its logic and satisfies every test case given in the problem description.
6 |
7 | ## Each Directory contains
8 |
9 | 1. Pdf file with a problem statement and test cases.
10 | 2. Source Code (Python File)
11 | 3. Readme File for a small description of the logic which is applied to solve the problem.
12 |
--------------------------------------------------------------------------------
/String_Rotation/README.md:
--------------------------------------------------------------------------------
1 | # String Rotation
2 |
3 | The question was asked in Codevita Examination 2018
4 |
5 | ## Problem Statement
6 |
7 | Rotate a given String in the specified direction by specified magnitude.
8 |
9 | After each rotation make a note of the first character of the rotated String, after all rotation are performed the accumulated first character as noted previously will form another string, say FIRSTCHARSTRING.
10 |
11 | Check If FIRSTCHARSTRING is an Anagram of any substring of the Original string.
12 |
13 | If yes print "YES" otherwise "NO". Input
14 |
15 | The first line contains the original string s. The second line contains a single integer q. The ith of the next q lines contains character d[i] denoting direction and integer r[i] denoting the magnitude.
16 |
17 | ## Explanation
18 |
19 | The user will provide us the string (word).
20 |
21 | Next, the user will state the length of the substring.
22 |
23 | Now the user will provide the location of the letters of the substring which are located in the string.
24 |
25 | Once, we get all the letters we need to form substring. And check for the anagram of the formed word in the string's substring.
26 |
27 | If we get at least one anagram then we print **'Yes'** else **'No'**.
28 |
29 |
30 |
31 |
32 | ```\String_Rotation> python stringRotation.py```
33 |
34 | ```alphabets```
35 |
36 | ```5```
37 |
38 | ```l 0```
39 |
40 | ```r 8```
41 |
42 | ```l 4```
43 |
44 | ```r 6```
45 |
46 | ```l 2```
47 |
48 | Output :
49 |
50 | ```YES```
51 |
--------------------------------------------------------------------------------
/String_Rotation/stringRotation.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deepspraj/CodeVita-Exam/513274f1e9733e5b96a78de0f3a65a30df9d9284/String_Rotation/stringRotation.pdf
--------------------------------------------------------------------------------
/String_Rotation/stringRotation.py:
--------------------------------------------------------------------------------
1 | ##
2 | # @author Deepak Prajapati
3 | # @email deepprajapati01@gmail.com
4 | # @create date 2020-07-02 19:12:32
5 | # @modify date 2020-07-02 19:12:32
6 | ##
7 |
8 | import os
9 |
10 | string = input()
11 | changes = int(input())
12 |
13 | def stringmaker(string,changes):
14 | string1 = ''
15 | sub_string = []
16 | for i in range (0, changes):
17 | direction , index = input().split(" ")
18 | index = int(index)
19 | direction = direction.upper()
20 | if (direction == 'L'):
21 | string1 = string1 + (string[(index)])
22 | else:
23 | string1 = string1 + (string[-(index)])
24 |
25 | length = len(string)
26 | count_of_substring = int(length/changes)
27 | count = 0
28 | a = 0
29 | b = changes
30 | for i in range (0, int(count_of_substring)):
31 | if(count < int(count_of_substring)):
32 | string_new = string[a:b]
33 | a = b
34 | b = (2 * changes)
35 | else:
36 | string_new = string[a:]
37 |
38 | sub_string.append(string_new)
39 | count += 1
40 | count_of_anagrams = 0
41 | for i in range (0,int(count_of_substring)):
42 | temp1 = sorted(string1)
43 | temp2 = sorted(sub_string[i])
44 | if((len(temp1) == len (temp2)) and (temp1 == temp2)):
45 | count_of_anagrams = count_of_anagrams + 1
46 | return count_of_anagrams
47 |
48 |
49 | if ((0 0):
52 | print('YES')
53 | else:
54 | print('NO')
55 |
56 | os.system('Pause')
--------------------------------------------------------------------------------
/accicoEquiPairs/README.md:
--------------------------------------------------------------------------------
1 | # Accico Equi Pairs
2 |
3 | The question was asked in Codevita Examination 2015
4 |
5 | ## Problem Statement
6 |
7 | Ron Wesley has been bit by a three-headed snake and Harry Potter is searching for a potion. The Witch promises to tell the ingredients of the medicine if Harry can find equi pair of an array. Listen to the conversation between Harry The witch to know more about equi pairs.
8 |
9 | ### Conversation
10 |
11 | **The Witch** : To find the equi pair, you must know how to find the slices first.
12 |
13 | **Harry** : What is a slice?
14 |
15 | **The Witch** : If Z is an array with N elements, a slice of indices (X, Y) is Z[X] + Z[X+1]...Z[Y]
16 |
17 | **Harry** : How can I use it to find equi pair?
18 |
19 | **The Witch** : (a, b) is an equi pair if slice of (0, a-1) = slice of (a+1, b-1) = slice of (b+1, N-1) and b>a+1 and size of array >4
20 |
21 | ## Explanation
22 |
23 | The above conversation pre-defines the way of program.
24 |
25 | **Please read it calmly and carefully.**
26 |
27 |
28 | ```\accicoEquiPairs> python accicoEquiPairs.py```
29 |
30 | ```5 8 6 3 2 1 4 5 6 3 2 11 5 6 9 8 5 6 3 2```
31 |
32 | Output :
33 |
34 | ```Array does not contain any equi pair```
35 |
--------------------------------------------------------------------------------
/accicoEquiPairs/accicoEquiPairs.py:
--------------------------------------------------------------------------------
1 | ##
2 | # @author Deepak Prajapati
3 | # @email deepprajapati01@gmail.com
4 | # @create date 2020-07-18 14:57:07
5 | # @modify date 2020-07-18 15:14:53
6 | ##
7 |
8 | def pairFinder(a,b,lst):
9 | count = 0
10 | temp1 = temp2 = temp3 = 0
11 | for i in range (a):
12 | temp1 += lst[i]
13 |
14 | for i in range (a+1,b):
15 | temp2 += lst[i]
16 |
17 | for i in range (b+1, len(lst)):
18 | temp3 += lst[i]
19 |
20 | if (temp1 == temp2 == temp3):
21 | print(f'Indices which form equi pair {a,b}.')
22 | print(f'Slices are {0,a-1}, {a+1, b-1}, {b+1, len(lst)-1}.')
23 | count += 1
24 |
25 | return count
26 |
27 | lst = input().split(' ')
28 | lst = list(map(int , lst))
29 | default = 0
30 |
31 | for i in range (len(lst)):
32 | for j in range (len(lst)):
33 | if (j > (i + 1)):
34 | default = pairFinder(i,j,lst)
35 | if(default == 0):
36 | print('Array does not contain any equi pair')
--------------------------------------------------------------------------------
/accicoEquiPairs/accioEquiPairs.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deepspraj/CodeVita-Exam/513274f1e9733e5b96a78de0f3a65a30df9d9284/accicoEquiPairs/accioEquiPairs.pdf
--------------------------------------------------------------------------------
/catch22/README.md:
--------------------------------------------------------------------------------
1 | # Catch 22
2 |
3 | The question was asked in Codevita Examination 2015
4 |
5 | ## Problem Statement
6 |
7 | A robot is programmed to move forward F meters and backwards again, say B meters, in a straight line. The Robot covers 1 meter in T units of time. On Robot's path there is a ditch at a distance FD from initial position in forward direction as well as a ditch at a distance BD from initial position in backward direction. This forward and backward movement is performed repeatedly by the Robot.
8 |
9 | Your task is to calculate amount of time taken, before the Robot falls in either ditch, if at all it falls in a ditch.
10 |
11 | ## Explanation
12 |
13 | First, if forward distance (F) and backward distance (B) are same and forward direction is greater than forward distance then the robot will not be ditched **i.e. NO DITCHED.**
14 |
15 | Let distance (dist) be the distance from the initial position (origin) and answer (ans) be the total distance travelled by the robot and answer.
16 |
17 | Add **F** to **dist** and **ans** when robot travels forward. Add **B** to **ans** and subtract from **dist**.
18 |
19 | Perform this untill **dist** is less than or equal to the **FD** or **BD** is greater than or equal to the **dist**.
20 |
21 | If **FD** condition satisfies the let forward (variable) be equal to 1 else **BD** condition satisfies then let backward (variable) be equal to 1.
22 |
23 | If forword is equal to one then follow :
24 |
25 | - If the dist is equal to **FD** then simply get the product of ans and time **(T)** else subtract difference of dist and **FD** from ans and then get the product of ans and time **(T)**.
26 |
27 | If backword is equal to one then follow :
28 |
29 | - If the dist is equal to BD then simply get the product of ans and time **(T)** else add difference of dist and **FD** from ans and then get the product of ans and time **(T)**.
30 |
31 | Once, the product is obtained just print it and print the direction of the whether it is forward **(F)** or backward **(B)**.
32 |
33 |
34 |
35 | ```\catch22> python catch22.py```
36 |
37 | ```5```
38 |
39 | ```4 5 6 7 8```
40 |
41 | ```3 2 1 0 5```
42 |
43 | ```7 5 2 3 6```
44 |
45 | ```9 6 3 2 48```
46 |
47 | ```5 2 3 6 8```
48 |
49 | Output :
50 |
51 | ```432 B```
52 |
53 | ```0 F```
54 |
55 | ```6 F```
56 |
57 | ```6 F```
58 |
59 | ```30 F```
60 |
61 |
--------------------------------------------------------------------------------
/catch22/catch22.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deepspraj/CodeVita-Exam/513274f1e9733e5b96a78de0f3a65a30df9d9284/catch22/catch22.pdf
--------------------------------------------------------------------------------
/catch22/catch22.py:
--------------------------------------------------------------------------------
1 | ##
2 | # @author Deepak Prajapati
3 | # @email deepprajapati01@gmail.com
4 | # @create date 2020-07-24 13:47:04
5 | # @modify date 2020-07-24 14:26:19
6 | ##
7 |
8 | import os
9 |
10 | n = int(input())
11 |
12 | ans = [0 for i in range(n)]
13 |
14 | for i in range (n):
15 | ans[i] = list(map(int, input().split(' ')))
16 |
17 | def calculator(f,b,t,fd,bd):
18 | dist = 0
19 | ans = 0
20 | forward = backward = 0
21 | bd = (-1) * bd
22 | if( (f==b) and (fd>f) ):
23 | print("No Ditch")
24 | else:
25 | while ( True ):
26 | dist = dist + f
27 | ans = ans + f
28 |
29 | if( dist >= fd ):
30 | forward = 1
31 | break
32 |
33 | dist = dist - b
34 | ans = ans + b
35 |
36 | if(dist <= bd):
37 | backward = 1
38 | break
39 |
40 | if(forward == 1):
41 |
42 | if(dist == fd):
43 | t = t * ans
44 |
45 | else:
46 | ans = ans - (dist - fd)
47 | t = t * ans
48 |
49 | print(f'{t} F')
50 |
51 | if( backward == 1 ):
52 |
53 | if( dist == bd ):
54 | t = t * ans
55 |
56 | else:
57 | ans = ans + (dist - bd)
58 | t = t * ans
59 |
60 | print(f'{t} B')
61 |
62 |
63 | for i in range (n):
64 | calculator(ans[i][0], ans[i][1], ans[i][2], ans[i][3], ans[i][4])
65 |
66 | os.system('Pause')
--------------------------------------------------------------------------------
/christmasTree/README.md:
--------------------------------------------------------------------------------
1 | # Christmas Tree
2 |
3 | The question was asked in Codevita Examination 2016
4 |
5 | ## Problem Statement
6 |
7 | Chirag is a pure Desi boy. And his one and only dream is to meet Santa Claus. He decided to decorate a Christmas tree for Santa on coming Christmas. Chirag made an interesting Christmas tree that grows day by day.
8 |
9 | The Christmas tree is comprised of the following Parts:
10 |
11 | 1. Stand
12 | 2. Each Part is further comprised of Branches.
13 | 3. Branches are comprised of Leaves.
14 |
15 | How the tree appears as a function of days should be understood. Basis that print the tree as it appears on the given day. Below are the rules that govern how the tree appears on a given day. Write a program to generate such a Christmas tree whose input is number of days.
16 |
17 | ## Explanation
18 |
19 | 1. Create a symmetrical triangle (i.e. first part) of stars with rows (user input + 1).
20 | 2. Create a symmetrical traiangle (i.e. second part) starting from 3 stars with rows (user input - 1) upto **x (i.e. user input - 4)** times.
21 | 3. Create a symmetrical traiangle (i.e. third part) starting from 3 stars with rows **(x - 1)**.
22 | 4. Create a simple stand.
23 |
24 | Hence, Program is done.
25 |
26 | ```\christmasTree> python christmasTree.py```
27 |
28 | ```4```
29 |
30 | Output :
31 |
32 | ```*```
33 |
34 | ```* * *```
35 |
36 | ```* * * * *```
37 |
38 | ```* * * * * * *```
39 |
40 | ```* * * * * * * * *```
41 |
42 | ```* * *```
43 |
44 | ```* * * * *```
45 |
46 | ```* * * * * * *```
47 |
48 | ```* * *```
49 |
50 | ```* * * * *```
51 |
52 | ```*```
53 |
54 | ```*```
--------------------------------------------------------------------------------
/christmasTree/christmasTree.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deepspraj/CodeVita-Exam/513274f1e9733e5b96a78de0f3a65a30df9d9284/christmasTree/christmasTree.pdf
--------------------------------------------------------------------------------
/christmasTree/christmasTree.py:
--------------------------------------------------------------------------------
1 | ##
2 | # @author Deepak Prajapati
3 | # @email deepprajapati01@gmail.com
4 | # @create date 2020-07-11 16:10:38
5 | # @modify date 2020-07-11 17:23:57
6 | ##
7 |
8 | import os
9 |
10 | num = int(input())
11 | num += 1
12 |
13 | def firstPart(n):
14 | k = 0
15 | for i in range(1, n+1):
16 | for space in range(1, (n-i)+1):
17 | print(end=' ')
18 | while k != (2*i-1):
19 | print('*', end=' ')
20 | k += 1
21 | k = 0
22 | print()
23 |
24 | def secondPart(n):
25 | k = 0
26 | a = 3
27 | for i in range (0, n-2):
28 | for space in range(0, n-i-2):
29 | print(end=' ')
30 | while k != a:
31 | print('*', end=' ')
32 | k += 1
33 | a += 2
34 | k = 0
35 | print()
36 |
37 | def lastPart(n):
38 | k = 0
39 | a = 3
40 | for i in range (0, n-3):
41 | for space in range(0, n-i-2):
42 | print(end=' ')
43 | while k != a:
44 | print('*', end=' ')
45 | k += 1
46 | a += 2
47 | k = 0
48 | print()
49 |
50 | def stand(num):
51 | for i in range (0,2):
52 | for j in range (0,(2*num)-2):
53 | print(end=' ')
54 | print('*')
55 |
56 | if(num <= 2):
57 | print('You cannot generate christmas tree')
58 |
59 | elif(num > 20):
60 | print('Tree is no more')
61 |
62 | else:
63 | firstPart(num)
64 | part = 1
65 | new = num
66 | for i in range (0 , num-4):
67 | if (part < num):
68 | secondPart(new)
69 | part += 1
70 | lastPart(num)
71 | stand(num)
72 | os.system('pause')
--------------------------------------------------------------------------------
/collectingCandies/README.md:
--------------------------------------------------------------------------------
1 | # Collecting Candies
2 |
3 | The question was asked in Codevita Examination 2016
4 |
5 | ## Problem Statement
6 |
7 | Krishna loves candies a lot, so whenever he gets them, he stores them so that he can eat them later whenever he wants to.
8 |
9 | He has recently received N boxes of candies each containing Ci candies where Ci represents the total number of candies in the ith box. Krishna wants to store them in a single box. The only constraint is that he can choose any two boxes and store their joint contents in an empty box only. Assume that there are infinite number of empty boxes available.
10 |
11 | At a time he can pick up any two boxes for transferring and if both the boxes say contain X and Y number of candies respectively, then it takes him exactly X+Y seconds of time. As he is too eager to collect all of them he has approached you to tell him the minimum time in which all the candies can be collected.
12 |
13 | ## Explanation
14 |
15 | The problem is really an easy one. But, there is a twist that we need to recognize before solving.
16 |
17 | For that I have divided the solution in two equal parts.
18 |
19 | 1. The Count of boxes is of even multiple.
20 |
21 | For example,
22 | There are 4 Boxes ans user provide data of candies count in each box (1 2 3 4).
23 | So, we need to add each and every number by sequence to the previous sum.
24 | 4 boxes, each containing 1, 2, 3 and 4 candies respectively.
25 | Adding 1 + 2 in a new box take's 3 seconds.
26 | Adding 3 + 3 in a new box takes 6 seconds.
27 | Adding 4 + 6 in a new box takes 10 seconds.
28 | Hence, total time taken is 19 seconds.
29 |
30 | 2. The Count of boxes is of odd multiple.
31 |
32 | For example,
33 | There are 5 Boxes ans user provide data of candies count in each box (1 2 3 4 5).
34 | 5 boxes, each containing 1, 2, 3, 4 and 5 candies respectively.
35 | Adding 1 + 2 in a new box takes 3 seconds.
36 | Adding 3 + 3 in a new box takes 6 seconds.
37 | Adding 4 + 5 in a new box takes 9 seconds.
38 | Adding 6 + 9 in a new box takes 15 seconds.
39 | Hence, total time taken is 33 seconds.
40 |
41 |
42 |
43 | ```\collectingCandies> python collectingCandies.py```
44 |
45 | ```3```
46 |
47 | ```6```
48 |
49 | ```12 35 69 18 32 89```
50 |
51 | ```13```
52 |
53 | ```1 2 3 4 5 6 7 8 9 13 95 63 65```
54 |
55 | ```3```
56 |
57 | ```86 52 34```
58 |
59 | Output :
60 |
61 | ```718 seconds```
62 |
63 | ```977 seconds```
64 |
65 | ```276 seconds```
66 |
--------------------------------------------------------------------------------
/collectingCandies/collectingCandies.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deepspraj/CodeVita-Exam/513274f1e9733e5b96a78de0f3a65a30df9d9284/collectingCandies/collectingCandies.pdf
--------------------------------------------------------------------------------
/collectingCandies/collectingCandies.py:
--------------------------------------------------------------------------------
1 | ##
2 | # @author Deepak Prajapati
3 | # @email deepprajapati01@gmail.com
4 | # @create date 2020-07-13 09:57:25
5 | # @modify date 2020-07-13 10:43:09
6 | ##
7 |
8 | import os
9 | import math as ms
10 |
11 | def collectingCandies(countOfBoxes,sub):
12 | if(len(sub)%2 == 0):
13 | totalTime = 0
14 | temp = [0 for j in range(countOfBoxes)]
15 | instantTime = 0
16 | for i in range (countOfBoxes):
17 | instantTime = instantTime + sub[i]
18 | if(i != 0):
19 | temp[i-1] = instantTime
20 | for i in range (len(temp)):
21 | totalTime = totalTime + temp[i]
22 | return (totalTime)
23 | else:
24 | firstHalf = ms.ceil(len(sub)/2)
25 | temp = [0 for j in range(countOfBoxes)]
26 | totalTime = instantTime = 0
27 | for i in range(firstHalf):
28 | instantTime = instantTime + sub[i]
29 | if(i != 0):
30 | temp[i-1] = instantTime
31 | instantTime = 0
32 | for i in range(firstHalf, len(sub)):
33 | instantTime = instantTime + sub[i]
34 | if(i != firstHalf):
35 | temp[i] = instantTime
36 |
37 | instantTime1 = temp[firstHalf-2]
38 | instantTime2 = temp[-1]
39 | temp.sort()
40 | temp[0] = instantTime1 + instantTime2
41 | temp.sort()
42 | for i in range (len(sub)):
43 | totalTime = totalTime + temp[i]
44 | return totalTime
45 |
46 | testCases = int(input())
47 |
48 | if(0
56 |
57 | ```\islSchedule> python islSchedule.py```
58 |
59 | ```8```
60 |
61 | ```1 2 3 4 5 6 7 8```
62 |
63 | Output :
64 |
65 | ```T1 vs T8``` ```T2 vs T7```
66 |
67 | ```T3 vs T6```
68 |
69 | ```T4 vs T5``` ```T1 vs T7```
70 |
71 | ```T8 vs T6```
72 |
73 | ```T2 vs T5``` ```T3 vs T4```
74 |
75 | ```T1 vs T6```
76 |
77 | ```T7 vs T5``` ```T8 vs T4```
78 |
79 | ```T2 vs T3```
80 |
81 | ```T1 vs T5``` ```T6 vs T4```
82 |
83 | ```T7 vs T3```
84 |
85 | ```T8 vs T2``` ```T1 vs T4```
86 |
87 | ```T5 vs T3```
88 |
89 | ```T6 vs T2``` ```T7 vs T8```
90 |
91 | ```T1 vs T3```
92 |
93 | ```T4 vs T2``` ```T5 vs T8```
94 |
95 | ```T6 vs T7```
96 |
97 | ```T1 vs T2``` ```T3 vs T8```
98 |
99 | ```T4 vs T7```
100 |
101 | ```T5 vs T6``` ```T1 vs T8```
102 |
103 | ```T2 vs T7```
104 |
105 | ```T3 vs T6``` ```T4 vs T5```
106 |
107 | ```T1 vs T7```
108 |
109 | ```T8 vs T6``` ```T2 vs T5```
110 |
111 | ```T3 vs T4```
112 |
113 | ```T1 vs T6``` ```T7 vs T5```
114 |
115 | ```T8 vs T4```
116 |
117 | ```T2 vs T3``` ```T1 vs T5```
118 |
119 | ```T6 vs T4```
120 |
121 | ```T7 vs T3``` ```T8 vs T2```
122 |
123 | ```T1 vs T4```
124 |
125 | ```T5 vs T3``` ```T6 vs T2```
126 |
127 | ```T7 vs T8```
128 |
--------------------------------------------------------------------------------
/islSchedule/islSchedule.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deepspraj/CodeVita-Exam/513274f1e9733e5b96a78de0f3a65a30df9d9284/islSchedule/islSchedule.pdf
--------------------------------------------------------------------------------
/islSchedule/islSchedule.py:
--------------------------------------------------------------------------------
1 | ##
2 | # @author Deepak Prajapati
3 | # @email deepprajapati01@gmail.com
4 | # @create date 2020-07-20 20:56:40
5 | # @modify date 2020-07-20 21:49:23
6 | ##
7 |
8 | import math
9 |
10 | def scheduler(n,sequence):
11 |
12 | limit = int(n/2)
13 | schedule = []
14 | firstHalf = []
15 | secondHalf =[]
16 |
17 | for i in range (limit):
18 | firstHalf.append(i+1)
19 |
20 | for i in range(n,limit,-1):
21 | secondHalf.append(i)
22 |
23 | for i in range (n-1):
24 | for j in range (limit):
25 | temp = [firstHalf[j],secondHalf[j]]
26 | schedule.append(temp)
27 |
28 |
29 | temp1 = firstHalf[-1]
30 | temp2 = secondHalf[0]
31 | firstHalf.insert(1,temp2)
32 | firstHalf.pop(-1)
33 | secondHalf.pop(0)
34 | secondHalf.append(temp1)
35 |
36 | schedule = 2 * schedule
37 |
38 | noOfDays = math.ceil(len(schedule) * 2 / 3)
39 |
40 | j = 0
41 |
42 | while (i < noOfDays):
43 |
44 | if (i%2 == 0):
45 | team1 = "T" + str(schedule[j][0]) + " vs " + "T" + str(schedule[j][1])
46 | j += 1
47 | team2 = "T" + str(schedule[j][0]) + " vs " + "T" + str(schedule[j][1])
48 | j += 1
49 | print(team1, end=' ')
50 | print(team2)
51 |
52 | else:
53 | team1 = "T" + str(schedule[j][0]) + " vs " + "T" + str(schedule[j][1])
54 | j += 1
55 | print(team1)
56 |
57 | print()
58 |
59 | i += 1
60 |
61 | n = int(input())
62 |
63 | if( (8 <= n <= 100) and (n%2 == 0)):
64 | sequence = map(int,input().split(' '))
65 | scheduler(n,sequence)
66 | else:
67 | print('Input is not according to the conditions')
--------------------------------------------------------------------------------
/isotopeFusion/isotopeFusion.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deepspraj/CodeVita-Exam/513274f1e9733e5b96a78de0f3a65a30df9d9284/isotopeFusion/isotopeFusion.pdf
--------------------------------------------------------------------------------
/isotopeFusion/isotopeFusion.py:
--------------------------------------------------------------------------------
1 | ##
2 | # @author Deepak Prajapati
3 | # @email deepprajapati01@gmail.com
4 | # @create date 2020-07-31 16:50:27
5 | ##
6 |
7 | import os
8 | from math import sqrt
9 |
10 | def isotopeFusion(dataList):
11 |
12 | confirm = False
13 | dataList.sort()
14 | num = sqrt(len(dataList))
15 | num = int(num)
16 | newLength = len(dataList)//num
17 | executableList = []
18 |
19 | for i in range (newLength):
20 | newList = []
21 |
22 | if((i%2)==0):
23 | for j in range (num):
24 | newList.append(dataList[j])
25 |
26 | for j in range (num):
27 | dataList.pop(0)
28 |
29 | newList.sort()
30 | executableList += newList
31 | confirm = True
32 |
33 | else:
34 | for j in range (1,num+1):
35 | newList.append(dataList[-j])
36 |
37 | for j in range (num):
38 | dataList.pop(-1)
39 |
40 | executableList += newList
41 | confirm = False
42 |
43 | newList.clear()
44 |
45 | if (len(dataList) > 0):
46 | if (confirm == True):
47 | dataList.sort(reverse = True)
48 |
49 | executableList += dataList
50 |
51 | temp = executableList[0]
52 | answer = 0
53 |
54 | for i in range (1,len(executableList)):
55 | tempAnswer = temp * executableList[i]
56 |
57 | answer += tempAnswer
58 |
59 | if(tempAnswer > 198):
60 | temp = tempAnswer%199
61 | else:
62 | temp = tempAnswer
63 |
64 | print(str(answer) + " KJ")
65 |
66 | n = int(input())
67 |
68 | if (0 < n < 1000):
69 | dataList = list(map(int, input().split(' ')))
70 |
71 | i = 0
72 |
73 | try:
74 | while (True):
75 | temp = dataList[i]
76 | if ((temp > 198) or (0 >= temp)):
77 | print('Invalid Input')
78 | exit()
79 |
80 | i += 1
81 |
82 | if(i == n):
83 | break
84 | except IndexError:
85 | print(f'Oooops!!\nIncomplete Sequence\n{n-i} atom(s) are missing')
86 | exit(0)
87 |
88 | if (len(dataList) > n):
89 | del dataList[n:len(dataList)]
90 |
91 | isotopeFusion(dataList)
92 |
93 | os.system('Pause')
--------------------------------------------------------------------------------
/logicPyramid/README.md:
--------------------------------------------------------------------------------
1 | # Logic Pyramid
2 |
3 | The question was asked in Codevita Examination 2016
4 |
5 | ## Problem Statement
6 |
7 | Identify the logic behind the series 6 28 66 120 190 276....
8 |
9 | The numbers in the series should be used to create a Pyramid. The base of the Pyramid will be the widest and will start converging towards the top where there will only be one element. Each successive layer will have one number less than that on the layer below it. The width of the Pyramid is specified by an input parameter N. In other words, there will be N numbers on the bottom layer of the pyramid.
10 |
11 | The Pyramid construction rules are as follows:
12 |
13 | 1. First number in the series should be at the top of the Pyramid
14 | 2. Last N number of the series should be on the bottom-most layer of the Pyramid, with Nth number being the right-most number of this layer.
15 | 3. Numbers less than 5-digits must be padded with zeroes to maintain the sanctity of a Pyramid when printed.
16 |
17 | ## Explanation
18 |
19 |
20 |
21 | ```\logicPyramid> python logicPyramid.py```
22 |
23 | ```7```
24 |
25 | Output :
26 |
27 | ```00006```
28 |
29 | ```00028 00066```
30 |
31 | ```00120 00190 00276```
32 |
33 | ```00378 00496 00630 00780```
34 |
35 | ```00946 01128 01326 01540 01770```
36 |
37 | ```02016 02278 02556 02850 03160 03486```
38 |
39 | ```03828 04186 04560 04950 05356 05778 06216```
40 |
--------------------------------------------------------------------------------
/logicPyramid/logicPyramid.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deepspraj/CodeVita-Exam/513274f1e9733e5b96a78de0f3a65a30df9d9284/logicPyramid/logicPyramid.pdf
--------------------------------------------------------------------------------
/logicPyramid/logicPyramid.py:
--------------------------------------------------------------------------------
1 | n = int(input())
2 |
3 | def numberCalculate(n):
4 | lists = [6,28,66,120]
5 |
6 | totalCount = 0
7 | for i in range (1,n+1):
8 | totalCount += i
9 |
10 | for i in range (0, totalCount-4):
11 | newNumber = (lists[i+3] - lists[i+2])*3 + lists[i+1]
12 | if (newNumber >100000):
13 | break
14 | lists.append(newNumber)
15 |
16 | lists = list(map(str,lists))
17 |
18 | for i in range (0,len(lists)):
19 | if (len(lists[i])==1):
20 | new = str(0) + str(0) + str(0) + str(0) + lists[i]
21 | lists[i] = new
22 | elif (len(lists[i])==2):
23 | new = str(0) + str(0) + str(0) + lists[i]
24 | lists[i] = new
25 | elif (len(lists[i])==3):
26 | new = str(0) + str(0) + lists[i]
27 | lists[i] = new
28 | elif (len(lists[i])==4):
29 | new = str(0) + lists[i]
30 | lists[i] = new
31 |
32 | a = lineCount = 0
33 | rows = n+1
34 | for i in range(1, rows+1):
35 | k = 0
36 | for j in range(1, (rows-i)+1):
37 | print(end=" ")
38 | while (k != (i-1)):
39 | print(lists[a], end=" ")
40 | k = k + 1
41 | a = a + 1
42 | print()
43 | if (lineCount == n):
44 | exit()
45 | lineCount += 1
46 |
47 | if (0 # of shares of TCS, Infy and Wipro each and overall value of Mani's portfolio
16 | Fund 2 -> # of shares of TCS, Infy and Wipro each and overall value of Mani's portfolio
17 | Fund 3 -> # of shares of TCS, Infy and Wipro each and overall value of Mani's portfolio
18 |
19 | ## Explanation
20 |
21 | The problem is just a simple linear equations question where 3 unknowns are shares of TCS, Infosys and Wipro.
22 |
23 |
24 |
25 | ```\mfTracker> python mfTracker.py```
26 |
27 | ```3```
28 |
29 | ```10 10 10 60000```
30 |
31 | ```10 20 0 50000```
32 |
33 | ```20 0 10 50000```
34 |
35 | Output :
36 |
37 | ```1000.0```
38 |
39 | ```2000.0```
40 |
41 | ```3000.0```
42 |
--------------------------------------------------------------------------------
/mfTracker/mfTracker.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deepspraj/CodeVita-Exam/513274f1e9733e5b96a78de0f3a65a30df9d9284/mfTracker/mfTracker.pdf
--------------------------------------------------------------------------------
/mfTracker/mfTracker.py:
--------------------------------------------------------------------------------
1 | ##
2 | # @author Deepak Prajapati
3 | # @email deepprajapati01@gmail.com
4 | # @create date 2020-07-27 19:27:10
5 | ##
6 |
7 | import numpy as np
8 | import os
9 |
10 | def solver(shares, amount):
11 | if (len(shares) == len(amount)):
12 | try:
13 | equations = np.array(shares)
14 | answers = np.array(amount)
15 | solutions = np.linalg.solve(equations,answers)
16 |
17 | for i in range (len(solutions)):
18 | print(round(solutions[i], 2))
19 | except:
20 | print('Unsolvable')
21 | else:
22 | print('Please check the inputs')
23 |
24 | amount = []
25 | shares = []
26 |
27 | n = int(input())
28 |
29 | for i in range (n):
30 | share = list(map(int,input().split(' ')))
31 | amountR = share[-1]
32 | share.pop(-1)
33 | shares.append(share)
34 | amount.append(amountR)
35 |
36 | solver(shares, amount)
37 | os.system('Pause')
--------------------------------------------------------------------------------
/minProductArray/README.md:
--------------------------------------------------------------------------------
1 | # Minimum Product Array
2 |
3 | The question was asked in Codevita Examination 2016
4 |
5 | ## Problem Statement
6 |
7 | The task is to find the minimum sum of Products of two arrays of the same size, given that k modifications are
8 | allowed on the first array. In each modification, one array element of the first array can either be increased or
9 | decreased by 2.
10 |
11 | ## Explanation
12 |
13 | The question above states that we can increase or decrease the certain number by twice the user input (i.e. k).
14 |
15 | 1. We need to find the product of first element of array1 and array2. If product and element of array2 are negative (i.e. < 0) then we need to increase the element of array1 and again find the product.
16 |
17 | 2. Now find the product of first element of array1 and array2. If product and element of array1 are negative (i.e. < 0) then we need to decrease the element of array1 and again find the product.
18 |
19 | 3. Now find the product of first element of array1 and array2. If product is positive (i.e. > 0) and element of array1 is negative (i.e. < 0) then we need to increase the element of array1 and again find the product.
20 |
21 | 4. Now find the product of first element of array1 and array2. If product and element of array1 are positive (i.e. > 0) then we need to decrease the element of array1 and again find the product.
22 |
23 | Once, any one of the above conditions satisfies and new product is found then find difference between new product and old product.If the diff is less than maximum difference then add previously obtained product in the variable of the minimum sum.
24 |
25 | Lastly, print the Minimum Sum obtained.
26 |
27 | **Note: Array (specifically integer type) in python language means list data type with all the containing values are purely integers.**
28 |
29 |
30 |
31 |
32 | ```\minProductArray> python minProductArray.py```
33 |
34 | ```6 6```
35 |
36 | ```-2 6 3 -7 -4 5```
37 |
38 | ```-3 23 -86 43 -68 74```
39 |
40 | Output :
41 |
42 | ```-805```
43 |
--------------------------------------------------------------------------------
/minProductArray/minProductArray.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deepspraj/CodeVita-Exam/513274f1e9733e5b96a78de0f3a65a30df9d9284/minProductArray/minProductArray.pdf
--------------------------------------------------------------------------------
/minProductArray/minProductArray.py:
--------------------------------------------------------------------------------
1 | ##
2 | # @author Deepak Prajapati
3 | # @email deepprajapati01@gmail.com
4 | # @create date 2020-07-10 16:07:01
5 | # @modify date 2020-07-10 16:07:01
6 | ##
7 |
8 | import os
9 |
10 | n ,k = map(int, input().split(' '))
11 |
12 | def minSumCal(n, k):
13 | listOne = input().split(' ')
14 | listOne = list(map(int,listOne))
15 | listTwo = input().split(' ')
16 | listTwo = list(map(int,listTwo))
17 | maxDiff = 0
18 | minSum = 0
19 |
20 | for i in range (0, n):
21 |
22 | product = listOne[i] * listTwo[i]
23 |
24 | if ( product < 0 and listTwo[i] < 0):
25 | temp = (listOne[i] + 2 * k ) * listTwo[i]
26 | elif( product < 0 and listOne[i] < 0):
27 | temp = (listOne[i] - 2 * k) * listTwo[i]
28 | elif( product > 0 and listOne[i] < 0):
29 | temp = (listOne[i] + 2 * k) * listTwo[i]
30 | elif (product > 0 and listOne[i] > 0):
31 | temp = (listOne[i] - 2 * k) * listTwo[i]
32 |
33 | diff = abs(product - temp)
34 |
35 | if( diff > maxDiff ):
36 | maxDiff = diff
37 |
38 | minSum = minSum + product
39 |
40 | minSum = minSum - maxDiff
41 |
42 | print(minSum)
43 |
44 | if ((1 <= n <= 100000) and (0 <= k <= 1000000000)):
45 | minSumCal(n,k)
46 | os.system('Pause')
47 |
--------------------------------------------------------------------------------
/minimumDistance/README.md:
--------------------------------------------------------------------------------
1 | # Minimum Distance
2 |
3 | The question was asked in Codevita Examination 2015
4 |
5 | ## Problem Statement
6 |
7 | Two riders A and B are travelling on a highway towards each other on two roads that intersect at right angle at speeds VA meters/second and VB meters/second. A is at a distance of 'x' meters and B is at a distance of 'y' meters from the intersection. Calculate the minimum distance between these two riders that is possible.
8 |
9 | **For diagrammatic explanation please view the pdf file.**
10 |
11 | ## Explanation
12 |
13 | First, all the inputs provided by the user must be positive as distances and velocities can't be negative (logically).
14 |
15 | Now, We need to find the distance between two riders by using the distance formula `(i.e. sqrt(x*x + y*y))` and subtract velocity of each rider from respective distance.
16 |
17 | And perform above step until distance of both the rider become's negative. As soon as, both the distances are negative just break the loop and the answer is the minimum distance which we calculated using distance formula before failing in the condition of positivity.
18 |
19 |
20 | **Calculating and printing of output should be done up to 11 digits precision after decimal point.**
21 |
22 |
23 |
24 | ```\minimumDistance> python minimumDistance.py```
25 |
26 | ```10056```
27 |
28 | ```12034```
29 |
30 | ```500```
31 |
32 | ```321```
33 |
34 | Output :
35 |
36 | ```4695.233434026471```
37 |
--------------------------------------------------------------------------------
/minimumDistance/minimumDistance.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deepspraj/CodeVita-Exam/513274f1e9733e5b96a78de0f3a65a30df9d9284/minimumDistance/minimumDistance.pdf
--------------------------------------------------------------------------------
/minimumDistance/minimumDistance.py:
--------------------------------------------------------------------------------
1 | ##
2 | # @author Deepak Prajapati
3 | # @email deepprajapati01@gmail.com
4 | # @create date 2020-07-19 13:25:00
5 | # @modify date 2020-07-19 13:44:23
6 | ##
7 |
8 | import math as ms
9 |
10 | distanceA = int(input())
11 | distanceB = int(input())
12 | vA = int(input())
13 | vB = int(input())
14 |
15 | if((distanceA < 0) or (distanceB < 0) or (vA < 0) or (vB < 0)):
16 | print('Invalid Input')
17 | else:
18 | minDistance = ms.sqrt( (distanceA * distanceA) + (distanceB * distanceB) )
19 | while((distanceA >= 0) or (distanceB >= 0)):
20 | distanceA -= vA
21 | distanceB -= vB
22 | currDistance = ms.sqrt( (distanceA * distanceA) + (distanceB * distanceB) )
23 | if( currDistance < minDistance ):
24 | minDistance = currDistance
25 | if(minDistance == 0.0):
26 | print('0.0')
27 | else:
28 | print(f'{minDistance}')
--------------------------------------------------------------------------------
/reverseGear/README.md:
--------------------------------------------------------------------------------
1 | # Reverse Gear
2 |
3 | The question was asked in Codevita Examination 2015
4 |
5 | ## Problem Statement
6 |
7 | A futuristic company is building an autonomous car. The scientists at the company are training the car to perform Reverse parking. To park, the car needs to be able to move in backward as well as forward direction. The car is programmed to move backwards **B** meters and forwards again, say **F** meters, in a straight line. The car does this repeatedly until it is able to park or collides with other objects. The car covers **1** meter in **T** units of time. There is a wall after distance **D** from car's initial position in the backward direction.
8 |
9 | The car is currently not without defects and hence often hits the wall. The scientists are devising a strategy to prevent this from happening. Your task is to help the scientists by providing them with exact information on amount of time available before the car hits the wall.
10 |
11 | ## Explanation
12 |
13 | In reality, we park the car at a particular position by driving some distance forward, backward after ensuring the position we turn off the engine.
14 |
15 | So, we need to apply the same strategy in this problem.
16 |
17 | Let **C** be the difference between the forward distance and backward distance.
18 |
19 | Multiply the **C** with **T** (time) and add to the Total time required **(TT)**.
20 |
21 | Subtract **C** from **D** (distance).
22 |
23 | Perform the above two steps, repeatedly until the **D** becomes smaller than **C**.
24 |
25 | As soon as the **C** becomes greater than **D** multiply the remaining distance **D** and add the product to the Total time.
26 |
27 | And print the Total Time **(TT)**.
28 |
29 | **Note - If ans display as "0" that means the provided inputs are not according to the specific conditions.**
30 |
31 | **Please check input twice before entering.**
32 |
33 |
34 |
35 | ```\reverseGear> python reverseGear.py```
36 |
37 | ```2```
38 |
39 | ```5 17 9 23```
40 |
41 | ```3 12 8 20```
42 |
43 | Output :
44 |
45 | ```297```
46 |
47 | ```208```
48 |
--------------------------------------------------------------------------------
/reverseGear/reverseGear.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deepspraj/CodeVita-Exam/513274f1e9733e5b96a78de0f3a65a30df9d9284/reverseGear/reverseGear.pdf
--------------------------------------------------------------------------------
/reverseGear/reverseGear.py:
--------------------------------------------------------------------------------
1 | ##
2 | # @author Deepak Prajapati
3 | # @email deepprajapati01@gmail.com
4 | # @create date 2020-07-13 21:47:01
5 | # @modify date 2020-07-13 22:12:36
6 | ##
7 |
8 | import os
9 |
10 | def timeCal(lst):
11 | ans = 0
12 | while True:
13 | if(lst[1] python sheldonCooper.py```
32 |
33 | ```8```
34 |
35 | ```10```
36 |
37 | ```25```
38 |
39 | ```1```
40 |
41 | ```18```
42 |
43 | ```34```
44 |
45 | ```14```
46 |
47 | ```3```
48 |
49 | ```8```
50 |
51 | Output :
52 |
53 | ```True```
54 |
--------------------------------------------------------------------------------
/sheldonCooper/sheldonCooper.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deepspraj/CodeVita-Exam/513274f1e9733e5b96a78de0f3a65a30df9d9284/sheldonCooper/sheldonCooper.pdf
--------------------------------------------------------------------------------
/sheldonCooper/sheldonCooper.py:
--------------------------------------------------------------------------------
1 | ##
2 | # @author Deepak Prajapati
3 | # @email deepprajapati01@gmail.com
4 | # @create date 2020-07-19 16:50:51
5 | # @modify date 2020-07-19 17:02:24
6 | ##
7 |
8 | import itertools as itt
9 |
10 | def combinationFinder(sizeOfBottles,aConsume):
11 | combinations = []
12 | pCombinations = 0
13 | sizeOfBottles.sort()
14 |
15 | for i in range (len(sizeOfBottles)):
16 | if(sizeOfBottles[i] > aConsume):
17 | sizeOfBottles.pop(i)
18 |
19 | for i in itt.combinations(sizeOfBottles, 3):
20 | combinations.append(list(i))
21 |
22 | for i in range (len(combinations)):
23 | temp = combinations[i][0] + combinations[i][1] + combinations[i][2]
24 | if (temp == aConsume):
25 | pCombinations += 1
26 |
27 | print('True') if (pCombinations > 0) else print('False')
28 |
29 | n = int(input())
30 | sizeOfBottles = []
31 |
32 | for i in range (n):
33 | sizeOfBottles.append(int(input()))
34 |
35 | aConsume = int(input())
36 |
37 | combinationFinder(sizeOfBottles,aConsume)
--------------------------------------------------------------------------------
/skateBoard/README.md:
--------------------------------------------------------------------------------
1 | # Accico Equi Pairs
2 |
3 | The question was asked in Codevita Examination 2015
4 |
5 | ## Problem Statement
6 |
7 | Ron Wesley has been bit by a three-headed snake and Harry Potter is searching for a potion. The Witch promises to tell the ingredients of the medicine if Harry can find equi pair of an array. Listen to the conversation between Harry The witch to know more about equi pairs.
8 |
9 | ### Conversation
10 |
11 | **The Witch** : To find the equi pair, you must know how to find the slices first.
12 |
13 | **Harry** : What is a slice?
14 |
15 | **The Witch** : If Z is an array with N elements, a slice of indices (X, Y) is Z[X] + Z[X+1]...Z[Y]
16 |
17 | **Harry** : How can I use it to find equi pair?
18 |
19 | **The Witch** : (a, b) is an equi pair if slice of (0, a-1) = slice of (a+1, b-1) = slice of (b+1, N-1) and b>a+1 and size of array >4
20 |
21 | ## Explanation
22 |
23 | The above conversation pre-defines the way of program.
24 |
25 | **Please read it calmly and carefully.**
26 |
27 |
28 | ```\accicoEquiPairs> python accicoEquiPairs.py```
29 |
30 | ```5 8 6 3 2 1 4 5 6 3 2 11 5 6 9 8 5 6 3 2```
31 |
32 | Output :
33 |
34 | ```Array does not contain any equi pair```
35 |
--------------------------------------------------------------------------------
/skateBoard/skateBoard.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deepspraj/CodeVita-Exam/513274f1e9733e5b96a78de0f3a65a30df9d9284/skateBoard/skateBoard.pdf
--------------------------------------------------------------------------------
/skateBoard/skateBoard.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deepspraj/CodeVita-Exam/513274f1e9733e5b96a78de0f3a65a30df9d9284/skateBoard/skateBoard.py
--------------------------------------------------------------------------------
/stoneGame/README.md:
--------------------------------------------------------------------------------
1 | # Stone Game - One Four
2 |
3 | The question was asked in Codevita Examination 2014
4 |
5 | ## Problem Statement
6 |
7 | Alice and Bob are playing a game called "Stone Game". Stone game is a two-player game. Let N be the total number
8 | of stones. In each turn, a player can remove either one stone or four stones. The player who picks the last stone,
9 | wins. They follow the "Ladies First" norm. Hence Alice is always the one to make the first move. Your task is to find
10 | out whether Alice can win, if both play the game optimally.
11 |
12 | ## Explanation
13 |
14 | The problem is an easy to be solved.
15 |
16 | The logic is explained as follows:
17 |
18 | 1. The total number of stones is divided by 4. As, we want to know who was the last one between **Alice** and **Bob** to pick 4 stone at an instance.
19 |
20 | - If the quotient netted is even that means **Bob** is the last player to pick the 4 stones at an instance.
21 |
22 | - If the quotient netted is odd that means **Alice** is the last player to pick the 4 stones at an instance.
23 |
24 | 2. The remainder after subtracting all the 4 stone's taken by both the player from the total number of stones.
25 |
26 | - If the remainder is odd and the quotient is even then **Alice** wins the game.
27 |
28 | - If the remainder is odd and the quotient is odd then **Bob** wins the game.
29 |
30 | - If the remainder is even and the quotient is even then **Bob** wins the game.
31 |
32 | - If the remainder is even and the quotient is odd then **Alice** wins the game.
33 |
34 |
35 | **Alice is preferenced to pick first due to "Ladies first rule."**
36 |
37 |
38 | ```\stoneGame>python stoneGame.py```
39 |
40 | ```4```
41 |
42 | ```63```
43 |
44 | ```45```
45 |
46 | ```21```
47 |
48 | ```98```
49 |
50 | Output :
51 |
52 | ```No```
53 |
54 | ```No```
55 |
56 | ```No```
57 |
58 | ```No```
59 |
--------------------------------------------------------------------------------
/stoneGame/stoneGame.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deepspraj/CodeVita-Exam/513274f1e9733e5b96a78de0f3a65a30df9d9284/stoneGame/stoneGame.pdf
--------------------------------------------------------------------------------
/stoneGame/stoneGame.py:
--------------------------------------------------------------------------------
1 | ##
2 | # @author Deepak Prajapati
3 | # @email deepprajapati01@gmail.com
4 | # @create date 2020-07-29 23:51:16
5 | ##
6 |
7 | import os
8 |
9 | def winner(n):
10 | chances = n//4
11 |
12 | if(chances%2 == 0):
13 | remain = n - (chances*4)
14 | if(remain%2 == 0):
15 | print("No")
16 | else:
17 | print("Yes")
18 |
19 | else:
20 | remain = n - (chances*4)
21 |
22 | if(remain%2 != 0):
23 | print("No")
24 | else:
25 | print("Yes")
26 |
27 | testCase = int(input())
28 |
29 | data = []
30 |
31 | for i in range (testCase):
32 | temp = int(input())
33 | data.append(temp)
34 |
35 | for i in range (testCase):
36 | winner(data[i])
37 |
38 | os.system('Pause')
--------------------------------------------------------------------------------
/superAsciiStringChecker/README.md:
--------------------------------------------------------------------------------
1 | # Super ASCII String Checker
2 |
3 | The question was asked in Codevita Examination 2014
4 |
5 | ## Problem Statement
6 |
7 | In the Byte land country, a string "S" is said to super ascii string if and only if count of each character in the string is equal to its ascii value.
8 |
9 | In the Byte land country ascii code of 'a' is 1, 'b' is 2 ...'z' is 26.
10 |
11 | Your task is to find out whether the given string is a super ascii string or not.
12 |
13 | ## Explanation
14 |
15 | The Logic is explained as follow:
16 |
17 | 1. We need to create the dictionary with the key as ascii code of byte land and respective value as an alphabet.
18 |
19 | 2. Count all alphabets according to the sequence.
20 |
21 | 3. Check that count and key of the alphabet in the dictionary is the same or not.
22 |
23 | 4. Perform above steps for all alphabets simultaneously.
24 |
25 | 5. At some instance we found that the key and the ascii code is not same abort the remaining task and print No else keep performing the steps.
26 |
27 |
28 |
29 | ```\superAsciiStringChecker> python superAsciiStringChecker.py```
30 |
31 | ```3```
32 |
33 | ```abbcccddddeeeee```
34 |
35 | ```eeeeddddccbba```
36 |
37 | ```pikachu```
38 |
39 | Output :
40 |
41 | ```Yes```
42 |
43 | ```No```
44 |
45 | ```No```
46 |
--------------------------------------------------------------------------------
/superAsciiStringChecker/superAsciiStringChecker.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deepspraj/CodeVita-Exam/513274f1e9733e5b96a78de0f3a65a30df9d9284/superAsciiStringChecker/superAsciiStringChecker.pdf
--------------------------------------------------------------------------------
/superAsciiStringChecker/superAsciiStringChecker.py:
--------------------------------------------------------------------------------
1 | ##
2 | # @author Deepak Prajapati
3 | # @email deepprajapati01@gmail.com
4 | # @create date 2020-07-30 13:28:45
5 | ##
6 |
7 | import os
8 | import string
9 |
10 | superAscii = True
11 |
12 | def stringChecker(word):
13 | dict = {}
14 | newList = []
15 | letters = []
16 |
17 |
18 | def keyChecker(aLetter):
19 | key = 0
20 | for i in range (1, 27):
21 | if (dict.get(i) == aLetter):
22 | key = i
23 | break
24 |
25 | return key
26 |
27 | newList = list(string.ascii_lowercase)
28 |
29 | for i in range (1,27):
30 | dict[i] = newList[i-1]
31 | if (i==26):
32 | newList.clear()
33 |
34 | for i in range (1,27):
35 | confirm = dict[i] in word
36 | if (confirm == True):
37 | letters.append(dict[i])
38 |
39 | for letter in range (len(letters)):
40 | word.count(letters[letter])
41 | if (keyChecker(letters[letter]) != word.count(letters[letter])):
42 |
43 | global superAscii
44 | superAscii= False
45 |
46 |
47 | print('Yes') if (superAscii == True) else print('No')
48 |
49 |
50 | testCase = int(input())
51 |
52 | strings = []
53 |
54 | if(0 < testCase <= 100):
55 | for test in range (testCase):
56 | word = input()
57 | word = word.lower()
58 | if (0 < len(word) <= 400):
59 | strings.append(word)
60 |
61 | for i in range (testCase):
62 | stringChecker(strings[i])
63 |
64 | os.system('Pause')
--------------------------------------------------------------------------------
/theGameOfMarbles/README.md:
--------------------------------------------------------------------------------
1 | # The Game of Marbles
2 |
3 | The question was asked in Codevita Examination 2016
4 |
5 | ## Problem Statement
6 |
7 | Darrell and Sally are two best friends. They had a large collection of marbles. They devised a game with it to play in their free time which will also help them to improve their math. One of them will have to select a certain number of marbles and give a hint to find the number. The other will have to guess the first number that matches the given criteria and vice versa.
8 |
9 | Your task is to act as a judge for this game. When the player finds the answer, you will have to verify the answer. If answer is right, add 10 points to that player. If the player passes the question, you will have to give the right answer (no change in points in this case). You should also announce the winner at the end of the game.
10 |
11 | *Hint to find the number:*
12 |
13 | When the marbles are put into a group of x1, x2, x3,...(where x1, x2, x3 can be any number from 1 to 100), it falls into a perfect group.(No marble is left without a group).
14 |
15 | ### Example
16 |
17 | When Darrell says the number falls into a perfect set when she groups them into sets of 3 and 5, the answer could be 15 or 30 and so on. Since the first number that matches the criteria is 15, 15 will be the answer.
18 |
19 | *(Explanation: when 15 marbles is put into groups of 3, We will get 5 sets of 3 marbles each and when it is put into groups of 5, we will get 3 sets of 5 marbles each. For 16 marbles, we will get 5 sets of 3 marbles each and one marble will be left without a proper group. So 16 cannot be the answer).*
20 |
21 |
22 |
23 | ***NOTE: Please have a look at Sample Input and Output before you read the Input and Output specification.***
24 |
25 | ## Explanation
26 |
27 | The logic is explained as follows:
28 |
29 | 1. The accurate answer to question asked by the questioner is **LCM** of the quantity of marbles.
30 |
31 | 2. The question always starts with questioner name and **x** quantity of marbles.
32 |
33 | 3. We take question and answer from the user in every repetition of for loop. Therefore, we limited the range of the for loop to n/2.
34 |
35 | 4. As soon as, the question is asked by the questioner we need to calculate the accurate answer.
36 |
37 | 5. Once the answerer resolves the asked question. We need checking whether the answer answered by the answerer is correct or not.
38 |
39 | 6. If the answer is correct then credit 10 points to answerer's account else do not credit the answerer.
40 |
41 | 7. Perform above 3 steps n/2 times (Reason: step 3).
42 |
43 | 8. Print the competition's statistics and winner.
44 |
45 |
46 |
47 | ```\theGameOfMarbles> python theGameOfMarbles.py```
48 |
49 | ***Input :*** ```8```
50 |
51 | ***Input :*** ```Darrell 40,17```
52 |
53 | ***Output :*** ```Darrell's question is 40,17```
54 |
55 | ***Input :*** ```A Sally 680```
56 |
57 | ***Output :*** ```Correct Answer```
58 |
59 | ***Output :*** ```Sally: 10 points```
60 |
61 | ***Input :*** ```Sally 36,8```
62 |
63 | ***Output :*** ```Sally's question is 36,8```
64 |
65 | ***Input :*** ```A Darrell 96```
66 |
67 | ***Output :*** ```Incorrect Answer```
68 |
69 | ***Output :*** ```Darrell: 0 points```
70 |
71 | ***Input :*** ```Darrell 7,34```
72 |
73 | ***Output :*** ```Darrell's question is 7,34```
74 |
75 | ***Input :*** ```A Sally 238```
76 |
77 | ***Output :*** ```Correct Answer```
78 |
79 | ***Output :*** ```Sally: 10 points```
80 |
81 | ***Input :*** ```Sally 11,23```
82 |
83 | ***Output :*** ```Sally's question is 11,23```
84 |
85 | ***Input :*** ```A Darrell 253```
86 |
87 | ***Output :*** ```Correct Answer```
88 |
89 | ***Output :*** ```Darrell: 10 points```
90 |
91 | ***Result :***
92 |
93 | ```Total Points```
94 |
95 | ```Darrell : 10 points```
96 |
97 | ```Sally : 20 points```
98 |
99 | ```Game Result : Sally is winner```
100 |
--------------------------------------------------------------------------------
/theGameOfMarbles/theGameOfMarbles.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deepspraj/CodeVita-Exam/513274f1e9733e5b96a78de0f3a65a30df9d9284/theGameOfMarbles/theGameOfMarbles.pdf
--------------------------------------------------------------------------------
/theGameOfMarbles/theGameOfMarbles.py:
--------------------------------------------------------------------------------
1 | ##
2 | # @author Deepak Prajapati
3 | # @email deepprajapati01@gmail.com
4 | # @create date 2020-08-03 16:33:47
5 | ##
6 |
7 | from os import system as sys
8 | from math import gcd
9 |
10 | def lcmFinder(lst):
11 | lcm = lst[0]
12 |
13 | for i in lst[1:]:
14 | lcm = int(lcm*i/gcd(lcm, i))
15 |
16 | return int(lcm)
17 |
18 | n = int(input())
19 |
20 | points = {"Sally": 0, "Darrell": 0}
21 |
22 | n = n//2
23 |
24 | try:
25 | for i in range (n):
26 | question = list(map(str, input().split(' ')))
27 | questioner = question[0]
28 | quest = question[1]
29 |
30 | print("{0}'s question is {1} ".format(questioner,quest))
31 |
32 | quest = list(map(int, quest.split(',')))
33 |
34 | userAnswers = input().split(' ')
35 | answerer = userAnswers[1]
36 |
37 |
38 | if(i == 0):
39 | firstQuestioner = questioner
40 | firstAnswerer = answerer
41 |
42 | correctAns = lcmFinder(quest)
43 |
44 | if (userAnswers[2] == 'PASS'):
45 |
46 | print('Question is PASSed')
47 | print('Answer is {0}'.format(correctAns))
48 | print('{0} : 0 points'.format(answerer))
49 |
50 | else:
51 | userAns = int(userAnswers[2])
52 |
53 | if(userAns == correctAns):
54 | print('Correct Answer')
55 | print('{0}: 10 points'.format(answerer))
56 | points[answerer] = points[answerer] + 10
57 |
58 | else:
59 | print('Incorrect Answer')
60 | print('{0}: 0 points'.format(answerer))
61 |
62 | except:
63 | print('Invalid Input')
64 | exit()
65 |
66 |
67 | print('\nTotal Points')
68 | print('{0} : '.format(firstQuestioner) + str(points[firstQuestioner]) + ' points')
69 | print('{0} : '.format(firstAnswerer) + str(points[firstAnswerer]) + ' points')
70 |
71 | if(points[firstQuestioner] == points[firstAnswerer]):
72 | print('Game Result : Draw\n')
73 |
74 | elif(points[firstQuestioner] < points[firstAnswerer]):
75 | print('Game Result : Sally is winner\n')
76 |
77 | else:
78 | print('Game Result : Darrell is winner\n')
79 |
80 | sys('Pause')
--------------------------------------------------------------------------------
/theMysteryOfSky/README.md:
--------------------------------------------------------------------------------
1 | # The Mystery of Sky
2 |
3 | The question was asked in Codevita Examination 2015
4 |
5 | ## Problem Statement
6 |
7 | Stark is a 10 year old kid and he loves stars. So, he decided every day he will capture a picture of a sky. After doing this for many days he found very interesting observations.
8 |
9 | Every day the total number of stars in the sky is same as days completed for a calendar year. He noticed, on Saturday's and Sunday's that there are no stars in the sky. Stark's camera does not have wide angle capture feature so he could only capture maximum of 50 stars at a time. So, he assumed that there are only 50 stars in the sky that day. Also, the camera discharges every 4th day and he is not be able to click any picture that day. So, let's say, if the first day of calendar (01/01/0001) starts on a Monday then on Thursday he can't click any pictures. Then resuming on Friday, he can take pictures until Sunday, but can't take picture on Monday, followed by downtime on Friday, then Tuesday, then Saturday etc. When the camera discharges he considers 0 stars that day.
10 |
11 | You are his programmer friend and want to help him. You need to write a code which will tell him on a particular date how many stars Stark's camera was able to click.
12 |
13 | You can assume Stark has an ancient camera and your first input will be the day for date (01/01/0001) and then followed by any date on which Stark wants to find out the number of stars in the sky.
14 |
15 | ## Explanation
16 |
17 |
18 |
19 | ```\theMysteryOfSky> python theMysteryOfSky.py```
20 |
21 | ```Wednesday```
22 |
23 | ```11/11/2054```
24 |
25 | Output :
26 |
27 | ```Camera is Discharged```
28 |
--------------------------------------------------------------------------------
/theMysteryOfSky/theMysteryOfSky.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deepspraj/CodeVita-Exam/513274f1e9733e5b96a78de0f3a65a30df9d9284/theMysteryOfSky/theMysteryOfSky.pdf
--------------------------------------------------------------------------------
/theMysteryOfSky/theMysteryOfSky.py:
--------------------------------------------------------------------------------
1 | ##
2 | # @author Deepak Prajapati
3 | # @email deepprajapati01@gmail.com
4 | # @create date 2020-08-01 11:53:41
5 | ##
6 |
7 | import datetime
8 | from os import system
9 |
10 | today = input()
11 | date, month, year = map(int, input().split('/'))
12 |
13 | today = today.lower()
14 |
15 | isValidDate = True
16 | confirm = False
17 | weekDays= ['monday', 'tuesday', 'wednesday', 'thursday', 'friday']
18 |
19 | for day in weekDays:
20 | if(day == today):
21 | confirm = True
22 | break
23 |
24 | try :
25 | datetime.datetime(year,month,date)
26 |
27 | except ValueError :
28 | print ("Invalid Date")
29 | exit()
30 |
31 | if(isValidDate and confirm) :
32 |
33 | firstDate = datetime.date(year, 1, 1)
34 | lastDate = datetime.date(year, month,date)
35 | daysCount = lastDate - firstDate
36 | totalDays = daysCount.days + 1
37 | countOfStars = totalDays % 50
38 |
39 | totalWeeks = totalDays // 7
40 | extraDays = totalDays % 7
41 |
42 | if (extraDays == 6):
43 | extraDays = 5
44 |
45 | days = (totalWeeks * 5) + extraDays
46 | discharge = days % 4
47 |
48 | if (discharge != 0):
49 | print(countOfStars + 1)
50 | system('Pause')
51 |
52 | else:
53 | print('Camera is Discharged')
54 | system('Pause')
55 | else :
56 | print ("Invalid Day")
57 | system('Pause')
--------------------------------------------------------------------------------
/theVitaSum/README.md:
--------------------------------------------------------------------------------
1 | # The Vita Sum
2 |
3 | The question was asked in Codevita Examination 2016
4 |
5 | ## Problem Statement
6 |
7 | Tom the cat is brushing up his Math skills. He has a bag containing N balls of different colors. Now Tom can randomly pick any even number of balls from the bag. Tom wants to find out the sum of all such combinations of balls that he can pull out from the bag. He can pull out at max K balls in one pick.
8 |
9 | ## Explanation
10 |
11 | We need to find every combinations possible for total number of balls (N) to every even multiple of the number of choosing balls (K).
12 |
13 | At last print sum obtained by summation of combinations.
14 |
15 |
16 |
17 | ```\theVitaSum> python theVitaSum.py```
18 |
19 | ```33 7```
20 |
21 | Output :
22 |
23 | ```1149017.0```
24 |
--------------------------------------------------------------------------------
/theVitaSum/theVitaSum.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deepspraj/CodeVita-Exam/513274f1e9733e5b96a78de0f3a65a30df9d9284/theVitaSum/theVitaSum.pdf
--------------------------------------------------------------------------------
/theVitaSum/theVitaSum.py:
--------------------------------------------------------------------------------
1 | ##
2 | # @author Deepak Prajapati
3 | # @email deepprajapati01@gmail.com
4 | # @create date 2020-08-01 14:52:19
5 | ##/
6 |
7 | from math import factorial as fact
8 | import os
9 |
10 | n, k = map(int, input().split(' '))
11 |
12 | if (k <= n):
13 |
14 | answer = 0
15 |
16 | for i in range (0,k+1,2):
17 |
18 | tempAnswer=fact(n)/(fact(n-i)*fact(i))
19 | answer=answer+tempAnswer
20 |
21 | print(answer)
22 | os.system('Pause')
--------------------------------------------------------------------------------
/traceTheRats/README.md:
--------------------------------------------------------------------------------
1 | # Trace The Rats
2 |
3 | The question was asked in Codevita Examination 2014
4 |
5 | ## Problem Statement
6 |
7 | Given a square maze (A) of dimension N, every entry (A[i][j]) in the maze is either an open cell 'O' or a wall 'X'. A rat can travel to its adjacent locations (left, right, top and bottom), but to reach a cell, it must be open. Given the locations of R rats, can you find out whether all the rats can reach others or not?
8 |
9 | ## Explanation
10 |
11 | The logic is explained as follow:
12 |
13 | 1. At given location of rats, we need to check whether it is open cell or not.
14 |
15 | 2. If there is an open cell at any of the 4 surrounding then rat can move else the rat can't.
16 |
17 |
18 |
19 | ```\traceTheRats> python traceTheRats.py```
20 |
21 | ```4```
22 |
23 | ```x o o x```
24 |
25 | ```o x x o```
26 |
27 | ```x o x o```
28 |
29 | ```o x o x```
30 |
31 | ```3```
32 |
33 | ```1 2```
34 |
35 | ```2 4```
36 |
37 | ```3 2```
38 |
39 | Output :
40 |
41 | ```Yes```
42 |
43 | ```Yes```
44 |
45 | ```No```
46 |
--------------------------------------------------------------------------------
/traceTheRats/tempCodeRunnerFile.py:
--------------------------------------------------------------------------------
1 | ##
2 | # @author Deepak Prajapati
3 | # @email deepprajapati01@gmail.com
4 | # @create date 2020-07-30 00:57:48
5 | ##
6 |
7 | import os
8 |
9 | def confirmation(x,y):
10 | temp1 = temp2 = temp3 = temp4 ="X"
11 | count = 0
12 |
13 | if(matrix[x][y] == 'O'):
14 | try:
15 | temp1 = matrix[x][y-1]
16 | temp2 = matrix[x][y+1]
17 | temp3 = matrix[x-1][y]
18 | temp4 = matrix[x+1][y]
19 | except:
20 | print(end='')
21 | if((temp1 == 'O') or (temp2 == 'O') or (temp3 == 'O') or (temp4 == 'O')):
22 | count += 1
23 |
24 | if(count == 1):
25 | print("Yes")
26 | else:
27 | print("No")
28 |
29 | n = int(input())
30 |
31 | matrix = []
32 |
33 | for i in range (n):
34 | temp = list(input().split(' '))
35 |
36 | if(len(temp) == n):
37 | for i in range (n):
38 | temp[i] = temp[i].upper()
39 | else:
40 | print('The input are not according to conditions ')
41 | exit()
42 | if(len(temp) == n):
43 | matrix.append(temp)
44 |
45 | noOfRats = int(input())
46 | location = []
47 |
48 | for rat in range (noOfRats):
49 | x, y = map(int, input().split(' '))
50 | if( x and y <= n ):
51 | location.append([x,y])
52 |
53 | for i in range (len(location)):
54 | confirmation(location[i][0]-1,location[i][1]-1)
55 |
56 |
57 |
58 | os.system('Pause')
--------------------------------------------------------------------------------
/traceTheRats/traceTheRats.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deepspraj/CodeVita-Exam/513274f1e9733e5b96a78de0f3a65a30df9d9284/traceTheRats/traceTheRats.pdf
--------------------------------------------------------------------------------
/traceTheRats/traceTheRats.py:
--------------------------------------------------------------------------------
1 | ##
2 | # @author Deepak Prajapati
3 | # @email deepprajapati01@gmail.com
4 | # @create date 2020-07-30 00:57:48
5 | ##
6 |
7 | #import os
8 |
9 | def confirmation(x,y):
10 | temp1 = temp2 = temp3 = temp4 ="X"
11 | count = 0
12 |
13 | if(matrix[x][y] == 'O'):
14 | try:
15 | temp1 = matrix[x][y-1]
16 | except:
17 | print(end='')
18 | try:
19 | temp2 = matrix[x][y+1]
20 | except:
21 | print(end='')
22 | try:
23 | temp3 = matrix[x-1][y]
24 | except:
25 | print(end='')
26 | try:
27 | temp4 = matrix[x+1][y]
28 | except:
29 | print(end='')
30 |
31 | if((temp1 == 'O') or (temp2 == 'O') or (temp3 == 'O') or (temp4 == 'O')):
32 | count += 1
33 |
34 | if(count == 1):
35 | print("Yes")
36 | else:
37 | print("No")
38 |
39 | n = int(input())
40 |
41 | matrix = []
42 |
43 | for i in range (n):
44 | temp = list(input().split(' '))
45 |
46 | if(len(temp) == n):
47 | for i in range (n):
48 | temp[i] = temp[i].upper()
49 | else:
50 | print('The input are not according to conditions ')
51 | exit()
52 | if(len(temp) == n):
53 | matrix.append(temp)
54 |
55 | noOfRats = int(input())
56 | location = []
57 |
58 | for rat in range (noOfRats):
59 | x, y = map(int, input().split(' '))
60 | if( x and y <= n ):
61 | location.append([x,y])
62 |
63 | for i in range (len(location)):
64 | confirmation(location[i][0]-1,location[i][1]-1)
65 |
66 |
67 |
68 | #os.system('Pause')
--------------------------------------------------------------------------------
/whereMyCar/README.md:
--------------------------------------------------------------------------------
1 | # Where's My Car
2 |
3 | The question was asked in Codevita Examination 2016
4 |
5 | ## Problem Statement
6 |
7 | The year is 2050. The population surge has taken over our metropolitan cities. High rise buildings are on a rise. And as usual, with the increase in population, the problem of parking in the city has increased manifold.
8 |
9 | To reduce the problem of parking, the government has built multi-storey parking lots all over the city. Imagine the city as an X-Y grid. And there are roads connecting all the neighbouring grid points except diagonals. And there is a pre-defined intersection interval **'I'** for parking lots such that at every I th intersection, there is a parking lot, starting from (0,0). For example, for a city of grid size 4×7 and I=3, you’ll have 6 parking lots at (0,0), (0,3), (0,6), (3,0), (3,3) and (3,6).
10 |
11 | Now all the cars have been fitted with self-driving mechanism. So whenever you get out of a car at any point in the grid, it will choose the nearest parking lot and automatically drive to it. If two parking lots are at equal distance from where you left, it will choose the parking lot with the lowest X-coordinate first, and if X-coordinates are same, the lowest Y-coordinate.
12 |
13 | At the parking lot, the cars will start getting parked from the ground floor and in the first available slot. As each floor gets filled up, newer cars will start parking on floors above them. Assume all the parking lots in the city have unlimited number of floors and a common maximum capacity of each floor **'C'**.
14 |
15 | Now whenever the owner wants to know where his car is parked or wants to retrieve it, he’ll open the app ‘Where’s my car!’ and insert his car number and the app will tell him the coordinates of the parking lot, the floor number and the slot number.
16 |
17 | ## Explanation
18 |
19 | The Logic applied precisely is explained as follows:
20 |
21 | 1. Get the matrix and plot the Parking Lots according to the user input.
22 |
23 | 2. Once, the parking lots are located, create a dictionary with the key as the lots location.
24 |
25 | 3. Get the data from the user whether the car is here for parking or retrieval.
26 |
27 | 4. According to the users input, park the car at the nearest parking lot.
28 |
29 | 5. For retrieval checks the location of the car in the dictionary.
30 |
31 | 6. As soon as location obtained then print the key of the dictionary where the car is found i.e. the location of the parking lot.
32 |
33 | 7. For the count of the floor just use divide the index by the capacity where the car was located and for the count of the car at that floor use modulus operation.
34 |
35 |
36 | **Note: The source code don't support multiple areas (i.e. no more than one city area) else tried the program may crash.**
37 |
38 |
39 |
40 | ```\whereMyCar> python wheresMyCar.py```
41 |
42 | ```7 7 2 2```
43 |
44 | ```10```
45 |
46 | ```P 3 2 MH12DE1433```
47 |
48 | ```P 5 3 DL04AF4943```
49 |
50 | ```P 5 5 KL45DD2002```
51 |
52 | ```R DL04AF4943```
53 |
54 | ```P 1 6 MH06EF3259```
55 |
56 | ```R MH12DE1433```
57 |
58 | ```P 3 6 UP16CD1996```
59 |
60 | ```R KL45DD2002```
61 |
62 | ```R MH06EF3259```
63 |
64 | ```P 4 6 GJ03MW8855```
65 |
66 | Output :
67 |
68 | ```16```
69 |
70 | ```4 2 0 1```
71 |
72 | ```2 2 0 1```
73 |
74 | ```4 4 0 1```
75 |
76 | ```0 6 0 1```
77 |
--------------------------------------------------------------------------------
/whereMyCar/wheresMyCar.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deepspraj/CodeVita-Exam/513274f1e9733e5b96a78de0f3a65a30df9d9284/whereMyCar/wheresMyCar.pdf
--------------------------------------------------------------------------------
/whereMyCar/wheresMyCar.py:
--------------------------------------------------------------------------------
1 | ##
2 | # @author Deepak Prajapati
3 | # @email deepprajapati01@gmail.com
4 | # @create date 2020-07-16 18:16:23
5 | # @modify date 2020-07-16 20:47:01
6 | ##
7 |
8 | import math as ms
9 | import os
10 |
11 | row, col, parkId, cap = map(int,input().split(' '))
12 | matrix = [[0 for i in range (col)] for j in range (row)]
13 | dataBase = {}
14 |
15 | def parking(x,y,carNumber,dataBase):
16 | locationX = locationY = 0
17 | for i in range(x+1):
18 | for j in range(y+1):
19 | if(matrix[i][j] == 'PL'):
20 | locationX = i
21 | locationY = j
22 | if(dataBase.get((locationX,locationY)) == ''):
23 | tempData = [carNumber]
24 | else:
25 | tempData = [dataBase.get((locationX,locationY)), carNumber]
26 | dataBase[locationX,locationY] = tempData
27 |
28 | def retreival(carNumber,dataBase,cap):
29 | for i in range (row):
30 | for j in range (col):
31 | try:
32 | currBase = dataBase.get((i,j))
33 | for k in range (len(currBase)):
34 | if(currBase[k] == carNumber):
35 |
36 | print(i, j, ms.floor(k/cap),(k%cap)+1)
37 | return None
38 | except:
39 | print(end='')
40 | parkingLots = 0
41 |
42 | for i in range (row):
43 | for j in range (col):
44 | if (i%parkId == j%parkId == 0):
45 | dataBase[i,j] = ''
46 | matrix[i][j] = 'PL'
47 | parkingLots += 1
48 |
49 | testCase = int(input())
50 |
51 | events = []
52 | retreivals = []
53 |
54 | for i in range(testCase):
55 | events = input().split(' ')
56 | if(events[0] =='P'):
57 | parking(int(events[1]),int(events[2]),events[3],dataBase)
58 | elif(events[0] == 'R'):
59 | retreivals.append(events[1])
60 |
61 | print(parkingLots)
62 | for j in range (len(retreivals)):
63 | retreival(retreivals[j],dataBase,cap)
64 | os.system('Pause')
--------------------------------------------------------------------------------
/zombieWorld/README.md:
--------------------------------------------------------------------------------
1 | # Zombie World
2 |
3 | The question was asked in Codevita Examination 2014
4 |
5 | ## Problem Statement
6 |
7 | Zoya has developed a new game called Zombie World. The objective of the game is to kill all zombies in given amount of time. More formally,
8 |
9 | - **N** represents the total number of zombies in the current level
10 |
11 | - **T** represents the maximum time allowed for the current level
12 |
13 | - **P** represents the initial energy level a player starts with
14 |
15 | - **Ei** defines the energy of the i-th zombie
16 |
17 | - **D** defines the minimum energy the player needs, to advance to the next level
18 |
19 | When a player energy is greater than or equal to the i-th zombie's energy, the player wins. Upon winning, the player will be awarded with an additional energy equal to the difference between current zombie energy and the player energy.
20 |
21 | One unit of time will be taken to complete the fight with a single zombie.
22 |
23 | Rules of the game: -
24 |
25 | - At any given time, a player can fight with only one zombie
26 |
27 | - Player is allowed to choose any one zombie to fight with.
28 |
29 | Your task is to determine whether the player will advance to the next level or not, if he plays optimally.
30 |
31 | ## Explanation
32 |
33 | The problem is an easy.
34 |
35 | The logic is explained as follows:
36 |
37 | 1. It is necessary that initial energy of the player should always be greater than or equal to the first zombie in the sequence to completely kill the one.
38 |
39 | 2. The player kills the first zombie and gain health equal to difference of the energy of the zombie and the player.
40 |
41 | 3. Repeat the above two steps to kill all zombies and gain the energy.
42 |
43 | 4. After killing all the zombies, the health of the player should be equal to or greater than the energy required to advance the player to next level.
44 |
45 | 5. If above condition satisfy then print Yes else No.
46 |
47 |
48 | **Note: The player fights all the zombies according to sequence which user has provided.**
49 |
50 |
51 |
52 | ```\zombieWorld> python zombieWorld.py```
53 |
54 | ```1```
55 |
56 | ```5 6```
57 |
58 | ```56 86 23 14 89```
59 |
60 | ```63 200```
61 |
62 | Output :
63 |
64 | ```Yes```
65 |
--------------------------------------------------------------------------------
/zombieWorld/zombieWorld.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/deepspraj/CodeVita-Exam/513274f1e9733e5b96a78de0f3a65a30df9d9284/zombieWorld/zombieWorld.pdf
--------------------------------------------------------------------------------
/zombieWorld/zombieWorld.py:
--------------------------------------------------------------------------------
1 | ##
2 | # @author Deepak Prajapati
3 | # @email deepprajapati01@gmail.com
4 | # @create date 2020-07-30 15:24:28
5 | ##
6 |
7 | import os
8 |
9 | def zombieWorld(n, t, e, p, d):
10 |
11 | for i in range (len(e)):
12 | if (e[i] <= p):
13 | temp = (p - e[i])
14 | p += temp
15 |
16 | if((p >= d)):
17 | print('Yes')
18 | else:
19 | print('No')
20 |
21 | testCase = int(input())
22 |
23 | energyOfZombies = []
24 | zombies = []
25 | time = []
26 | playerEnergy = []
27 | advanceLevel = []
28 |
29 | if(0 < testCase <= 10):
30 | for test in range (testCase):
31 | instantZombies, instantTime = map(int, input().split(' '))
32 |
33 | if((0 < instantZombies <= 50) and (0 < instantTime <= 100)):
34 | zombies.append(instantZombies)
35 | time.append(instantTime)
36 |
37 | energies = list(map(int, input().split(' ')))
38 |
39 | if (len(energies) == instantZombies):
40 | energyOfZombies.append(energies)
41 |
42 | instantPlayerEnergy, minimumEnergy = map(int, input().split(' '))
43 |
44 | if ((0 < instantPlayerEnergy <= 2000) and (0 < minimumEnergy <= 500)):
45 | playerEnergy.append(instantPlayerEnergy)
46 | advanceLevel.append(minimumEnergy)
47 |
48 | if (len(energyOfZombies) == testCase):
49 | for i in range (testCase):
50 | try:
51 | zombieWorld(zombies[i],time[i],energyOfZombies[i],playerEnergy[i],advanceLevel[i])
52 | except IndexError:
53 | print('Test Case ' + str(i+1) + ' failed due inappropriate input')
54 | os.system('Pause')
55 | else:
56 | print('Provided Inputs are not according to the conditions')
--------------------------------------------------------------------------------