Bill Division Solution in Kotlin -HackerRank

  • bill: an array of integers representing the cost of each item ordered
  • k: an integer representing the zero-based index of the item Anna doesn’t eat
  • b: the amount of money that Anna contributed to the bill
4 1 
3 10 2 9

fun bonAppetit(bill: Array<Int>, k: Int, b: Int): Unit {
var annaBill = 0for(x in 0 until bill.size) {
val it = bill[x]
if (x != k) {
annaBill += it

if (annaBill / 2 == b) "Bon Appetit"
else b - annaBill / 2
4 1 
3 10 2 9
Bon Appetit




Hey curious person, I am Software Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

What I learned today — Episode 2

Make the Leap from JavaScript to PureScript

Getting started with AngularJS

List comprehensions with Applicative Functors

Vue.js Components Communication Patterns (without Vuex) — Part 4

Final project of Boot camp

Writing unit tests for a working full stack application using Mocha and Chai — Part I — Back end…

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Umar Syaid Himawan

Umar Syaid Himawan

Hey curious person, I am Software Developer

More from Medium

How to get started with Kotlin Language(Part1).

Recursive Permutations calculation Algorithm (in Kotlin)

Kotlin Flows: The Graduated Coroutine — I

Tried making bubbles