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

The best way to learn is to practice. Below, you will find some of the solutions other golfers have entered. To unlock higher ranked solutions, submit your own entry which does as well or better than the solutions you can currently see - climb the ladder!

Check out these helpful resources to improve your Vim skills... Game on.

Unlock 76 remaining solutions by signing in and submitting your own entry
#77 Chris Davis / @nthState-Chris - Score: 52 - 05/08/25 @ 09:49
tLi:<Esc>/in<CR>i<BS>: <Esc><Right>xiI<Esc>:%s/00/00.0/g<CR>:%s/return //g<CR>:wq<CR>

0 comments


Created by: @pacuna

77 active golfers, 243 entries

Leaderboard (lowest score wins):
22
#31 - Damien Baldy / @dbaldy

05/19/2025 at 12:43PM

22
#32 - Sjur B. / @Apostrophel

05/21/2025 at 10:00PM

22
#33 - turtlefetus / @turtlefetus

05/24/2025 at 05:14AM

22
#34 - winter-loo / @winter-loo

05/28/2025 at 03:09PM

22
#35 - Hessesian / @Hessesian

06/15/2025 at 06:45PM

22
#36 - 0xf00ff00f / @0xf00ff00f

06/21/2025 at 03:50PM

22
#37 - Ozan / @OzanY4

07/22/2025 at 01:25AM

23
#38 - Keane / @keanesc

10/23/2024 at 04:25AM

23
#39 - DayuanX / @DayuanX

11/02/2024 at 10:35AM

23
#40 - Chloe Brett / @chloebrett

11/09/2024 at 08:50AM

23
#41 - MC / @MC88686523

01/18/2025 at 06:22PM

23
#42 - Berkay Berabi / @BBerabi

02/01/2025 at 04:02PM

23
#43 - Martin Knoller Stocker / @linuxswords

05/25/2025 at 09:31AM

24
#44 - Gibson Starkweather / @boaf

05/29/2025 at 11:48PM

25
#45 - daniilsvirin / @daniilsvirin

10/21/2024 at 08:34AM

25
#46 - JMTed / @JMTed

10/21/2024 at 10:51AM

25
#47 - ProGamerYeet / @ProGamerYeet

10/21/2024 at 01:32PM

25
#48 - _3tHeR_ / @3ther-joyboy

11/11/2024 at 10:37AM

25
#49 - enaygit / @enaygit

02/15/2025 at 05:10AM

25
#50 - ohwell / @KiranClose

05/10/2025 at 07:57PM

26
#51 - Ban / @Rheriel

10/21/2024 at 06:12AM

26
#52 - thedvd98 / @thedvd98

11/03/2024 at 11:31AM

26
#53 - Tzadiko / @Tzadiko

12/17/2024 at 01:57AM

26
#54 - Biswajit / @biswajitpatra

01/26/2025 at 03:12PM

26
#55 - SD / @SD24757629

04/06/2025 at 07:45AM

26
#56 - estoneman / @estoneman

04/23/2025 at 03:23AM

26
#57 - Katie Gardner / @KatieLG

06/01/2025 at 12:01AM

26
#58 - Tom Dailey / @tomdailey

07/25/2025 at 10:14AM

27
#59 - Matthew Cooper / @mkcmkc

07/07/2025 at 12:56AM

28
#60 - romache8 / @romache8

12/11/2024 at 12:23PM