Programming Geek
Rated 4.1/5 based on 446 reviews

A Few Tips to Crack CodeVita 2014

-> Freshen up your data structure (stack, queue, linked list, graph etc ) and algorithm (Greedy, Divide and Conquer etc. ) concepts.

-> Revise API of your programming language.

->Solve previous year CodeVita’s question to get an overview of the problems asked in Codevita. Check previous year CodeVita’s questions here : http://goo.gl/Xv59SX and http://goo.gl/8MOLbF
->You must form the team before the deadline in order to participate in CodeVita 2014.

->Result depends on the following factors
Number of participants in a particular time interval.
Average number of question solved by a team.
Questions solved by maximum team.
Question solved by least team.
Complex problem (typically memory management related problems).

So, If a person solves only one problem and the number of participant are very few in that interval than he might qualify for the next round.

These are my interpretation based on experience of previous year’s CodeVita  and interaction with CodeVita 2013 organizing team thereafter.

->The contest will start on August 13, 2014 and last for 24 hours. The exact time will be displayed on Campus Commune a few days before.

->Every team will get 6 hour only within 24 hour time frame. If a team logins after last 6 hour then he will get remaining time only(not 6 hour ). Choose a proper 6 hour interval when you are free.

-> Properly set
coding environment on your machine.

-> Don’t use conio.h or process.h header file and related function if you are programming in C as these header files do not belong to gcc.

-> Each team member can separately login and submit the solution. So you can work on your individual machine and submit the solution.

-> You will get easy to complex problems. So identify the problem which you can solve first and later moves to complex one.

->Strictly follow the input/output format. You may find spelling mistakes and wrong order of input in test cases. Don’t bother, apply your common sense if you really want to solve that problem.

->Your result might not appear instantly due to heavy traffic so wait for a while to see the result or solve other problem in the mean time.

-> The programming environment is not as great as HackerRank or CodeChef. So you might not see the leader board. Although you may see number of users attempting a particular question which gets updated very slowly.

Still have queries? Leave a message below.


CodeVita 2013 Questions : Set2

Isotope Fusion
(Complex Problem)
Problem Statement:
Scientists recently found a new element X, which can have different isotopes upto an atomic value of 199. Speciality of element X is that when two atoms fuse they produce energy multiple of their atomic value and forms an atom with atomic value of their multiple modulus 199.
For Eg:
If atom1 with value 56 and atom2 with value 61 fuse.
They produce energy of 3416 KJ (56 * 61)
Resulting atom will have atomic value (56*61) mod 199 = 33
Scientists created a nuclear reactor to create energy by this method. Everyday they get several atoms of X from supplier in a particular sequence. Since this element highly radioactive they cant risk by changing its sequence. So each atom can fuse only with another atom nearby. Nevertheless scientists can choose order of fusion thereby maximizing total energy produced.
Now, for given sequence of atomic values, output maximum energy that can be produced.
Example
If sequence of atoms are
56,61, 2
Then they can produce 3416KJ by fusing 56&61 which results in an atom of value 33. Then they can fuse 33 and 2 to get energy of 66KJ. So total energy generated is 3482.
But if they cleverly choose to fuse atoms 61 & 2 first then they generate 122 KJ with a resulting atom of value 122. Then if they fuse 122 and 56, they can generate 6832 KJ. So total energy is 6954.
Hence Maximum energy that can be generated from this sequence is 6954.

Input Format
Input starts with a number specifying number of inputs(n) followed by n space separated integers specifying atomic values of n atoms.
Line 1
N,where N is the number of atoms in the sequence to be fused.
Line 2a1 a2 a3 .... an
where ai -> Atomic value of i th atom.
and two atoms are space delimited

Limits:
0 < ai < 199
1 < n < 1000

Output Format
Print Determinant of the input matrix rounded up to 3 digits after decimal point, on console in the format shown in table below
Line 1
For Valid Input
E,where E is Integer stating maximum energy that can be produced
For Invalid Input
INVALID INPUT

Sample Inputs and Outputs
Sr.no
Input
Output(Rounded upto Three Decimal digits)
1
3 15 75 60

8925
2JINVALID INPUT
33 15 0 6

INVALID INPUT
43 5 5 199

INVALID INPUT
5
4 15 75 60 4518515

(Note:-Please do not forget to end your program with a new line, else you may get a Compile Time Error from the Code Evaluation Engine
Note:-Participants submitting solutions in C language should not use functions from / as these files do not exist in gcc)



Brokerage

The current maximum intra-day brokerage offered is 0.03% for buying and 0.03% for selling.

Taxes

1. The service tax is of 10.36% only on brokerage.
2. The STT (Security Transaction Tax) is of 0.025% only selling amount.
3. The stamp duty on total turnover for a day which is 0.002%.
4. Finally you have to pay Regulatory charges on total turnover for a day which is 0.004%

Example:
Suppose the shares of Bank has been bought at Rs.315, quantity - 100 so the amount comes to Rs.315 x 100 = Rs.31500.
Your buying amount Rs.31500 (Rs.315x100 Qty shares) Brokerage charge
0.03% as brokerage on 31,500 which comes to Rs.9.45
Service Tax:
The service tax is 10.36% only on brokerage, so 10.36 % on Rs.9.45 comes to Rs 0.98.
Total charges you have pay on buying amount is:
The total brokerage + service tax which come to Rs.9.45 + Rs.0.98 = Rs.10.43
Your selling amount:

Suppose you sold Bank shares at Rs.316, Qty - 100 so the amount comes to Rs.31,600 (Rs.316 x 100 Qty shares)

Brokerage charge:

0.03% brokerage on 31600, comes to Rs.9.48 STT(Service Transaction Tax) only on selling amount
The STT (Service Transaction Tax) is 0.025% on selling amount (the selling amount is 31,600) which comes to Rs.7.9.
Total charges you have to pay on Selling amount = total brokerage + service tax + STT on selling amount is = Rs.9.48 + Rs.0.98 + Rs.7.9 = Rs.18.36
Total amount you have to pay on buying and selling is = Rs.10.43 (buying) + Rs.18.36 (selling) = Rs.28.79
Your total turn over is calculated by adding the buying amount and selling amount.
Buying amount is 31500 and selling amount is 31600 which adds up to Rs. 61300
Stamp duty is 0.002% and Regulatory charges are 0.004% which adds up to 0.006%
So on total turnover amount (Rs. 61300) the stamp duty and regulatory charges comes to Rs 3.8.
So the total amount you have to pay including brokerage and all taxes is only Rs 28.79 + 3.8 = 32.58

Conclusion

So now the conclusion is you are paying Rs.31.02 while you earned the profit of Rs.100.
So your profit is Rs 100-32.58 = 67.42
User has to enter brokerage tax in %. and buying amount and selling amount and quantity of the share.
Now calculate the total profit or loss in this transaction.

Write a program to compute Profit or Loss statement for Transactions.

Input Format:

Input contains three integers N, L, X in each line

Line1
Brokerage rate
Line 2
Buying amount
Line 3
Selling amount
Line 4
Quantity

Assume STT to be fixed at 0.025%, Service Tax to be fixed at 10.36%, Stamp-duty on total turn-over is fixed at 0.002% and Regulatory charge on total turn-over is 0.004%

Output Format:

Print Profit or Loss as applicable with respect to transaction , and in next line print amount profit/loss faced

Line 1
For Valid Input,print
Profit
Or
Loss

For Invalid Input,print
Invalid Input
Line 2
For Valid Input,print
Amount of Profit / Loss faced in transaction

Sample Test Cases:

SNo.InputOutput
1
0.03
315
316
100
Profit
67.42
1
0.03
315
@
100
Invalid Input
1
0.03
315
315.32
100
Loss
0.53


Note:

Participants submitting solutions in C language should not use functions from / as these files do not exist in gcc
Note:

This question is inspired by an example of Brokerage calculations provided at
http://www.stockmarketindian.com/calculate_brokerage_charges.html



Helloworld

Bob is a newbie to programming and while learning the programming language he came to came the following rules:
  1. Each program must start with '{' and will end with '}'.
  2. Each program must contain only one main program. Main program will start with '<' and will end with '>'.
  3. A program may or may not contain user defined fuctions but there is no limitation about the number of user definded functions present in the program. User defined program will start with '(' and will end with ')'.
  4. Loops are allowed only inside the functions (this function can be either main function or user defined function(s)). Every loop will start wih '{' and will end with '}'
  5. User defined function(s) are not allowed to define inside main function or user defined function(s).
  6. Nested loops (loop inside a loop) are allowed.
  7. Instructions can be defined any where inside the program.
  8. If any of the above conditions does not met, then the program will generate compilation errors.
  9. Today Bob has written his first program " Hello World ", but he is not sure about the correctness of the program now your task is to help him to find out whether his program will compile without any errors or not.

Input Format:

Each Input will contain a single line L, where L is a program written by Bob.


Line 1
L,where L is a single line program written by Bob.

Constraints:

L is a text and can be composed of any of the characters {, }, (, ) , <, >and P, where P will represent the instruction.
L will contain single spaced characters where each character will represent the each line of the program.
Number of characters in the text < = 10000

Output Format:

Line 1
For Valid Input,print
“No Compilation Errors“, if there is no compilation error

For Invalid Input,print

“Compilation Error“


Sample Input and Output

SNo.InputOutput
1
{ < > ( P ) }
No Compilation Errors
2
{ < { } > ( { } ) )
Compilation Errors
3
{ ( { } ) }
Compilation Errors

Note:

Participants submitting solutions in C language should not use functions from / as these files do not exist in gcc





Hexogonal Triangle

In NASA, two researchers, Mathew and John, started their work on a new planet, but while practicing research they faced a mathematical difficulty. In order to save the time they divided their work.
So scientist Mathew worked on a piece and invented a number computed with the following formula:
A Mathew number is computed as follows using the formula:
H(n) = n(2n-1)
And scientist John invented another number which is built by the following formula which is called John number:
T(n) = n(n+1)/2
Now Mathew and John are jumbled while combining their work. Now help them combine their research work by finding out number in a given range that satisfies both properties. Using the above formula, the first few Mathew-John numbers are:
1 6 15 28... …

Input Format:

Input consists of 3 integers T1,T2,M separated by space . T1 and T2 are upper and lower limits of the range. The range is inclusive of both T1 and T2. Find Mth number in range [T1,T2] which is actually a Mathew-John number.

Line 1
T1 T2 M,where T1 is upper limit of the range, T2 is lower limit of the range and M ,where Mth element of the series is required

Constraints:

0 < T1 < T2 < 1000000

Output Format:

Print Mth number from formed sequence between T1 and T2(inclusive).

Line 1
For Valid Input,print

Print Mth number from formed sequence between T1 and T2
Or
No number is present at this index

For Invalid Input,print

Invalid Input

Sample Input and Output

SNo.InputOutput
1
90 150 2
120
2
20 80 6
No number is present at this index
3
-5 3 a
Invalid Input

Note:

Participants submitting solutions in C language should not use functions from / as these files do not exist in gcc

CodeVita 2013 Questions : Set1

Problem: Query Engine
Implement operations similar to database operations in your favourite language. Think of these operations as operations that we use in SQL (Structured Query Language) that we run on databases. These operations will be implemented on files which can be treated as database tables. These files will consist of comma-separated values which can be considered as different columns in the table. A newline character in the file can be treated as a record delimiter.
Given the above background, write a program to implement the following operations viz. Join on two tables, Sort by, limit and result printing. Consider the following database schema to understand the problem better. Consider 2 tables

CollegeMaster -
UserMaster -
Constraints:
  1. collegeid is the primary key of CollegeMaster table
  2. userid is the primary key of UserMaster table
  3. collegeid in UserMaster is the foreign key to collegeid in CollegeMaster
  4. ctreference,email and username satisfies unique key constraint on UserMaster table
  5. Query on search attribute in UserMaster will always have Select clause comprising of columns in CollegeMaster and vice-versa.
  6. CollegeId need not be printed in either case since that is the only column on which 2 tables can be joined.
Your program should implement a SQL query, say for example like

Select userid, username, email, ctreference from usermaster, collegemaster where usermaster.collegeid = collegemaster.collegeid and usermaster.collegeid=1 sort by userid limit 0, 5;
OR
Select collegename, cityid, stateid from collegemaster, usermaster where collegemaster.collegeid =usermaster.collegeid and usermaster.userid=1;
Input Format:
Input will consists 5 items as described below.
Line 1

Absolute path to CollegeMaster file
Line 2

Absolute path to UserMaster file
Line 3

Either C or U, where C represents, search field is in CollegeMaster and
 
U represents, search field is in UserMaster.
Line 4

Name of the search attribute
Line 5

Value of the search attribute

File Format
CollegeMaster File Master
Column 1 – CollegeId
Column 2 – CollegeName
Column 3 – CityId
Column 4 – StateId

Columns are separated by “,”
 
UserMaster File Format
Column 1 – UserId
Column 2 – UserName
Column 3 – Email
Column 4 – CTReference
Column 5 – CollegeId

Columns are separated by “,”
Output:
Output of the program will be the filtered records that are returned as a result of a query. Records should be sorted by userid when printing query results where applicable. Maximum number of records to be printed is 5.
Example Output with query on Collegename:

1,Sachin Tendulkar,user1@gmail.com,CT20120000001
2,M S Dhoni,user2@gmail.com,CT20120000002
3,Virender Sehwag,user3@gmail.com,CT20120000003
6,Zaheer Khan,user4@gmail.com,CT20120000004
31,Ishant Sharma,user5@yahoo.com,CT20120000005
Example Output with query on CTReference: 

Kirti College, 1, 1
Note:
This is a sample data file only. Actual data file may contain more / less data, but is guaranteed to adhere to this format.

Sample Input and Output:
SNo.
Input
Output
1

Collegemaster.csv
Usermaster.csv
C
CollegeName
Kirti College

1,Sachin Tendulkar,user1@gmail.com,CT20120000001
2,M S Dhoni,user2@gmail.com,CT20120000002
3,Virender Sehwag,user3@gmail.com,CT20120000003
6,Zaheer Khan,user4@gmail.com,CT20120000004
31,Ishant Sharma,user5@yahoo.com,CT20120000005
2

Collegemaster.csv
Usermaster.csv
U
CTReference
CT20120000001

Kirti College, 1, 1
3

Collegemaster.csv
Usermaster.csv
@
4

Invalid Input
4

Collegemaster.csv
Usermaster.csv
U
CTReference
CT20120000007

Data unavailable





Problem : Loan Structuring
Develop a program to find EMI (Equated Monthly Installment) and the amortization schedule for loan repayment. Three primary inputs for doing loan arithmetic are Loan Amount, Rate of interest and Tenure. Rate of interest can vary over certain months and affect the tenure. Write a program to calculate EMI, total interest paid over entire tenure of the loan and amortization schedule. Amortization schedule is explained in text below.
This problem will take into account frequency of payment viz.
 MONTHLY/YEARLY/ DAILY. The EMI is payable at this frequency. The interest rate variation is captured in form of From Installment number to To Installment number. The interest rate may vary or may remain constant over the tenure of the loan repayment schedule.
Program should accept name of the file as input on console. The file will contain inputs such as loan amount, rate etc. See details in input specification section below. In case of a bad input, program should notify user with invalid input.
Information:
  • EMI are the payments one makes in order to pay off the loan. On a specific date every month,one needs to pay the EMI. EMI depends upon loan amount, interest rate, loan tenure and the frequency in which one wants to pay EMI i.e can be monthly/quarterly/yearly etc
  • Round off the interest paid to the nearest rupee.
  • EMI can be calculated using the formula:
EMI = (L*I)* {((1+I)^N) / ([(1+I)^N]-1)}
where
L = loan amount
I = interest Rate(rate per annum divided by 12)
^ = to the power of
N = Loan Period in months

Example
Mr. Gonsalves borrowed Rs 57,00,000 Lakhs (Rs 5.7 million) at 10% per annum for a tenure of 20 years with EMI payable monthly. According to his loan plan after 100 months for next 50 months, the rate of interest changes to 10.5.
So here, Loan amount=Rs 57,00,000 Lakhs (Rs 5.7 million) 
Rate of interest= 10
Tenure=240(20*12)
Frequency=MONTHLY
From Installment:100
To Installment:150
Rate of interest= 10.5
EMI calculated, using formula mentioned above is 55006.23376921851. Rounded off to two digits after decimal point, EMI becomes Rs 55006.23. Amortization schedule for this loan case looks similar to the table shown below :

Amortization Schedule:
InstNo.
Opening Principal
Installment Amount
Principal Component
Interest Component
Closing Principal
Rate Of Interest
1
5700000
55006.23
7506.23
47500
5692493.77
10
2
5692493.77
55006.23
7568.79
47437.45
5684924.98
10
3
5684924.98
55006.23
7631.86
47374.37
5677293.12
10
4
...
...
...
...
...

5






99
4569291.63
55006.23
16928.8
38077.43
4552362.83
10
100
4552362.83
55006.23
15173.06
39833.17
4537189.77
10.5
101
4537189.77
55006.23
15305.82
39700.41
4521883.95
10.5
245






246





10.5
247
54551.64
55006.23
54551.64
454.6
0
10.5


Total interest paid on 57,00,000 at rate 10.50 is 78,77,467.47 in 247 installments. While printing the output report interest paid rounded off to the nearest multiple of hundered (100). In this case it will be 78,77,500 .Refer section on Output Format for precise instructions.
Note, two things from the table and the sentence above
  1. Since the rate of change of interest is marked from 100th month to 150th month, but no additional information is provided about the rate from 151st month till the end of the tenure. Hence rate of interest in this case will remain as 10.5 until any explicit rate change, to take place later is provided. In this case, since no information is provided, rate will remain 10.5% until end of tenure.
  2. At the start of the problem, it was stated that the tenure is 240 months. But due to increase in rate of interest and no change in EMI, the tenure increased to 247 months. You are assured that rate of interest will never change in such a way that with the current EMI amount the loan can never be repaid. Such test cases are out of scope for this problem.

Input Format
Line 1
Name of the file from which inputs are to be taken. The input file format is described next.
Line 2
A particular installment number whose opening principle is to be calculated using amortization schedule.
Note:
The
 Input in file column in table below on Sample Test Cases is provided to help you visualize how the input file will look like.
File Format
Line 1
Loan Amount (L)
Line 2
Rate of Interest per annum (R) in percentage
Line 3
Tenure (N)
Line 4
Frequency of payment
Frequency can be MONTHLY/YEARLY/DAILY
for MONTHLY Rate of Interest =Rate of Interest per annum (R) /12
DAILY Rate of Interest=Rate of Interest per annum (R)/365

If there is a change of rate of interest then following lines will be a part of the input
Line 5
From installment
Line 6
To installment
Line 7
Changed Rate of Interest
Constraints
  1. Here:
0 <= L <= 10,000,000,000
0 <= R <= 100
1 <= N <= 1188
  1. In case of change of rate of interest, the To installment value should be greater than From installment value

Output Format
Line 1
For valid input,print
EMI amount rounded to 2 digits after decimal point
For Invalid input,print
Invalid Input
Line 2
For valid input,print
Opening Principal before installment X is Rs Y
where X is the input provided in Line 2 (installment number) and
Y is Prinicipal outstanding in Rs rounded to nearest multiple of hundered (100)
For Invalid input,print
Please Mention Frequency Of EMI As MONTHLY/YEARLY/DAILY
Line 3
Interest paid is Rs Z
where Z = interest paid over entire tenure rounded to nearest multiple of hundered (100)


Sample Input and Output
SR.no
Input
Input in File
Output
1
EMIinput.txt
25



15000
10.5
240
MONTHLY
 
200
220
11
221
240
12
EMI is Rs 149.76
Opening Principal before installment 25 is Rs 14500
Interest paid is Rs 21000
2
EMIinput.txt
23



1000
10
25
abc
Invalid Input
Please Mention Frequency Of EMI As MONTHLY/YEARLY/DAILY
3
EMIinput.txt
11
5
25
40
DAILY
??
Invalid Input
4
EMIinput.txt
12
1200000
25
 
40
DAILY
EMI is Rs 30423.11
Opening Principal before installment 12 is Rs 873300
Interest paid is Rs 16900






Problem : Expense Solver
5 friends share accommodation. Expenses between them are shared. They have a rule that expenses are shared equally among all friends those who are a party to that expense. Their problem is they are poor in math. Hence they end up fighting over expenses. Your job is to help them in splitting the expenses and prevent in-fighting. 

Write a program to help divide the expenses. The program should be generic enough such that number of members sharing accommodation can vary. Your program should take the following inputs and give the following output.

Assumptions:
The Person paying for a transaction is himself a party in that particular expense
Input Format:
Line 1 contains the name of the friends sharing the accomodation. Line 2 provides the number of trancations(T) to be accounted. Line 3 to line T+2 will give the details of the transactions and will contain the spender's name,the amount spent and the friends involved in the transactions
Line 1

N
1 N2…Nn 
where N
i is the name of all the friends sharing the accomodation,separated by white space character
Line 2

T
 
where T is the number of transactions
Line 3 to Line T+2

N
s1 A Np1 Np2  
where N
s is the spender, A is the amount spent in a particular transaction and Npi are the other friends involved in the transaction

Output Format: 
Line 1

For Valid Input, print
N
1 A1
N
2 -A2

N
n -An

where N
i is the name of the friend and Ai is the amount he has to recieve/pay. Negative(-) number represents payable.

Sample Inputs and Outputs:
SNo.
Input
Output
1


Pankaj Pranav Mayank Nihit Mukesh
5
Pankaj 600 Pranav Mayank
Pranav 450 Mayank Nihit
Mayank 300 Mukesh Pranav Nihit
Nihit 1200 Pranav Pankaj
Mukesh 3000 Pranav Pankaj Mayank

Pankaj -750.0
Pranav -1125.0
Mayank -875.0
Nihit 575.0
Mukesh 2175.0
2

Sagar Sumit Suresh
4
Sagar Sumit

Invalid Input







Problem : SQL Analysis
Given a proper SQL (Structured Query Language) statement, identify the objects and group by operations in the SQL statement. Assume SQL-92 standard specification to which all the input SQLs will adhere to. Assume that SQL queries are composed only on tables (no views). 
  1. Your program should implement a SQL Analyzer which will break up the query into number of tables and number of group by clauses.
  2. If a table is accessed more than once (say twice), print table name twice. Print table names in case-insensitive sorted order. (A-Z)
  3. Print group by statements in sorted order of the columns used in group by clause (A-Z)
Input Format:
Input will consists 1 item as described below.

Line 1

Absolute path to file containing the SQL query

Output Format:
Lets say, the SQL query in the input is

select count(uname),name from present_address pr,country cn,customer_details cd, address a
 
where a.addrid=cd.addrid and
 
a.adtid=pr.adtid and
 
cn.countryid=pr.countryid
group by name;
then,output should print the same query in first line of the output followed by the analysis.

select count(uname),name from present_address pr,country cn,customer_details cd,address a where a.addrid=cd.addrid and a.adtid=pr.adtid and cn.countryid=pr.countryid group by name;
Table : address
Table : country
Table : customer_details
Table : present_address
Group By : name
Note:
This is a sample data file only. Actual data file may different types of queries, but is guaranteed to adhere to SQL-92 format.

Sample Input and Output
SNo.
Input
Output
Comments
1

/tmp/query1.txt

select count(uname),name from present_address pr,country cn,customer_details cd,address a where a.addrid=cd.addrid and a.adtid=pr.adtid and cn.countryid=pr.countryid group by name;
Table : address
Table : country
Table : customer_details
Table : present_address
Group By : name

The entire SQL is Line 1.


Line 2 – 5 are names of tables used in the query, printed in sorted order (A-Z) of the tablename.

Next Line(s) is Group By




Problem : Pagination
Pagination is the process of dividing content into discrete pages. Pagination is common in Web-based applications, and is used for limiting the result set and displaying a limited number of records on the web page. 

For example, consider the Department-Employee scenario. If the search operation is performed on the basis of Department Id, and there are 100,000 employees per department, then it does not make sense to display the details of 100,000 employees in single page. So, pagination allows to display limited results e.g. 20 records per page. "Previous" and "Next" links or the Page numbers are usually provided on the user interface so that users can navigate to other pages.

Your task is to write a program for selecting the records that need to be displayed on user interface. Records should be filtered as per the input parameters, and should be sort-able by any field.Sort in asecending order.
Your program should extract the records from a file on the basis of input parameters. For example, if the input is (Department ID-10, Page Size-20, and Page Number -1), then the program should retrieve first set of 20 records for Department ID-10 sort-able by any field. If the input is (Department ID-10, Page Size-20, and Page Number -2), then the program should retrieve second set of 20 records.
 
Information:
  • Expected Volumes: Department Data File may have approx. 100,000 records per department ID. Page Size is expected to be less than 100 records.
  • Application also allows other search operations on the basis of Employee ID, Name ,Grade.Program should be able to sort on any of these fields
Input Format:
Line 1

Absolute file path
Line 2

C,D,S,N
  • Column(C) on which sort need to be happen
  • Department ID (D) is search Parameter
  • Page Size (S) is number of records that need to be displayed on UI e.g. 20
  • Page Number(N) is the number of Page which should be displayed e.g. 2 (2nd Page to be displayed)

File Format

Number of Columns-4
Order of Column -DEPT_ID,EMP_ID ,EMP_NAME,GRADE
Columns delimited by comma(,)
Example Department Data File:

DEPT_ID,EMP_ID,EMP_NAME,GRADE
1,1,Smith Frank,A
1,2,Manager Mike,C
1,3,Driver Danny,D
2,7,Bliss,B
2,8,Java,D
2,9,Kyte Kelly,B
1,4,Boat Tony,A
2,5,Louie Chef,B
2,6,Lawson,C
2,10,Baker Sarah,D
2,11,Smothers Sally,A
 
2,12,Silly Sall,C
2,13,Viper,B
2,14,Beck,B
2,15,Rambo,A

Note:
This is a sample data file only. Actual data file may contain more / less data, but is guaranteed to adhere to this format.
Output: 

Output of the program will be the filtered records that need to be displayed on UI (User Interface). Records should be sorted by Employee Names and should be filtered as per the input parameters.
Sample Input and Output
SNo.
Input
Output
Remark
1

Page.csv
2,2,3,2

2,8,Java,D
2,9,Kyte Kelly,B
2,10,Baker Sarah,D
Second Page with 3 records from ordered data of Dept ID-2. Ordered by Emp ID
2

Page.csv
a,b,c,d

Invalid Input
--
3

Page.csv
3,1,4,1,1

Invalid Input
--
4

Page.csv
3,1,4,1,1

Data Unavailable
Based on sample data above, DEPT_ID 9 does not exist. Hence data will be unavailable for this input.
5

Page.csv
4,1,2,1

1,1,Smith Frank,A
1,4,Boat Tony,A
First Page with 2 records from ordered data of Dept ID-1. Ordered by GRADE




Problem : Credits
Alan has recently joined an Engineering college. On the first day he came to know that each semester will contain N number of subjects and Di (where 1<=i<=N) is the credit associated with that particular subject. In order to be eligible for the next semester each student must get at least X number of credits from the current semester. After knowing this Alan became tensed and nervous, but after discussing with seniors he came to know that getting X number of credits from N number of subjects is easy if they concentrate on particular subjects rather than all subjects. But Alan is having preference list of subjects. As compared with others Alan will give more preference to the subjects listed in preference list.

Based on past results Alan expects pass percentage Pi (where i<=i<=N) for each subject. Now Alan needs to get X number of credits in the current semester. Can you please help the Alan to select the subjects on which he needs to concentrate on, to get exactly X number of credits.
Input Format:
First line of input contains a single integer N, number of subjects present in a current semester, next N lines follows each line contains Si, Di, Pi where Si is the name of the subject, Di is the credit associated with the particular subject, Pi is the pass percentage of the subject. After N lines next line contains X, number of credits needed and the final line will contain the Alan's preference list (N subjects, separated by a space).
Line 1

N , where N is the Number of subjects present in a current semester
Line 2

S1 D1 P1 ,
where S1 is the name of the subject
 
D1 is the credit associated with the particular subject and
 
P1 is the pass percentage of the subject
Si Di Pi
Line N+1

Sn Dn Pn
Line N+2

X , where X is the number of credits needed
Line N+3

S
1 S2…SN , where Si is the subjects of Alan according to his preference

Constraints:
1<=N<=25, where N is the number of subjects.
1<=|Di|<=100, where |Di| is the credits associated with the subject (where 1<=i<=N).
1<=X<=C (C=Sum of Di, where i=1, …, N), where X is the credits needed for next semester's promotion.
1<=|Si|<=50, where |Si| is the subject name length (where 1<=i<=N).
1<=Pi<=100, where Pi is the pass percentage of the subject (where 1<=i<=N).
Note:
  1. If there present multiple set of subjects, then print the first set with highest average pass percentage, and if there are any sets with same average pass percentage then select the set based on the preference list. Please print the subject names separated by a space.
  2. There will be at-least one way to get X number of credits.

Output:
Line 1

For Valid Input, print
A set of subjects among N subjects on which Alan needs to concentrate on. Output the subjects based on the preference list ordering.

Sample Input and Output
SNo.
Input
Output
1

5
Maths 5 80
Physics 6 75
Chemistry 10 85
Drawing 1 70
English 4 80
11
Maths Drawing Physics English Chemistry

Maths Physics




Problem : Count The Factor
The factorial of a non-negative integer N, denoted by N!, is the product of all positive integers less than and equal toN.
Factorial of any number can be represented in simplest form of its prime factors.
 
e.g. 4!=4*3*2*1= 2
3*31
Factorials can also be specified by the number of times each prime factors occurs in it, thus 24 could be specified as (3 1) meaning 3 twos, 1 three.
Write a program that will take an integer as input and give output as the following.
Input:
Input will be a positive Integer N where N>1.
Line 1
N,where N is any integer.

Output:
Output will show a series consists of the number of times each prime factor appears after the factorization of N! separated by spaces.
Line 1

For Valid Input,print

L,where L is the series consists of the number of times each prime factor appears after the factorization of N! separated by spaces.
For Invalid Input,print

Invalid Input

Sample Test Cases:
SNo.
Input
Output
1

6
4 2 1
2

a
Invalid Input
2

-5
Invalid Input