COLONY - Linearian Colony

no tags 

Description

Linearians are peculiar creatures. They are odd in several ways:
  1. Every Linearian is either red or blue.
  2. A Linearian colony is a straight line, aligned N-S with the magnetic field.
  3. A colony starts with single red Linearian.
  4. Every year, each Linearian produces an offspring of the opposite color. After birth, the parent moves just south of the offspring. (Since everyone is born at once, this does make for a lot of jostling, but everyone stays in order.)
So a colony grows as follows:
N ----------- S

Year 0: R
Year 1: BR
Year 2: RBBR
Year 3: BRRBRBBR
Year 4: RBBRBRRBBRRBRBBR
Given a year and a position along the N-S axis, determine what the color of the Linearian there will be.

Input

The first line is the year Y (0 <= Y <= 51). The second line is the position P from north to south, 0-indexed (0 <= P < 2^Y).

Output

The color of the Linearian, either red or blue.
Input Input
3
6
51
123456789012345
Output Output
blue
red

hide comments
ABHISHEK004: 2013-12-30 11:51:51

have fun while doing this prob... :)
easy one..

Mitch Schwartz: 2013-12-20 08:24:45

@thedarkone: Your original request is strange to me as (1) I don't consider this problem to have any corner cases, (2) knowing a specific input and its output is not likely to give any insight here, and (3) it would be a huge spoiler to be given ~1/8 of the actual test data that is being used for this problem. Also, "random small inputs" is not very convincing, since you can test a LOT of small inputs iteratively (in an exhaustive manner), you do not need to use randomness for those. Maybe you tested a lot of small cases, but you did not state that clearly. Asking for such debugging help seems to me more suited for the forum (link on the left side menu). Be sure to read the posts "Read this before posting!" by TripleM and "PLEASE USE CODE TAGS" by leppy.

Last edit: 2013-12-20 09:06:46
thedarkone: 2013-12-19 21:47:32

Ok thanks for the info
Though the problem is that, I am getting correct answer for the test cases and for random small inputs. However its not possible to check for large inputs. Therefore any help would be appreciated.
Submission ID: 10698421

Mitch Schwartz: 2013-12-19 20:53:43

"WA on the 7th file"

If you see "Running... (7)" that does NOT mean that you got the all the tests before that right. The judge doesn't halt on first failure. You can check this easily by submitting e.g. infinite loop code. I'm considering writing a FAQ for some things like this that come up over and over again in comments, wasting space that could be used for more constructive comments.

thedarkone: 2013-12-19 20:11:52

WA on the 7th file
could you please kindly provide the input and output required there
ID:10698421

Last edit: 2013-12-19 20:21:04
Bhavik: 2013-12-10 16:16:51

easy one:))there is similar problem like this...

Jignesh: 2013-12-05 20:04:46

nice problem :)

Laxus!!: 2013-12-05 11:13:27

SWEET!!

harsh: 2013-11-25 18:58:52

learnt something new..:)

nitish rao: 2013-11-13 12:28:20

Just a matter of 3 lines in C!! :D


Added by:BYU Admin
Date:2013-10-18
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM32-GCC ASM64 MAWK BC C-CLANG NCSHARP CPP14 CPP14-CLANG COBOL COFFEE D-CLANG D-DMD DART ELIXIR FANTOM FORTH GOSU GRV JS-MONKEY JULIA KTLN NIM OBJC OBJC-CLANG OCT PICO PROLOG PYPY PYPY3 R RACKET RUST CHICKEN SQLITE SWIFT UNLAMBDA VB.NET