Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
22 views2 pages

Sample Question 1

The document outlines the instructions and rules for a coding test, including time management, coding practices, and error handling. It presents two coding questions: creating a magic square of a given order and determining the minimum number of attempts to find a critical floor using eggs in a K-floored building. Participants must adhere to the guidelines and submit their solutions within the specified time limit.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views2 pages

Sample Question 1

The document outlines the instructions and rules for a coding test, including time management, coding practices, and error handling. It presents two coding questions: creating a magic square of a given order and determining the minimum number of attempts to find a critical floor using eggs in a K-floored building. Participants must adhere to the guidelines and submit their solutions within the specified time limit.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

NAME: _____________________________

DOB: _____________________________
COLLEGE ID: _______________________
COLLEGE : _______________________
BRANCH : ________________________

Round 1: Coding Question


Instructions:
1) Understand the coding questions at the start of the session. If you have any questions, you must ask
only the invigilator for clarification.
2) Time Limit: 3 Hours including the evaluation. The start and end time will be communicated by the
invigilator. Manage your time effectively to complete all the questions within the given time frame.
3) Use C or Python for coding. Don't switch between languages during the test.
4) Use of Libraries and External Resources: Unless specified otherwise, avoid using external libraries or
resources beyond what's provided in the standard library of the chosen programming language.
5) Coding Style: Follow good coding practices and maintain a clean and readable code style. Use
meaningful variable names, proper indentation, and comments to explain complex code sections.
6) Function and Variable Naming: Choose descriptive names for functions and variables that accurately
reflect their purpose and usage. Avoid using single-letter variable names unless they are standard
conventions (e.g., i, j, k for loop counters).
7) Input/Output Format: Ensure that your program reads input from stdin or command-line arguments as
specified and outputs results to stdout in the required format. Pay attention to details such as
whitespace, newline characters, and formatting.
8) Error Handling: Implement error handling where necessary, especially for cases where input may be
invalid or unexpected. Handle edge cases gracefully and provide informative error messages if
applicable.
9) Testing: Test your code thoroughly using sample inputs and edge cases to ensure correctness. Check
for off-by-one errors, boundary conditions, and corner cases that might lead to unexpected behaviour.
10) Malpractices: Write your solutions independently without copying code from external sources or
collaborating with others during the test. If found guilty, you will be disqualified.
11) Submission: Submit your solutions within the given time limit. Double-check your code and ensure
that all test cases pass before submitting. Once submitted, you may not be able to make further changes.
12) Electrifex has full discretion to take actions for the smooth conduct and in the evaluation of the coding
round.

1|Page
EFX/240301/B

QUESTION 1
A magic square of order n is an arrangement of n2 numbers, usually distinct integers, in a square,
such that the n numbers in all rows, all columns, and both diagonals sum to the same constant. A
magic square contains the integers from 1 to n2. Create a magic square of a given order N.
SAMPLE INPUT 1 SAMPLE OUTPUT 1
Magic Square of order N = 3 2 7 6
9 5 1
4 3 8
QUESTION 2
You are given N identical eggs, and you have access to a K-floored building from 1 to K. There
exists a floor f where 0 <= f <= K such that any egg dropped from a floor higher than f will
break, and any egg dropped from or below floor f will not break.
There are few rules which are given below.
a) An egg that survives a fall can be used again.
b) A broken egg must be discarded.
c) The effect of a fall is the same for all eggs.
d) If the egg doesn't break at a certain floor, it will not break at any floor below.
e) If the eggs break at a certain floor, it will break at any floor above.
f) Return the minimum number of moves to determine with certainty what the value of f is.
Your Task: Complete the function eggDrop() which takes two positive integer N and K as input
parameters and returns the minimum number of attempts you need in order to find the critical floor.
SAMPLE INPUT 1 SAMPLE OUTPUT 1
N = 1 2
K = 2
Explanation:
a) Drop the egg from floor 1. If it breaks, we know that f = 0.
b) Otherwise, drop the egg from floor 2. If it breaks, we know that f = 1.
c) If it does not break, then we know f = 2.
d) Hence, we need at minimum 2 moves to determine with certainty what the value of f is.

SAMPLE INPUT 2
N = 2, K = 10 SAMPLE OUTPUT 2
4
*******

2|Page

You might also like