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 53369b712a09c1000223fb57

Two become one

We have two c arrays and want to make one two dimensional out of it. Can we do that?

Start file
/* Frame (32 bytes) */
static const unsigned char pkt1[32] = {
0x08, 0x60, 0x6e, 0xf1, 0x3c, 0xb9, 0x9c, 0xc7, /* .`n.<... */
0xa6, 0x35, 0x08, 0x12, 0x08, 0x00, 0x45, 0x00, /* .5....E. */
0x05, 0xdc, 0x1b, 0xe3, 0x40, 0x00, 0x31, 0x06, /* ....@.1. */
0xe8, 0xc8, 0xcb, 0xd9, 0x00, 0xda, 0xc0, 0xa8  /* ........ */
};

/* Frame (32 bytes) */
static const unsigned char pkt2[32] = {
0x08, 0x60, 0x6e, 0xf1, 0x3c, 0xb9, 0x9c, 0xc7, /* .`n.<... */
0xa6, 0x35, 0x08, 0x12, 0x08, 0x00, 0x45, 0x00, /* .5....E. */
0x05, 0xdc, 0x6b, 0x98, 0x40, 0x00, 0x31, 0x06, /* ..k.@.1. */
0x99, 0x13, 0xcb, 0xd9, 0x00, 0xda, 0xc0, 0xa8, /* ........ */
};
End file
/* Frame (32 bytes) */
static const unsigned char pkt1[2][32] = {
	{
	0x08, 0x60, 0x6e, 0xf1, 0x3c, 0xb9, 0x9c, 0xc7, /* .`n.<... */
	0xa6, 0x35, 0x08, 0x12, 0x08, 0x00, 0x45, 0x00, /* .5....E. */
	0x05, 0xdc, 0x1b, 0xe3, 0x40, 0x00, 0x31, 0x06, /* ....@.1. */
	0xe8, 0xc8, 0xcb, 0xd9, 0x00, 0xda, 0xc0, 0xa8  /* ........ */
	},
	{
	0x08, 0x60, 0x6e, 0xf1, 0x3c, 0xb9, 0x9c, 0xc7, /* .`n.<... */
	0xa6, 0x35, 0x08, 0x12, 0x08, 0x00, 0x45, 0x00, /* .5....E. */
	0x05, 0xdc, 0x6b, 0x98, 0x40, 0x00, 0x31, 0x06, /* ..k.@.1. */
	0x99, 0x13, 0xcb, 0xd9, 0x00, 0xda, 0xc0, 0xa8, /* ........ */
	}
};

View Diff

2,14c2,14
< static const unsigned char pkt1[32] = {
< 0x08, 0x60, 0x6e, 0xf1, 0x3c, 0xb9, 0x9c, 0xc7, /* .`n.<... */
< 0xa6, 0x35, 0x08, 0x12, 0x08, 0x00, 0x45, 0x00, /* .5....E. */
< 0x05, 0xdc, 0x1b, 0xe3, 0x40, 0x00, 0x31, 0x06, /* ....@.1. */
< 0xe8, 0xc8, 0xcb, 0xd9, 0x00, 0xda, 0xc0, 0xa8  /* ........ */
< };
< 
< /* Frame (32 bytes) */
< static const unsigned char pkt2[32] = {
< 0x08, 0x60, 0x6e, 0xf1, 0x3c, 0xb9, 0x9c, 0xc7, /* .`n.<... */
< 0xa6, 0x35, 0x08, 0x12, 0x08, 0x00, 0x45, 0x00, /* .5....E. */
< 0x05, 0xdc, 0x6b, 0x98, 0x40, 0x00, 0x31, 0x06, /* ..k.@.1. */
< 0x99, 0x13, 0xcb, 0xd9, 0x00, 0xda, 0xc0, 0xa8, /* ........ */
---
> static const unsigned char pkt1[2][32] = {
> 	{
> 	0x08, 0x60, 0x6e, 0xf1, 0x3c, 0xb9, 0x9c, 0xc7, /* .`n.<... */
> 	0xa6, 0x35, 0x08, 0x12, 0x08, 0x00, 0x45, 0x00, /* .5....E. */
> 	0x05, 0xdc, 0x1b, 0xe3, 0x40, 0x00, 0x31, 0x06, /* ....@.1. */
> 	0xe8, 0xc8, 0xcb, 0xd9, 0x00, 0xda, 0xc0, 0xa8  /* ........ */
> 	},
> 	{
> 	0x08, 0x60, 0x6e, 0xf1, 0x3c, 0xb9, 0x9c, 0xc7, /* .`n.<... */
> 	0xa6, 0x35, 0x08, 0x12, 0x08, 0x00, 0x45, 0x00, /* .5....E. */
> 	0x05, 0xdc, 0x6b, 0x98, 0x40, 0x00, 0x31, 0x06, /* ..k.@.1. */
> 	0x99, 0x13, 0xcb, 0xd9, 0x00, 0xda, 0xc0, 0xa8, /* ........ */
> 	}

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 207 remaining solutions by signing in and submitting your own entry
#208 Peter Lustig / @germecon - Score: 123 - 08/06/14 @ 17:46
<C-><Up><C-><Up><C-><Up><C-><Up><C-><Up><C-><Up><C-><Up><C-><Up>j\\f1ijku<Esc>ua[]2<BS>jk<BS><BS><Esc>ba2<Esc>jkoi<BS>{jj<BS><BS><Esc>jjjjjwklrqr,jdd.d5wxxxxxxx\\f}/}<CR>a<CR>}jk<BS><BS><Esc>kkkkkkkkkkkkVjjjjjjjjjjj><Esc>:wq<CR>

0 comments


Created by: @saschagrunert

208 active golfers, 713 entries

Leaderboard (lowest score wins):
25
#1 - trx / @trxdbg

10/27/2016 at 01:35PM

25
#2 - Saki Gw / @Sakigw

12/14/2016 at 04:30AM

25
#3 - Rami Hovi / @hacker_lawyer

05/27/2017 at 04:28AM

25
#4 - Turkey Man / @lvturkeyman

11/21/2017 at 06:31AM

25
#5 - John Braxler / @braxler

09/28/2018 at 01:46PM

25
#6 - alekfed / @alek_fed

04/16/2019 at 11:46AM

25
#7 - Miłosz Łakomy / @foobar01123

12/24/2019 at 05:40AM

25
#8 - Peppa Pig / @PeppaPigSg

07/03/2024 at 04:19AM

26
#9 - Urtica dioica / @udioica

03/29/2014 at 05:04PM

26
#10 - Nikita Kouevda / @nkouevda

04/03/2014 at 09:45PM

26
#11 - Vlad-Ștefan Harbuz / @vladh

04/05/2014 at 01:27AM

26
#12 - G / @drdevil44

04/09/2014 at 03:55PM

26
#13 - Felipe Spychalski / @fspychalski

04/09/2014 at 05:01PM

26
#14 - kiho choi / @ArtStandAlone

04/18/2014 at 10:20AM

26
#15 - Jacob Robles / @JacobRobles0

05/07/2014 at 03:53PM

26
#16 - zmo / @guyzmo

05/07/2014 at 08:34PM

26
#17 - Nolen Royalty / @NolenRoyalty

05/08/2014 at 07:44AM

26
#18 - Alex Tercete / @alextercete

06/03/2014 at 04:39AM

26
#19 - Robert Bruce / @therealrobru

06/10/2014 at 05:42PM

26
#20 - John Meisner / @jmeisned

06/24/2014 at 07:00PM

26
#21 - ゆきみ / @edp02

06/27/2014 at 01:18PM

26
#22 - alexscott / @4l3xsc0tt

06/30/2014 at 04:01PM

26
#23 - Lasse Dalegaard / @ldalegaard

07/06/2014 at 11:41PM

26
#24 - Juan-Lucas Picard / @davidmh

09/09/2014 at 04:34AM

26
#25 - Felix Stridsberg / @FelixStridsberg

09/22/2014 at 05:52PM

26
#26 - Ivan Brennan / @ivanbrennan

12/07/2014 at 01:02AM

26
#27 - kimber gonzalez / @kimberlycreates

02/06/2015 at 09:00PM

26
#28 - Terence Hang / @technic_tec

02/14/2015 at 03:02AM

26
#29 - Matt / @mcr05

03/01/2015 at 10:34AM

26
#30 - Mutter Mumble / @muttermumble

07/12/2015 at 10:16AM