Created
April 23, 2015 00:47
-
-
Save ninjapanzer/0d1711a686c5c371d0c4 to your computer and use it in GitHub Desktop.
Hacker Rank Halloween Party
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Enter your code here. Read input from STDIN. Print output to STDOUT\ | |
from sys import stdin | |
# get the first line of the input and figure out how many cases there are to run | |
userinput = stdin.readline() | |
count = int(userinput) | |
# do the counting work | |
def count_pieces(cuts): | |
# divide the number of cuts in half and truncate to the nearest integer | |
half_cuts = int(cuts/2) | |
# find out how much is left | |
other_half_cuts = cuts - half_cuts | |
# get the product | |
return half_cuts * other_half_cuts | |
# loop over the test cases and print the pieces | |
for _ in range(0,count): | |
cuts = int(stdin.readline()) | |
print count_pieces(cuts) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment