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):
30
#91 - Marco Biasini / @biasmv

08/01/2014 at 08:17PM

30
#92 - Florian Gauger / @FlorianGauger

06/05/2017 at 08:47PM

30
#93 - QingyuZhao / @zhao_qingyu

11/21/2017 at 09:22AM

31
#94 - Oddbike / @oddbike

04/01/2014 at 12:22PM

31
#95 - Marcin Cabaj / @marcincabaj

04/03/2014 at 08:07PM

31
#96 - usrbin / @notusrbin

04/09/2014 at 05:04PM

31
#97 - Jeff Runningen / @jeffrunningen

04/10/2014 at 08:14PM

31
#98 - Milind Ganjoo / @mganjoo

04/23/2014 at 08:40PM

31
#99 - 土ヤ / @ttsuchiya

04/25/2014 at 08:29AM

31
#100 - skensell / @skensell

04/27/2014 at 12:09AM

31
#101 - Marcin Mucha / @marcinmucha

04/28/2014 at 03:50PM

31
#102 - Dane Summers / @dsummersl

05/30/2014 at 01:28PM

31
#103 - T / @tea_sea

08/06/2014 at 01:22PM

31
#104 - Mauro Persano / @fzort

06/05/2015 at 07:30PM

31
#105 - TweetDreams / @TweetMusicians

10/16/2016 at 07:19AM

32
#106 - Nabi Studios / @Toribash

03/29/2014 at 01:59PM

32
#107 - Richard Ramsden / @rramsden

03/31/2014 at 01:52AM

32
#108 - Aidan Brumsickle / @aidanbrumsickle

04/02/2014 at 12:59PM

32
#109 - Jared Meyering / @Jmeyering

04/11/2014 at 02:54PM

32
#110 - Chris Trombley / @ctrombley

04/23/2014 at 10:38PM

32
#111 - Markus Kasper / @KasperBox

05/16/2014 at 08:39PM

32
#112 - TapTemplate / @TapTemplate

06/25/2014 at 12:25PM

32
#113 - Caek / @Caek_

06/27/2014 at 03:26AM

32
#114 - Ram Tamtam / @ramtamtamtam

07/07/2014 at 08:44PM

32
#115 - Ryan / @murftown

07/27/2014 at 03:24PM

32
#116 - Noah Ruderman / @noahc66260

10/04/2014 at 04:48AM

32
#117 - Carlos A Henríquez Q / @lagunex

01/18/2015 at 09:17PM

32
#118 - Oliver Christ / @0liverChrist

02/08/2015 at 08:48PM

32
#119 - Walker Boh / @walker_boh

10/09/2015 at 10:35AM

32
#120 - И К / @igorjan94

09/15/2016 at 08:37AM