Codewars 2021openbeta Na Problems 2021 02 26 UTC b28
Codewars 2021openbeta Na Problems 2021 02 26 UTC b28
Please read the following instructions carefully. They contain important information on
how to run your programs and how to prepare them for submission. If you have any
questions regarding these instructions, please ask it in our Discord server (your
teacher has the link).
• C/C++ source code submission instead of executables.: Any solutions in C or C++ must be submitted as source files and not as a
binary executable. Your solutions can rely on glibc/libm and the standard headers. More information about our C/C++ environment and
how you can create it locally are provided in the "C/C++ Development Environment Guide" available on the contest site.
Program Input
Most programs will require input. You have two options:
Note: An easy way to enter keyboard data is by redirecting the contents of a file to your program. For example, if you are
executing prob01, the input file input.txt can be redirected to the standard in of your program using syntax like this (examples
are shown for each of the allowed languages):
Your program will behave exactly as if you were typing the input at the keyboard.
Program output
All programs must send their output to the screen (standard out, the default for any print statement). Please remember to
carefully review your file names.
• For Python you should use the extension that matches the Python version that you are using.
• For Java, the main class must be named probXX. Note there is no capitalization. All main and supporting classes should
be in the default (or anonymous) package.
You are strongly encouraged to submit solutions for Problem #0 and #1 (see next pages) prior to the start of the competition to
ensure that your environment is compatible with the judges' and that you understand the input and output methods required.
problem
Welcome, to the 24th Triwizard Tournament! 1
00 points
Input
You will not receive any input for this (and only this) problem
Output
Print a welcome message to the screen as follows:
We bid welcome to the ladies of Beauxbaton and our friends from the north, the sons of Durmstrang.
Discussion
Simply print to the screen the sentence given above as output. There are no datasets for this problem (as it is
meant to ensure that your coding environment and setup works when submitting code for judging).
Help Spock welcome you, the new captain of the Enterprise, to the
bridge with a reminder of your duty -- by telling him your name.
Input
You will receive exactly one word on a single line.
Jim
Output
Print the following sentence to the screen, substituting the word read in from your dataset in place of the
placeholder NAME: NAME, the needs of the many outweigh the needs of the few, or the one; live long and
prosper.
Jim, the needs of the many outweigh the needs of the few, or the one; live long and prosper.
Discussion
You do not have to worry about spaces, hyphenated names, or words that are too long. You are guaranteed that
the words supplied in the datasets will fit in the output, and conform to the guidelines given.
Reminder: have you run your solution against all of the student data sets?
Additional Examples
Input 1 Output 1
Jamie Jamie, the needs of the many outweigh the needs of the few, or the one; live long and prosper.
Input 2 Output 2
Sisko Sisko, the needs of the many outweigh the needs of the few, or the one; live long and prosper.
However, this model did not work too well because many
parasites are unable to distinguish between parasitized and
unparasitized hosts. Thus Thompson's model predicted a
higher rate of parasitism than would actually occur. In reality, a
host can end up with more than one parasitoid egg and is then
"superparasitized".
Thompson's model may not have been very accurate, but it
makes a great CodeWars program. Write a program that uses
Thompson's model to predict the rate of parasitism for a pair
of input values.
Input
The first line of input is the value of C, the Mean Female Egg Compliment, an integer between 1 and 10,000. The
second line is the value of P, the Number of Females Searching, an integer between 1 and 100,000.
1300
97450
Output
The program must print the value of Pe, the Number of Eggs Laid. The answer must match the judge's expected
value precisely.
126685000
Discussion
The output should literally just be the product of the multiplication of the integer values from the two lines. You are
guaranteed that you will not receive any values for input (or have to calculate for output) which will overflow an
int-32.
Reminder: have you run your solution against all of the student data sets?
Additional Examples
Input 1 Output 1 Input 2 Output 2
Input
The input is a single integer between one and ten, inclusive.
Output
The program must print a sentence in the format shown below, using the input number written as a word.
Discussion
Simply spell out the integer as a word and plug it into the output sentence.
Reminder: have you run your solution against all of the student data sets?
Additional Examples
Input 1 Output 1 Input 2 Output 2
Input
Each line of the input is two floating point decimal values. The last line of input is two zeros.
15.10 9.0
11.19 8.0
0 0
Output
Multiply the stock's cost (left most number) against how many units you want to buy (right most number). Output
the total cost for each stock, one per line (matching the same order as the input). Round your answer to 1
decimal place.
135.9
89.5
Discussion
You are guaranteed not to have to deal with numbers greater than the value of an int-32, negative numbers, or
numbers multiplied by zero.
Reminder: have you run your solution against all of the student data sets?
Additional Examples
Input 1 Output 1 Input 2 Output 2
Input
You will get exactly 3 lines of input. Line 1 contains the value for A. Line 3 contains the value for C. (The rest of
the line definitions Tony leaves as an exercise for the reader ^_-)
11
5
4
Output
Your program must help Tony convince his obnoxious know-it-all AI (is there any other type?) that his math is
correct. So, your program must show its work. Print three lines of output. On the first line swap the numbers into
the equation given above. On the second line, first solve the parts in parenthesis (on the left side of the equation);
then do the multiplication (only on the right side). On the third line show the result of the final evaluations. AIs are
tricky little devils, and they are extremely suspicious of human errors so follow the output format given below
exactly.
11 * (5 + 4) = 11 * 5 + 11 * 4
11 * 9 = 55 + 44
99 = 99
Discussion
This is a substitution mathematics problem. Simply plug in the numbers into the formulas given for all of the
stages given, and then calculate the results. You are guaranteed not to have deal with negative numbers or
multiplication by zero.
Reminder: have you run your solution against all of the student data sets?
Additional Examples
Input 1 Output 1 Input 2 Output 2
𝑃2 = 𝑅 3
Where P is the period measured in Earth-years, and R is the semi-major axis (orbital radius) in Astronomical
Units (AU).
Help Shepard write a program to calculate the orbital radius of a planet given its orbital period so she can better
map the star system she is in. To solve this problem you may need to know that you can express square roots
and cube roots as fractional exponents. For example:
x1/2 =
x1/3 =
Input
Each line of input is the orbital period (P), in years, of a body orbiting the sun. The input ends with a value of
zero.
1.8808
4.60
0.615198
30.07
0
Output
For each period, the program must print the semi-major axis (R) in AU. Round your answers to 4 decimal places.
The answer must be accurate to within +/- 0.01 AU.
1.5237
2.7659
0.7233
9.6699
Discussion
Reminder: have you run your solution against all of the student data sets?
Additional Examples
Input 1 Output 1 Input 2 Output 2
Input
GladOS is calling up lists of test subjects from the archives. Each list will have, on line one, the total count of
people in the list. Every line after that will consist of the subject's first name followed by a space, and then the
companion cube ID assigned to that person.
11
Chell 42
ATLAS 0
P-body 0
Wheatley 99
Lonely 52
Cave 123
Caroline 123
Rattmann 1
SpaceCore 0
Lonely 12
Rick 9
Output
Print 3 total lines. On the first line print the count of Lonely cubes. On the second print the count of duplicate
companion cube ID assignments. On the third line print the count of test subjects without a companion cube.
Lonely Cubes: 2
Duplicate Cube Assignments: 1
Test Subjects without Cubes: 3
Discussion
No names will contain spaces. For the duplicate counts, you are counting the duplicate cube IDs assigned, not
the total number of times IDs were duplicated. For example, if cube ID 99 shows on every line of the file, that
counts as one cube ID that was duplicated.
Reminder: have you run your solution against all of the student data sets?
Additional Examples
Input 1 Output 1
12 Lonely Cubes: 5
Gordon 0 Duplicate Cube Assignments: 2
Lonely 971 Test Subjects without Cubes: 1
Ozioma 1
James 3
Lonely 125
Lonely 126
Shapiro 3
Tony 4
Ellen 5
Lonely 124
Rhys 1
Lonely 123