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 59553bd164628d0009000038

Missing Library and a Typo

I forgot to add a c library, please add it for me. Also I'm bad at typing so fix my typo too.

Start file
#define MIN_NUMBER 1
#define MAX_NUMBER 100
#include <stdio.h>
#include <time.h>
#include <stdlib.h>

int getGuess(){
   
int c;
   
int guess = 0;

   
while(guess < MIN_NUMBER || guess > MAX_NUMBER){
        printf
("Guess: ");
        scanf
("%d", &guess);

       
while((c = getchar()) != '\n' && c != EOF);
   
}

   
return guess;
}

int main(){
    srand
(time(NULL));
   
int number = rand()%(MAX_NUMBER-MIN_NUMBER+1)+MIN_NUMBER;

    printf
("Let's start a game.\n");
    printf
("I've picked a number between %d and %d\n",MIN_NUMBER,MAX_NUMBER);
    printf
("Guess what it is and I'll tell you \n");
    printf
("if it's higher or lower.\n");
    printf
("You win if you guess it in 7 turns or less\n\n");

   
int turn;
   
for(turn = 0; turn < 7; turn++){
       
int guess = getGuess();
       
assert(guess>=MIN_NUMBER && guess<=MAX_NUMBER);

       
if(guess < number){
            printf
("Higher\n\n");
       
}else if(guess > number){
            printf
("Lower\n\n");
       
}else{
           
break;
       
}
   
}

   
if(turn < 7)
        printf
("\nYou Win!\n");
   
else
        printf
("You Lose the answer was %d.\n", number);

   
return 0;
}
// I think I forgot to include the library assetr
End file
#define MIN_NUMBER 1
#define MAX_NUMBER 100
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <assert.h>

int getGuess(){
   
int c;
   
int guess = 0;

   
while(guess < MIN_NUMBER || guess > MAX_NUMBER){
        printf
("Guess: ");
        scanf
("%d", &guess);

       
while((c = getchar()) != '\n' && c != EOF);
   
}

   
return guess;
}

int main(){
    srand
(time(NULL));
   
int number = rand()%(MAX_NUMBER-MIN_NUMBER+1)+MIN_NUMBER;

    printf
("Let's start a game.\n");
    printf
("I've picked a number between %d and %d\n",MIN_NUMBER,MAX_NUMBER);
    printf
("Guess what it is and I'll tell you \n");
    printf
("if it's higher or lower.\n");
    printf
("You win if you guess it in 7 turns or less\n\n");

   
int turn;
   
for(turn = 0; turn < 7; turn++){
       
int guess = getGuess();
       
assert(guess>=MIN_NUMBER && guess<=MAX_NUMBER);

       
if(guess < number){
            printf
("Higher\n\n");
       
}else if(guess > number){
            printf
("Lower\n\n");
       
}else{
           
break;
       
}
   
}

   
if(turn < 7)
        printf
("\nYou Win!\n");
   
else
        printf
("You Lose the answer was %d.\n", number);

   
return 0;
}
// I think I forgot to include the library assert

View Diff

5a6
> #include <assert.h>
52c53
< // I think I forgot to include the library assetr
---
> // I think I forgot to include the library assert

Solutions by @Rt6RjEAJ987Woes:

Unlock 12 remaining solutions by signing in and submitting your own entry
Created by: @BBernardoni

213 active golfers, 887 entries

Solutions by @Rt6RjEAJ987Woes:
17
#118 - 默罕默德 / @Rt6RjEAJ987Woes

01/22/2019 at 01:18PM

18
#>136 - 默罕默德 / @Rt6RjEAJ987Woes

01/22/2019 at 01:18PM

19
#>142 - 默罕默德 / @Rt6RjEAJ987Woes

01/22/2019 at 01:15PM

19
#>142 - 默罕默德 / @Rt6RjEAJ987Woes

01/22/2019 at 01:15PM

20
#>148 - 默罕默德 / @Rt6RjEAJ987Woes

01/22/2019 at 01:06PM

21
#>165 - 默罕默德 / @Rt6RjEAJ987Woes

01/22/2019 at 01:05PM

22
#>176 - 默罕默德 / @Rt6RjEAJ987Woes

01/22/2019 at 01:04PM

23
#>187 - 默罕默德 / @Rt6RjEAJ987Woes

01/22/2019 at 01:02PM

26
#>198 - 默罕默德 / @Rt6RjEAJ987Woes

01/22/2019 at 01:02PM

27
#>199 - 默罕默德 / @Rt6RjEAJ987Woes

01/22/2019 at 12:59PM

33
#>206 - 默罕默德 / @Rt6RjEAJ987Woes

01/22/2019 at 12:59PM

34
#>206 - 默罕默德 / @Rt6RjEAJ987Woes

01/22/2019 at 12:58PM