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):
32
#121 - Michał Dytko / @DytkoM

12/27/2016 at 01:29PM

32
#122 - vimgolfaccfekxh / @vimgolfaccfekxh

10/30/2022 at 10:34PM

33
#123 - RobertT / @techrt2050

04/01/2014 at 05:29PM

33
#124 - はちよん / @84____

04/22/2014 at 01:09PM

33
#125 - Solar Powered Robot / @moskrin

05/01/2014 at 06:41PM

33
#126 - Sntano Euhsk / @SEuhsk

06/15/2014 at 06:06AM

33
#127 - Chase Lambert / @chasediscs

06/15/2014 at 10:52PM

33
#128 - Tim Vim / @vim_tim

07/01/2014 at 08:47PM

33
#129 - Dominik Szerszeń / @DominikSze

07/22/2014 at 03:11PM

33
#130 - vgmct / @vgmct

04/25/2015 at 06:48PM

34
#131 - Par Narvi / @ParNarvi

03/31/2014 at 04:18PM

34
#132 - Rasmus P / @rasmup

04/05/2014 at 09:26PM

34
#133 - Gabutero / @wizmokeri

04/14/2014 at 02:38AM

34
#134 - wizardwerdna / @wizardwerdna

05/12/2014 at 05:44PM

34
#135 - Drew DeVault / @sircmpwn

05/19/2014 at 06:49PM

34
#136 - shhittbrick / @shhittbrick

06/01/2014 at 01:50AM

34
#137 - Alexey Fedorov / @waterlink000

07/09/2014 at 04:35PM

34
#138 - Etienne Tremel / @etiennetremel

02/20/2016 at 08:40PM

34
#139 - Dan Piponi / @sigfpe

10/04/2016 at 08:25PM

34
#140 - Mark Blakeney / @bulletmark

12/21/2017 at 06:01AM

34
#141 - RockerZZY / @rocker_zzy

06/20/2020 at 02:57AM

34
#142 - bonettimrc / @bonettimrc

04/28/2024 at 10:46AM

35
#143 - James / @Dronak

04/03/2014 at 02:55PM

35
#144 - Jim Vogel / @BIThoughts

04/15/2014 at 06:15PM

35
#145 - Dylan Farnsworth / @FarnsworthDylan

04/21/2014 at 11:46PM

35
#146 - David Shields / @salacio

04/22/2014 at 08:05PM

35
#147 - Olivier Gayot / @duskCoder

05/01/2014 at 04:58PM

35
#148 - Jeff Parent / @jeffparent

05/11/2014 at 02:46AM

35
#149 - Jake Eaton / @Jake__Eaton

06/01/2014 at 05:20AM

35
#150 - Martijn Theunissen / @Damnesia__

06/12/2014 at 11:51PM