Skip to content

Instantly share code, notes, and snippets.

@pirapira
Created September 5, 2009 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pirapira/181425 to your computer and use it in GitHub Desktop.
Save pirapira/181425 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void main(void) {
int num_problems;
int problem;
char* welcome = "welcome to code jam";
unsigned int ret[strlen(welcome)];
const int wel_len = strlen(welcome);
scanf("%d\n", &num_problems);
for (problem = 1; problem <= num_problems; problem++) {
int len;
int i;
char c;
for (i = 0; i < wel_len; i ++)
ret[i] = 0;
printf("Case #%d: ", problem);
while (c = getchar()) {
int j;
if (c == '\n') break;
for (j = wel_len - 1; j >= 0 ; j --) {
if (welcome[j] == c) {
int previous = (j == 0) ? 1 : ret[j-1];
ret[j] += previous;
ret[j] %= 10000;
}
}
}
printf("%04d\n", ret[wel_len - 1]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment