sleep makes solving problems easier. Day1 fully done

This commit is contained in:
Preston Baxter 2023-12-05 08:09:53 -06:00
parent 45dfb8f726
commit 47d0073217
4 changed files with 6 additions and 6 deletions

BIN
day1/day1

Binary file not shown.

View File

@ -76,7 +76,6 @@ int decodeB(const char *str) {
if (isalpha(back)) {
pushs(bl, back);
char *bw = contentb(bl);
printf("%s", bw);
num = getnumber(bw);
free(bw);
if (num > 0) {
@ -86,7 +85,7 @@ int decodeB(const char *str) {
ones = back - 48;
}
}
printf("front %c, tens %d, back %d, ones %d\n", front, tens, back, ones);
// printf("front %c, tens %d, back %d, ones %d\n", front, tens, back, ones);
}
return tens * 10 + ones;
@ -107,7 +106,7 @@ int decodeA(const char *str) {
if (!isalpha(back) && ones < 0) {
ones = back - 48;
}
printf("front %c, tens %d, back %d, ones %d\n", front, tens, back, ones);
// printf("front %c, tens %d, back %d, ones %d\n", front, tens, back, ones);
}
return tens * 10 + ones;
@ -138,7 +137,7 @@ char getnumber(const char *str) {
if (strstr(str, "eight") != NULL) {
return '8';
}
if (strstr(str, "9") != NULL) {
if (strstr(str, "nine") != NULL) {
return '9';
}
return -1;

View File

@ -1 +1 @@
eightwothree
two1nine

View File

@ -73,7 +73,8 @@ char* contents(list *l) {
char* contentb(list *l) {
char *out = (char*)malloc(l->size * sizeof(char) + 1);
for (int i = 0; i<l->size; i++){
out[i] = pops(l);
int index = l->head - i;
out[i] = l->arr[index];
}
out[l->size] = '\0';