Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ce21cd4

Browse files
authored
Solution
1 parent c6c3fce commit ce21cd4

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

‎HackerRank-Bon App-tit/Bon Appétit.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/python3
2+
3+
import math
4+
import os
5+
import random
6+
import re
7+
import sys
8+
9+
# Complete the bonAppetit function below.
10+
def bonAppetit(bill, k, b):
11+
count=0
12+
for i in range(len(bill)):
13+
if(i!=k):
14+
count+=bill[i]
15+
pay = count//2
16+
if(pay != b):
17+
print(b-pay)
18+
else:
19+
print("Bon Appetit")
20+
21+
if __name__ == '__main__':
22+
nk = input().rstrip().split()
23+
24+
n = int(nk[0])
25+
26+
k = int(nk[1])
27+
28+
bill = list(map(int, input().rstrip().split()))
29+
30+
b = int(input().strip())
31+
32+
bonAppetit(bill, k, b)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /