Sei sulla pagina 1di 5

Round 2: Q1 COLOUR BOMBARD!

The RGB colour is a colour code where each colour (Red Green Blue) has a value from 0 to 255 , Given a question where we can target a given canvas and allow an area of effect to formed . Say the canvas is your Array and we will give the coordinates of bombarding ! Say your canvas is w w w w w w w w w w wwwwwwwwww wwwwwwwwww wwwwwwwwww wwwwwwwwww wwwwwwwwww wwwwwwwwww wwwwwwwwww wwwwwwwwww w w w w w w w w w w a 10x10 Canvas. WORKING RULE At the Given Coordinates mention the Dominant colours Value , and as we move away the colour should decrease by 50% , say the code was 254 for Red , the adjacent squares will have 254/2= 127(decimal part to be ignored) as the colour code, and so on till the value is below 10 then the colour is set to 0. Note Boundary Conditions Apply, The canvas is considered to be round and if the coordinates are on the edge then make sure the effect applies on the opposite part also ! INPUT The Input will be the X-Y Coordinates of the colour attack and the Colour code(in decimal) Output Output will be a canvas indicating the area of effect Sample Input 55 254 127 10

Expected output 15 15 15 15 15 15 15 15 15 0 15 31 31 31 31 31 31 31 15 0 15 31 63 63 63 63 63 31 15 0 15 15 15 31 31 31 63 63 63 127 127 127 127 254 127 127 127 127 63 63 63 31 31 31 15 15 15 0 0 0 15 31 63 63 63 63 63 31 15 0 15 31 31 31 31 31 31 31 15 0 15 15 15 15 15 15 15 15 15 0 0 0 0 0 0 0 0 0 0 0

Sample Input 11 60 10 10 Expected output 60 30 15 0 0 0 0 0 15 30 30 30 15 0 0 0 0 0 15 30 15 15 15 0 0 0 0 0 15 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 15 15 15 0 0 0 0 0 0 0 30 30 15 0 0 0 0 0 0 0

ROUND 2: Q2:
Your task is to create a building elevator controller with maximum efficiency. There are two elevators in the building, and 10 floors (0,1,2 9). You are given a list of inputs, where each line represents one button being pressed. The last set of numbers will always be 0,0 indicating the end of the list. The input will look something like this: 4,6 5,9 3,0 0,0 Write code that will take this input and return a list of floors which the elevator will visit in order to take everyone to their right destinations. The list must have all floors that the elevators will stop at. Your goal is to minimize the total time

taken for both elevators to transport everyone. Thus, if one elevator goes from 0 to 5 and then to 3, the output would be: 0,5,3 Note: this example is for a single lift. Your code must assume TWO lifts! Also, Assume that the elevator ALWAYS STARTS FROM FLOOR 0. Example: Input: 4,6 5,9 3,0 0,0 Output: Elevator 1: 0,6,3,0 Elevator 2: 0,5,9

ROUND 2: Q3
A sliding puzzle is basically a 4x4 grid containing 15 tiles numbered from 1 to 15. Thus, one cell in the grid is empty. It is labeled as 0. Each tile can be slid in all four directions, provided theres an empty cell. You will be given a grid in which the tiles are all mixed up. Your code must sort the grid into the right order:
1 5 9 13 2 6 10 14 3 7 11 15 4 8 12 0

INPUT : 2468 1305 9 11 13 15 10 12 14 7 OUTPUT: 1234 5678 9 10 11 12 13 14 15 0 NOTE: in case of ties, the algorithm that solves it in lesser number of steps will be awarded more marks.

ROUND 3: Q1
COIN GAME Alice and Bob are playing a game using a bunch of coins. The players pick several coins out of the bunch in turn. Each time a player is allowed to pick 1, 2 or 4 coins, and the player that gets the last coin is the winner. Assume that both players are very smart and they will try their best to work out a strategy to win the game. For example, if there are 2 coins and Alice is the first player to pick, she will definitely pick 2 coins and win. If there are 3 coins and Alice is still the first player to pick, no matter she picks 1 or 2 coins, Bob will get the last coin and win the game. Given the number of coins and the order of players (which means the first and the second players to pick the coins), and calculate how many different strategies there are for him/her to win the game. Input: <No of Coins><space><Player 1><space><Player 2> Output: <Winner><space><No of turns Required to Win> Here are some sample runs of the program: 1 alice bob alice 1 2 bob alice bob 1 3 alice bob bob 2 10 alice bob alice 22 25 alice bob alice 3344 30 alice bob bob 18272

ROUND 3: Q2
Question 1 Your task is to create a compiler for a new language! Don't worry, the language is quite simple. Here are the specifications of the language: There are 4 keywords is Assignment display Outputs code to console check Conditional Statement otherwise similar to else statement loop x times iterative statement add x to y does exactly what you think it does Here's an example code :

a is 5 loop 3 times add 1 to a check a>7 display it worked! otherwise display it didnt work. OUTPUT: it worked! An important point to note here is that the statements loop, check, and otherwise are valid only for the immediately next statement. That is, there is no concept of statement blocks. Thus, the loop in line 2 holds only for line 3. Similarly, line 5 holds only for line 4 and line 7 only for line 6. Also, this language is insensitive to whitespaces, just like C or Java. The indentation is only to make it clearer to the programmer. Your code should be able to take such an input and generate code in any known language which can be compiled using a standard compiler/interpreter. THE OUTPUT OF YOUR CODE MUST BE ANOTHER CODE IN ANY KNOWN LANGUAGE THAT DOES THE EXACT SAME THING THAT THE INPUT CODE DOES!

Potrebbero piacerti anche