You are on page 1of 13

Delhi Public School

Dwarka
Presents

‘CORE KERNEL’

CORE O8’
Rules and Regulations

1. There are 7 questions; the weightage of each question is given along


with the question.

2. In case you can’t solve a question you really want to, don’t worry,
we are there for the rescue. We Dipsites believe in ‘Service Before
Self’. We can always give you a hint for the question. But in return you
will have to give up half the points of the question, irrespective of
whether you are able to complete it later or not. Just shout out “24”
for a hint.
Hints are not available for question II, question IV and question VI.

3. When you complete a question, you will be given time bonus on the
basis of following rules:
a) If you are the first to solve the particular question, the time left
will be added to your score as time bonus.
b) If the question you complete has been solved earlier, half the
time left will be added to your score as time bonus.

4. As soon as you complete a question, shout out “Bugs Bunny loves


carrots”.

5. No question should take more than 10 seconds for execution.

6. 50 points are deducted for each mis-attempt.

Best of luck!!!
I
1234…what??

The digits 1, 2, 3, 4, 5, 6, 7, 8, 9 on being used once and just once can form 9!
different numbers.
Your job is to tell us the nth number, when these numbers are arranged in
ascending order.
Here obviously n will be given by us.

Sample input:

1) 1
2) 10

Sample Output:

1) 123456789
2) 123457896

Scoring and constraints:

150 points

1 < n < 9!
II
Check the Check

Your have to write a program that reads a chessboard configuration and


identifies whether a king is under attack (in check). A king is in check if it is
on square which can be taken by the opponent on his next move.
White pieces will be represented by uppercase letters and black pieces by
lowercase letters. The white side will always be on the bottom of the
board, with the black side always on the top.

For those unfamiliar with chess, here are the movements of each piece:
Pawn (p or P): can only move straight ahead, one square at a time.
However, it takes pieces diagonally, and that is what concerns you in this
problem.
Knight (n or N): has an L-shaped movement shown below. It is the only
piece that can jump over other pieces.
Bishop (b or B): can move any number of squares diagonally, either
forward or backward.
Rook (r or R): can move any number of squares vertically or horizontally,
either forward or backward.
Queen (q or Q): can move any number of squares in any direction
(diagonally, horizontally, or vertically) either forward or backward.
King (k or K): can move one square at a time in any direction (diagonally,
horizontally, or vertically) either forward or backward.

The pawn movement will depend on its side. If it is a black pawn, it can
only move one square diagonally down the board. If it is a white pawn, it
can only move one square diagonally up the board.

There will be an arbitrary board configuration in the input, each consisting


of eight lines of eight characters each. A “.” denotes an empty square,
while upper and lowercase letters represent the pieces as defined above.
There will be no invalid characters and no configurations where both kings
are in check.
For each board configuration read you must output one of the following
answers:
1) White king is in check.
2) Black king is in check.
3) No king is in check.

Sample Input
1)
..k.....
ppp.pppp
........
.R...B..
........
........
PPPPPPPP
K.......
2)
rnbqk.nr
ppp..ppp
....p...
...p....
.bPP....
.....N..
PP..PPPP
RNBQKB.R

Sample Output
1) Black king is in check.
2) White king is in check.

Scoring and constraints:

150 points
No constraints
III
Divison of Malland

Vijay Mallya recently bought a big plot of land, worth Rs. 1100 Crore in
Scotland.
Now he wants to build a palace on this land, and wants to start the work
right away.
But he was so happy about buying the land that he got drunk (and
because of the heavy drinking named the land....well.…Malland (Mallya-
land)) and now can’t understand even a single thing about the land.

So now he turns to you, the star programmer, and asks you to find out
how many different rectangular palaces can be built on the land.
2 palaces are said to be different, if they have different size and different
position, or same size but different position, or simply different size.

So you have to derive a program, in which you’ll be given the size of the
land (m X n) and you’ll have to find out how many different rectangular
palaces of integral sides can be formed on this land.

The palaces of same dimensions but different position will be counted as


different.

Sample Input:
1) m=8
n=8
2) m=6
n=4

Sample Output:
1) 1296
2) 210

Scoring and constraints:

100 points
1 < m, n < 360
IV
Score It!!!

Recession has had its effect everywhere around the world. Even Derek ‘O’
Brien hasn’t been spared.
He has no option but to cut down on his support staff. So, thinking that
they have the least importance, he fires all the scorers.
But alas! He was so wrong. Without the scorers all his quiz shows failed and
his reputation was falling day-by-day. With falling profits on one side and
falling reputations on the other side, and an all-India quiz coming up, he
has no other option but to turn to you to build him a scoring system for a
quiz of 4 teams.
He wants you to build him a system in which he will give you the number
of questions asked, and the question answered by each team.
He will represent the right answer as “D” and the wrong or non-attempted
ones as “.”
For example – .D.. means the question was answered by the second team;
and …D means the question was answered by the 4th team.
But it isn’t that easy. There are 3 rules:
1) The quiz is an infinite bounce; that means, irrespective of the
question number, whichever team answers a passed or a direct
question, the next question goes to the next team, For eg. - If the 1st
question is answer by the 3rd team, the 2nd question goes to the 4th
team.
2) A team gets 20 points for a direct question and 10 for a passed one.
3) Don’t worry. Derek isn’t so cruel. There are no negative marks for
the wrong answers.

SAMPLE INPUT:
1) 2
..D.
D…
2) 5
.D..
D…
..D.
…D
…D
SAMPLE OUTPUT:
1) Team 1 – 10
Team 2 – 0
Team 3 – 10
Team 4 – 0
1) Team 1 – 10
Team 2 – 10
Team 3 – 10
Team 4 – 30
Scoring and constraints:
100 points
1 < n < 10
V
Star Counting

A board contains 48 triangular cells. In each cell is written a digit in a


range from 0 through 9. Every cell is a part of two or three lines. These
lines are marked by letters from A through L. See the figure below, where
the cell containing digit 9 belongs to lines D, G, and I and the cell
containing digit 7 belongs to lines B and I.

For each line, we can measure the largest digit on the line. Here the largest
digit for line A is 5, B is 7, E is 6, H is 0, and J is 8.

You have to write a program that reads the largest digit for all 12 of the
depicted lines.
The first of these digits describes the largest digit in line A, the second in line
B, and so on, until the last digit denotes the largest one in line L.

The program should then compute and print the smallest and the largest
possible sums of all digits on the board.
Sample Input:

1) 5
7
8
9
6
1
9
0
9
8
4
6

2) 6
9
8
2
0
9
9
4
8
7
6
9

Sample Output:
1) Smallest = 40
Largest = 172

2) Smallest = 45
Largest = 185
Scoring and Constrains:

75 points (for finding the smallest sum)


+
175 points (for finding the largest sum)

No constraints
VI
The NeoCorp Dilemma

In order to increase security, the network manager of NeoCorp has


introduced some new rules concerning passwords:

1. Passwords must consist of a mixture of lowercase letters and numerical


digits only, with at least one of each.
2. Passwords must be at least 5 characters long.
3. Passwords must not contain any sequence of characters immediately
followed by the same sequence.

Write a program that inputs a password and then prints REJECTED if the
password is rejected, or ACCEPTED otherwise.

Sample input
1. cakeshop
2. ab34
3. A567xcz
4. 9apple8
5. 03bananas
6. 123xy123

Sample output:
1. REJECTED
2. REJECTED
3. REJECTED
4. REJECTED
5. REJECTED
6. ACCEPTED

Scoring and constraints:

200 points
No constraints
VII
The Programming Knight

Most of you might have seen The Dark Knight. In case you haven’t, you
should, it’s pretty good.

Anyway, coming back to the question, the movie was supposed to have a
different climax, but it was changed to what it is now because many
people couldn’t understand it. But well, we are supposing that you are
smart enough to get the complicated scene.
So, instead of the scene where Batman hands over Joker to the police,
what was supposed to happen was that Joker traps Batman in his den.
After a long altercation, Joker decides to play a game with Batman. He
tells him, “If you win, I hand myself over to the police; but if you don’t win,
Gotham burns. MUAHAHAHAHA!!!”

Joker tells Batman that he will hand over the 13 playing cards of hearts to
him.
Now what Batman is supposed to arrange the playing cards upside down
in a particular way and then the following algorithm will be followed:
All the playing cards in the stack are inverted. The 1st one is flipped and
kept on the table (so that it reveals the number). The next n playing cards
are then kept at the bottom of the stack. The next one on the top of the
stack is flipped and kept on the table after the 1st one; and the next n ones
are kept at the bottom of the stack….and so on……
Now the challenge is that the playing cards in the stack should be
arranged in such a way, so that the playing cards being kept on the table
should be in ascending order (A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K).

But Batman isn’t smart enough to solve this problem so he turns to you
and asks you to make a program for it, such that you will be given the
number ‘n’ and you will have to print out the series of upside down cards
in the stack.

Can you save Gotham?


Sample input:

1) 1
2) 2

Sample Output

1) A, Q, 2, 8, 3, J, 4, 9, 5, K, 6, 10, 7
2) A, 8, 10, 2, 6, Q, 3, 9, 7, 4, K, J, 5

Scoring and constraints:

150 points
No Constraints

You might also like