Problem Description
Write a program to find sum of series
Hint:1+2+3+4+nCODING ARENA::
a=int(input())
sum=0
for i in range(1,a+1):
sum=sum+i
print(sum)
Test Case 1
Input (stdin)18
Expected Output171
Test Case 2
Input (stdin)100
Expected Output5050
UNI-THON
This blog is to help for the programmers to learn the programs and not to demotivate any people .Our intention is to make the learners to learn the code easily.
Friday, February 1, 2019
The Castle Gate
Problem Description
Gudi, a fun loving girl from the city of Dun, travels to Azkahar - a strange land beyond the mountains. She arrives at the gates of Castle Grey, owned by Puchi,the lord of Azkahar to claim the treasure that it guards. However, destiny has other plans for her as she has to move through floors, crossing obstacles on her way to reach the treasure.
The gates of the castle are closed. An integer N is engraved on the gates. A writing on the wall says
Tap the gates as many times as there are unordered pairs of distinct integers from 1 to N whose bit-wise XOR does not exceed N
Help her find the number of the times she has to tap.
Input:
First line contains an integer T
T testcases follow.
Each testcase consists of an integer N
Output:
Print the answer to each testcase in a newline.
Explanation
For N=4, pairs are (1,2) , (1,3) and (2,3)CODING ARENA
def ans():
for _ in range(int(input())):
n=int(input())
if(n<3):
yield 0
else:
m=1<<(n.bit_length()-1)
yield ((m-1)*(m-2)+3*(n-m+1)*(n-m))//2
print(*ans(),sep="\n")
Test Case 1
Input (stdin)3 4 6 8
Expected Output3 12 21
Test Case 2
Input (stdin)5 6 10 20 26 12
Expected Output12 30 135 270 51
Day Old Bread
Problem Description
A bakery sells loaves of bread for 185 rupees each. Day old bread is discounted by 60 percent. Write a program that begins by reading the number of loaves of day old bread being purchased from the user.
Then your program should display the regular price for the bread, the discount because it is a day old, and the total price.
All of the values should be displayed using two decimal places, and the decimal points in all of the numbers should be aligned when reasonable values are entered by the user.CODING ARENA
a=int(input())
b=a*185
print("Loaves Discount")
print("Regular Price",b)
print("Total Discount",b*.6)
print("Total Amount to be paid",b-(b*.6))
Test Case 1
Input (stdin)15
Expected OutputLoaves Discount Regular Price 2775 Total Discount 1665.0 Total Amount to be paid 1110.0
Test Case 2
Input (stdin)25
Expected OutputLoaves Discount Regular Price 4625 Total Discount 2775.0 Total Amount to be paid 1850.0
Body Mass Index
Problem Description
Write a program that computes the body mass index (BMI) of an individual.
Your program should begin by reading a height and weight from the user. If you read the height in meters and the weight in kilograms then body mass index is computed using this slightly simpler formula:
BMI = weight / height *height
Use round function in the final output valueCODING ARENA
a=float(input())
b=int(input())
c=b/(a*a)
print("The BMI IS",round(c,2))
Test Case 1
Input (stdin)1.69 64
Expected OutputThe BMI IS 22.41
Test Case 2
Input (stdin)1.72 71
Expected OutputThe BMI IS 24.0
Area of a Room
Problem Description
Write a program that asks the user to enter the width and length of a room.
Once the values have been read, your program should compute and display the area of the room.
The length and the width will be entered as floating point numbers. Include units in your prompt and output message; either feet or meters, depending on which unit you are more comfortable working with.
Formula = length*widthCODING ARENA
a=float(input())
b=float(input())
c=a*b
print("The area of the room is",round(c,2),"square feet")
Test Case 1
Input (stdin)23.44 22.33
Expected OutputThe area of the room is 523.42 square feet
Test Case 2
Input (stdin)18.66 22.45
Expected OutputThe area of the room is 418.92 square feet
Three Idiots
Problem Description
Create a program that reads three integers from the user and displays them in sorted order (from smallest to largest).
Use the min and max functions to find the smallest and largest values.
The middle value can be found by computing the sum of all three values, and then subtracting the minimum value and the maximum value.CODING ARENA
a=[]
for i in range(3):
b=int(input())
a.append(b)
a.sort()
print("The minimum value is",a[0])
print("The maximum value is",a[2])
print("The middle value is",a[1])
Test Case 1
Input (stdin)25 12 1988
Expected OutputThe minimum value is 12 The maximum value is 1988 The middle value is 25
Test Case 2
Input (stdin)9 19 1972
Expected OutputThe minimum value is 9 The maximum value is 1972 The middle value is 19
Convert integer to float
Problem Description
Given an input as integer to the machine , he need to get the output of corresponding floating point number
Hint: Divide the number by 100 and display the output
Please help him to write the program that satisfy the output.CODING ARENA
a=int(input())
b=a/100
print(b)
Test Case 1
Input (stdin)12
Expected Output0.12
Test Case 2
Input (stdin)15
Expected Output0.15
Subscribe to:
Posts (Atom)