2025-FEB-Coding-FY-Induction-Paper
2025-FEB-Coding-FY-Induction-Paper
February 2025
Coding Subsystems - First Year
General instructions:
A. Attempt as many questions as you can.
B. Logical justification for answers is expected.
C. The final solution is not important, your approach is!
D. Write down your thought process for solving the questions.
E. It is NOT compulsory to answer all the questions, but try to attempt each question
even if you don't get the final answer.
F. You may use any source of information to solve the questions, but provide a
reference at the end of the solution. Please ensure that this source is not "the
answer sheet of another candidate". Don't copy from the internet, you may use it as
a reference.
G. For physics questions, solutions in a .txt file or a single .pdf of photos will be
acceptable.
S. In case you have any doubts, please feel free to contact us:
Anvay Joshi: 8888424146
Amruni Mehta: 7020727780
Physics
1. You are on a space station and you have a big contract from NASA to place satellites
in orbit. The space station has a circular orbit, and its altitude is 500 km above the
earth's surface. You open the station’s bay door and grab your first satellite, which has
a mass of 1000kg, with tremendous effort you hurl it into orbit with a force of 2000
N, applied in the direction of motion, over 1 meter. What speed does the satellite
attain with respect to the space station? You can consider that the satellite's mass is
negligible when compared to that of the space station.
2. Bob built a satellite. He attached a wheel to the shaft of a motor and he put this
assembly inside the satellite with only the motor in contact with the satellite. He
performed following experiments:
a. He tested the satellite on the Earth by keeping the satellite on the table and
rotating the wheel.
b. He performed a similar testing in a Zero-gravity chamber with satellite in
gravity-less environment.
Both of these tests were done with the axis of the wheel passing through the centre of
mass first, and then with the wheel offset by some distance from the centre of mass.
Predict the results observed in above cases.
3. Murph has two permanent magnets which she has to store in space. However, she is
not aware of the most suitable configuration in which he must store it. So she stores it
in two different configurations shown. Which configuration is suitable according to
you? Why?
Coding
Ensure that you add comments wherever necessary to explain your logic.
1. Given two strings, interweave their characters such that the first two characters come
from each string, followed by the next two characters from each string, then the next
three, and so on. If one string is shorter than the other, it wraps around and continues
from the beginning of that string, until the length of the new string is equal to length
str1 + str2.
Example 1:
str1 = "abcdefgh"
str2 = "12345678"
Result: "a1bc23def456gh78"
Example 2:
str1 = "abc"
str2 = "1234"
Result: "a1bc23a4"
2. Ryan is playing a game where he starts with x coins. At certain points in the game, he
has to spend some coins to progress to the next level. During the game, he can also
collect more coins. If at any point his coin count becomes less than 1, he loses the
game. Your task is to determine the minimum starting value of x such that Ryan will
always win the game, i.e., he will never run out of coins at any point during the game.
Example:
n = 5: There are 5 levels in the game.
The list of coin changes at each level is: [-2, 1, -3, 2, 1].
Example: "hi"
4. An array contains all kinds of integers i.e. positive integers, negative integers and
zero's.
Write a program to remove all the zeros from the array and append them to the end of
the array. The integer may be zero itself or one of the digits may be zero. The
respective order of non-zero elements/digits should not change.
Example:
Input:
3 3 1 23 431 -123 12 0 140 1302 0 12
Output:
3 3 1 23 431 -123 12 14 132 12 0 0 0 0
5. You are given a string s of length n, consisting of characters 'a' and 'b'. Define:
a. AB(s) as the number of times "ab" appears as a substring in s.
b. BA(s) as the number of times "ba" appears as a substring in s.
In one step, you can change any character in s to 'a' or 'b'. Find the minimum number
of operations needed to make AB(s) = BA(s).
Example 1:
Input: abb
Output: 1 (change to aba or bbb)
Example 2:
Input: ababa
Output: 0 (no change required)
6. You are given three unsorted linked lists A, B, C. Each linked list contains unique
integers. Your task is to merge these three lists into a single linked list following this
specific zigzag pattern:
a. Pick the smallest element from A.
b. Pick the largest element from B.
c. Pick the smallest element from C.
d. Pick the largest element from A.
e. Pick the smallest element from B.
f. Pick the largest element from C.
g. Continue alternating between smallest and largest. If only one list remains,
append the remaining elements in the order in which they appear in the list.
h. Repeat this process until all the elements from all three lists are merged into
the final linked list. No element from any list should be repeated
Output: A single linked list that is the result of merging the three linked lists in the
zigzag pattern.
Example:
Input:
List A: 8 → 3 → 5 → 7
List B: 2 → 4 → 1 → 6
List C: 12 → 10 → 9 → 11
Output:
3 → 6 → 9 → 8 → 1 → 12 → 5 → 4 → 10 → 7 → 2 → 11
7. A blacksmith has chains of connected iron rings. He has to make a full chain
consisting of N complete rings. He has a set of chains already and he has to create a
long chain using these. He also doesn't want to use extra rings. But he can melt one
ring (from any position in a chain) to create a gap and then use this ring to link two
different chains. You have to help him to melt the minimum number of rings on the
existing chains to attach them all.
Example:
Input:
N=7 M=3
1 4 2 (M chains that add up to total N rings)
8. Write a Bash Script which will download any file from web, read contents and
display it on the command line. It should also print number of lines, words and
characters.
9. Given a string n representing an integer, return the closest integer (not including
itself), which is a palindrome. If there is a tie, return the smaller one.
The closest is defined as the absolute difference minimized between two integers.
Example 1:
Input: 123
Output: 121
Example 2:
Input: 1
Output: 0
Explanation: 0 and 2 are the closest palindromes but we return the smallest one.
10.Given an array of integers representing colors, where each color is represented by an
integer: 0 represents Red, 1 represents White, and 2 represents Blue. You need to sort
the array so that all the 0s come first, followed by all the 1s, and then all the 2s. This
must be done in a single pass through the array and in-place.
Example 1:
Input:
[2, 0, 1, 1, 0, 2, 1, 0]
Output:
[0, 0, 0, 1, 1, 1, 2, 2]