CarlosLabs
Hackerrank Challenges - Bill Division
Sometimes the filename and the URI differ in Hackerank. Annoying.
import math import os import random import re import sys ## Rank: 591489|Points: 196/200 # Complete the bonAppetit function below. def bonAppetit(bill, k, b): subTotal = 0 retVal = "" ix = 0 for z in bill: if (ix!=k): subTotal += bill[ix] ix+=1 subTotal = (subTotal //2) if (subTotal==b): retVal = "Bon Appetit" else: retVal = str(abs(b-subTotal)) return retVal if __name__ == '__main__': nk = input().rstrip().split() n = int(nk[0]) k = int(nk[1]) bill = list(map(int, input().rstrip().split())) b = int(input().strip()) result = bonAppetit(bill, k, b) print(str(result) + '\n')