0% found this document useful (1 vote)
164 views

Cattleways Solutions Pvt. LTD.: Attempt The Two Problems

The document provides instructions for candidates to complete two coding problems within 120 minutes. For problem 1, candidates are asked to write an algorithm to calculate the maximum number of circles that can fill a square area, along with the coordinates of each circle. For problem 2, candidates must write a program to map a list of input numbers to an output list by scaling the values linearly between two given numbers. Candidates are asked to submit their solutions in a folder with readme files explaining how to run their code.

Uploaded by

44Pratyush Raj
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
164 views

Cattleways Solutions Pvt. LTD.: Attempt The Two Problems

The document provides instructions for candidates to complete two coding problems within 120 minutes. For problem 1, candidates are asked to write an algorithm to calculate the maximum number of circles that can fill a square area, along with the coordinates of each circle. For problem 2, candidates must write a program to map a list of input numbers to an output list by scaling the values linearly between two given numbers. Candidates are asked to submit their solutions in a folder with readme files explaining how to run their code.

Uploaded by

44Pratyush Raj
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Cattleways Solutions Pvt. Ltd.

Instructions

 Attempt the two problems.


Cattleways Solutions Pvt. Ltd.

 Use Codechef Online IDE - https://www.codechef.com/ide or you can choose your own from that
you can download the code.

 The combined time for both the problems is 120 minutes


 You are free to use any common programming language of your choice, not something that you’ve
invented. You may use different languages for the two problems if you wish to.
 Avoid the use of any specialized libraries or frameworks that solves the problem as a BlackBox.
 When solving using HTML/javascript or other languages it is OK to use jquery or other libraries that
help manipulate the DOM or other functions etc. easily. The idea here is that the core algorithm
asked to be solved in the problem should not be derived from an existing library.
 The problems are simple enough to be solved quite rapidly. Consideration would also be given to
code that is efficient and to the design of a solution to allow further extension. Use your time
wisely.
 During the tech interview round (if you are selected), expect questions around extending your
approach to scale or adapt the solutions to other similar problems without having to change too
much of the existing code.
 Try to use modular and good program design principles.
 For submission of the solutions.
 Create a folder and Name it <yourname>.
 Download the code from Codechef IDE. Place a copy of your resume in the above folder for us to
refer to it quickly.
 Upload respective code file(s) of problem_1 and problem_2, inside the above folder.
 Place a readme.txt file for each of the two problems mentioning the programming language and
any special instructions to execute the program. (eg. if your code is a standalone solution.html file,
instructions could be: open the solution.html file in your web browser, etc .....)
 Finally, compress the <yourname> folder and mail it to [email protected]. Put subject as “Coding
Test”
 There will be some grace time for the email to reach us. But that is a secret. So relax. :)

 Lets code!

All the Best!


Cattleways Solutions Pvt. Ltd.

Problem 1
Fill Circles

Implement an alogirithm to achieve something as described below.


Given a square of side (S) and circle radius (R) [S >= 4R]. Write a program that calculates the
maximum number of circles that may fill up the square and calculate their coordinates such that
all the circles fall within the boundary of the square and are equally placed from each other,
occupying the entire square fully. The square may be moved at an offset defined by the Top and
Left parameters as shown below. You may use (x,y) to define the offset if (0,0) is your bottom left.

The below images are just for representation. Your output may look different. Even a program
which does not draw the objects but calculates the co-ordinates is acceptable.
Cattleways Solutions Pvt. Ltd.

Problem 2
Map Values

Write an program that reads a list of numbers input_list (from a file or any other source such as a
html textarea). Now given two values (P,Q) it maps the input_list to another output_list using (P,
Q), both inclusive, as the range.
In other words, P maps to the lowest number in the input_list and Q maps to the highest number
in the input_list and all other values in between, from the input_list is scaled up or down linearly.

Eg for P = 1 and Q = 5.
input_list : 1, 2, 3, 4, 5
maps to output_list : 1,
2, 3, 4, 5

whereas for P = 5 and Q = 1 same input_list


as above maps to : 5, 4, 3, 2, 1

Have a careful look at some of the test cases below.


Cattleways Solutions Pvt. Ltd.

--------- End of Document ------

You might also like