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 @ymte:

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

54 active golfers, 162 entries

Solutions by @ymte:
22
#23 - ymte / @ymte

03/28/2025 at 08:59AM

22
#>23 - ymte / @ymte

03/28/2025 at 09:01AM

23
#>30 - ymte / @ymte

03/28/2025 at 08:58AM

25
#>35 - ymte / @ymte

03/28/2025 at 08:57AM

27
#>40 - ymte / @ymte

03/28/2025 at 08:56AM

29
#>45 - ymte / @ymte

03/28/2025 at 08:53AM

31
#>46 - ymte / @ymte

03/28/2025 at 08:45AM

32
#>50 - ymte / @ymte

03/28/2025 at 08:44AM

33
#>50 - ymte / @ymte

03/28/2025 at 08:48AM

34
#>51 - ymte / @ymte

03/28/2025 at 08:46AM

34
#>51 - ymte / @ymte

03/28/2025 at 08:47AM

38
#>53 - ymte / @ymte

03/28/2025 at 08:45AM

41
#>53 - ymte / @ymte

03/28/2025 at 08:44AM