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

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

89 active golfers, 286 entries

Solutions by @turtlefetus:
22
#34 - turtlefetus / @turtlefetus

05/24/2025 at 05:14AM

25
#>56 - turtlefetus / @turtlefetus

05/24/2025 at 05:12AM

26
#>62 - turtlefetus / @turtlefetus

05/24/2025 at 05:11AM

27
#>65 - turtlefetus / @turtlefetus

05/24/2025 at 05:09AM

28
#>69 - turtlefetus / @turtlefetus

05/24/2025 at 05:05AM

29
#>72 - turtlefetus / @turtlefetus

05/24/2025 at 04:34AM

31
#>75 - turtlefetus / @turtlefetus

05/24/2025 at 04:33AM

35
#>86 - turtlefetus / @turtlefetus

05/24/2025 at 04:32AM

41
#>87 - turtlefetus / @turtlefetus

05/24/2025 at 04:31AM