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 52 remaining solutions by signing in and submitting your own entry
#53 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

53 active golfers, 158 entries

Leaderboard (lowest score wins):
9
#1 - arte7 / @arte7

11/22/2024 at 10:29AM

22
#2 - Peppa Pig / @PeppaPigSg

10/21/2024 at 03:34AM

22
#3 - demouo / @demouo

10/21/2024 at 01:32PM

22
#4 - Pablo Acuna / @pacuna

10/21/2024 at 06:28PM

22
#5 - dlum20 / @dlum20

10/22/2024 at 01:00AM

22
#6 - Roger Stoltz / @rogsto1

10/22/2024 at 08:04AM

22
#7 - John Braxler / @braxler

10/23/2024 at 02:19PM

22
#8 - timonjamjam1 / @timonjamjam1

10/24/2024 at 10:25PM

22
#9 - Fredrik Robertsen / @fredrikr79

10/25/2024 at 03:17PM

22
#10 - aaay-aaay / @aaay-aaay

10/25/2024 at 04:14PM

22
#11 - got_windy / @insomnight

10/28/2024 at 08:51AM

22
#12 - Brieuc Praud / @brieuc-praud

10/31/2024 at 08:17PM

22
#13 - Melih Aktop / @mlhktp

11/01/2024 at 09:04PM

22
#14 - editor3D / @editor3D

11/16/2024 at 01:04AM

22
#15 - Danilo J. S. Bellini ๐ŸฅŠ๐Ÿ‡ง๐Ÿ‡ท / @danilobellini

11/16/2024 at 06:18AM

22
#16 - Michael Cuffaro / @maiku1008

11/16/2024 at 12:16PM

22
#17 - Julien Durillon / @juuduu

11/22/2024 at 02:40PM

22
#18 - Brendan Maginnis / @brendanator

12/09/2024 at 06:18PM

22
#19 - Batyr Asadullin / @Sengoku11

12/12/2024 at 02:56PM

22
#20 - George Golubev / @george-gol

01/22/2025 at 06:02PM

22
#21 - Alexander Cai / @adzcai

02/01/2025 at 05:14PM

22
#22 - Kamal Aghayev / @agayev169

03/04/2025 at 06:11PM

22
#23 - ymte / @ymte

03/28/2025 at 08:59AM

22
#24 - Abdelrahman Madkour / @a3madkour

04/02/2025 at 06:52PM

23
#25 - Keane / @keanesc

10/23/2024 at 04:25AM

23
#26 - DayuanX / @DayuanX

11/02/2024 at 10:35AM

23
#27 - Chloe Brett / @chloebrett

11/09/2024 at 08:50AM

23
#28 - MC / @MC88686523

01/18/2025 at 06:22PM

23
#29 - Berkay Berabi / @BBerabi

02/01/2025 at 04:02PM

25
#30 - daniilsvirin / @daniilsvirin

10/21/2024 at 08:34AM