Skip to content

Instantly share code, notes, and snippets.

@jmcph4
Created July 4, 2024 04:34
Show Gist options
  • Save jmcph4/3cc5900ebddd56a3961b8e9172dc3b74 to your computer and use it in GitHub Desktop.
Save jmcph4/3cc5900ebddd56a3961b8e9172dc3b74 to your computer and use it in GitHub Desktop.
Guess a 4-digit PIN
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#define MAX_PIN 9999
int main(int argc, char** argv) {
if (argc != 2) {
printf("usage: guess pin\n");
return EXIT_FAILURE;
}
uint16_t pin = atoi(argv[1]);
for (uint16_t i=0;i<MAX_PIN;i++) {
if (i == pin) {
printf("done\n");
break;
}
}
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment