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 565bb80fceffe53baa038f0c

No naked if allowed!

House style forbids naked condition statements, comments should start with a space character and be on their own line. Good luck!

Start file
#include <sock.h>
if (recvfrom(s, (char*)&ms, sizeof(ms), 0, foo, bar) >= 0) //receive initial message frame
{
	f++;
	if (f == snwseq) //if its the right sequence
	{
		if (sendto(s, (char*)&a, sizeof(a), 0, foo, bar) > 0) //Send ACK
			log << "Send ACK " << snwseq << ".\n";
		else
			cout << "Error!" << endl;
	}
	else //wrong sequence
	{
		receive_packet_transfer(s, a, sa, f, slen, snwseq, num); //wait for correct packet
	}
}
else
	cout << "Error!" << endl;
End file
#include <sock.h>
if (recvfrom(s, (char*)&ms, sizeof(ms), 0, foo, bar) >= 0) {
	// receive initial message frame
	f++;
	if (f == snwseq) {
		// if its the right sequence
		if (sendto(s, (char*)&a, sizeof(a), 0, foo, bar) > 0) {
			// Send ACK
			log << "Send ACK " << snwseq << ".\n";
		} else {
			cout << "Error!" << endl;
		}
	} else {
		// wrong sequence
		receive_packet_transfer(s, a, sa, f, slen, snwseq, num);
	}
} else {
	cout << "Error!" << endl;
}

View Diff

2,3c2,3
< if (recvfrom(s, (char*)&ms, sizeof(ms), 0, foo, bar) >= 0) //receive initial message frame
< {
---
> if (recvfrom(s, (char*)&ms, sizeof(ms), 0, foo, bar) >= 0) {
> 	// receive initial message frame
5,7c5,8
< 	if (f == snwseq) //if its the right sequence
< 	{
< 		if (sendto(s, (char*)&a, sizeof(a), 0, foo, bar) > 0) //Send ACK
---
> 	if (f == snwseq) {
> 		// if its the right sequence
> 		if (sendto(s, (char*)&a, sizeof(a), 0, foo, bar) > 0) {
> 			// Send ACK
9c10
< 		else
---
> 		} else {
10a12,15
> 		}
> 	} else {
> 		// wrong sequence
> 		receive_packet_transfer(s, a, sa, f, slen, snwseq, num);
12,17c17
< 	else //wrong sequence
< 	{
< 		receive_packet_transfer(s, a, sa, f, slen, snwseq, num); //wait for correct packet
< 	}
< }
< else
---
> } else {
18a19
> }

Solutions by @vimgolfer7:

Unlock 3 remaining solutions by signing in and submitting your own entry
Created by: @samasuy

17 active golfers, 39 entries

Solutions by @vimgolfer7:
46
#3 - vimgolfer / @vimgolfer7

10/05/2019 at 01:55PM

55
#>6 - vimgolfer / @vimgolfer7

10/05/2019 at 01:43PM

59
#>11 - vimgolfer / @vimgolfer7

10/05/2019 at 01:39PM