At the opening scene of the Dark Knight rises, there is a rather awkward dialogue between a CIA agent and the villain Bane.
CIA agent: “If I pull that [mask] off, will you die?”
Bane: “It would be extremely painful…”
CIA agent: “You’re a big guy.”
Bane: “…for you.”
It’s unsure if Bane intends to say “painful for you” or “big guy for you”. Let’s settle this problem once for all through code golfing!
Challenge
Your task is write a program that reorders the above dialogue depending on an integer given as input.
CIA agent dialogue words are:
If I pull that off will you die? You're a big guy.
Bane’s dialogue words are:
It would be extremely painful... for you!
Please note that die?, You’re, painful... and you! are considered as single words.
- Given an integer n as input, convert it to binary
- Reading the binary digits from left to right, output the next word from CIA agent dialogue if the digit is
1, and the next word from Bane dialogue if the digit is0. The words should be separated by a space. When the speaker changes, add a line feed. Also, prefix each dialogue line with the speaker name (BANE:orCIA:).
You can assume that the input always starts with a 1 in binary form, and has 12 ones and 7 zeroes.
Example
522300
Converted to binary:
1111111100000111100The number starts with 8 ones, so we output the 8 first words from CIA’s agent dialogue, and prefix them with CIA:
CIA: If I pull that off will you die?Then we got 5 zeroes, so we get the 5 first words from Bane’s dialogue:
BANE: It would be extremely painful...Then there are 4 ones, so we output the 4 next CIA words:
CIA: You’re a big guy.Then 2 zeroes:
BANE: for you!
Final result:
CIA: If I pull that off will you die?
BANE: It would be extremely painful...
CIA: You’re a big guy.
BANE: for you!
More test cases:
494542
CIA: If I pull that
BANE: It would be
CIA: off
BANE: extremely
CIA: will you die? You're
BANE: painful... for
CIA: a big guy.
BANE: you!
326711
CIA: If
BANE: It would
CIA: I pull that off will you
BANE: be extremely painful... for
CIA: die? You're
BANE: you!
CIA: a big guy.