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 56 remaining solutions by signing in and submitting your own entry
#57 colorless green idea / @dkrentzlin - Score: 43 - 11/22/24 @ 10:31
/s<CR>a:<Esc>/gea<BS><CR>al<BS><Esc>la:<Esc>llrI<Esc>/10<CR>wi.0<Esc>/r<CR>dw:wq<CR>

0 comments


Created by: @pacuna

57 active golfers, 173 entries

Leaderboard (lowest score wins):
23
#31 - Berkay Berabi / @BBerabi

02/01/2025 at 04:02PM

25
#32 - daniilsvirin / @daniilsvirin

10/21/2024 at 08:34AM

25
#33 - JMTed / @JMTed

10/21/2024 at 10:51AM

25
#34 - ProGamerYeet / @ProGamerYeet

10/21/2024 at 01:32PM

25
#35 - _3tHeR_ / @3ther-joyboy

11/11/2024 at 10:37AM

25
#36 - enaygit / @enaygit

02/15/2025 at 05:10AM

26
#37 - Ban / @Rheriel

10/21/2024 at 06:12AM

26
#38 - thedvd98 / @thedvd98

11/03/2024 at 11:31AM

26
#39 - Tzadiko / @Tzadiko

12/17/2024 at 01:57AM

26
#40 - Biswajit / @biswajitpatra

01/26/2025 at 03:12PM

26
#41 - SD / @SD24757629

04/06/2025 at 07:45AM

26
#42 - estoneman / @estoneman

04/23/2025 at 03:23AM

28
#43 - romache8 / @romache8

12/11/2024 at 12:23PM

28
#44 - poudyal_rabin / @poudyal_rabin

01/07/2025 at 12:53PM

28
#45 - chujDK / @chujDK

03/04/2025 at 07:48AM

29
#46 - Mikael Axelsson / @muxare

10/21/2024 at 01:08PM

29
#47 - ak@developer / @Ajay-056

10/25/2024 at 10:44AM

31
#48 - Ivan Prikaznov / @Prikaz98

10/31/2024 at 12:55PM

32
#49 - Leo / @Leoduck

10/30/2024 at 01:14PM

32
#50 - cr100 / @rekicc

11/08/2024 at 07:33AM

32
#51 - Christian Foster / @fosteeco

12/22/2024 at 01:28AM

32
#52 - SRINIVASU SALADI / @SRINIVASUS22587

03/14/2025 at 06:43AM

32
#53 - vimster12312 / @vimster12394846

04/27/2025 at 10:39PM

34
#54 - Kristóf Cserpes / @KriCse

10/28/2024 at 09:06AM

35
#55 - Лихачев Арсений / @lizaruche

11/07/2024 at 05:43PM

37
#56 - beethovn1204 / @beethovn1204

12/27/2024 at 02:57PM

43
#57 - colorless green idea / @dkrentzlin

11/22/2024 at 10:31AM