Real Vim ninjas count every keystroke - do you?

Pick a challenge, fire up Vim, and show us what you got.

Changelog, Rules & FAQ, updates: @vimgolf, RSS.

Your VimGolf key: please sign in

$ gem install vimgolf
$ vimgolf setup
$ vimgolf put 9v006715b7d2000000000535

Fix the Scala Method

Fix the missing semicolons and the Int type, ensure the floating point division, and remove the unnecessary return.

Start file
def calculateTotalPrice(items List[Double], discountPercentage int): Double = {
  val subtotal = items.sum
  val discountAmount = subtotal * (discountPercentage / 100)
  val total = subtotal - discountAmount
  return total
}
End file
def calculateTotalPrice(items: List[Double], discountPercentage: Int): Double = {
  val subtotal = items.sum
  val discountAmount = subtotal * (discountPercentage / 100.0)
  val total = subtotal - discountAmount
  total
}

View Diff

1c1
< def calculateTotalPrice(items List[Double], discountPercentage int): Double = {
---
> def calculateTotalPrice(items: List[Double], discountPercentage: Int): Double = {
3c3
<   val discountAmount = subtotal * (discountPercentage / 100)
---
>   val discountAmount = subtotal * (discountPercentage / 100.0)
5c5
<   return total
---
>   total

Solutions by @brieuc-praud:

Unlock 5 remaining solutions by signing in and submitting your own entry
Created by: @pacuna

39 active golfers, 106 entries

Solutions by @brieuc-praud:
22
#12 - Brieuc Praud / @brieuc-praud

10/31/2024 at 08:17PM

24
#>22 - Brieuc Praud / @brieuc-praud

10/31/2024 at 08:13PM

26
#>27 - Brieuc Praud / @brieuc-praud

10/31/2024 at 08:10PM

29
#>32 - Brieuc Praud / @brieuc-praud

10/31/2024 at 08:06PM

31
#>33 - Brieuc Praud / @brieuc-praud

10/31/2024 at 08:01PM