Added day predictor

This commit is contained in:
Mattia Mascarello 2024-12-16 10:50:01 +01:00
parent 2f7a9209d8
commit ced29a1974

644
haiku.c
View File

@ -2,6 +2,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
#include <sys/random.h> #include <sys/random.h>
#include <errno.h>
// Function to pick a random word/phrase from an array // Function to pick a random word/phrase from an array
const char *randomWord(const char *words[], int size) const char *randomWord(const char *words[], int size)
@ -204,321 +205,344 @@ const char *randomLocation()
return randomWord(locations, sizeof(locations) / sizeof(locations[0])); return randomWord(locations, sizeof(locations) / sizeof(locations[0]));
} }
int main() int main(int argc, char *argv[])
{ {
int days = 1;
srand(time(NULL) / 86400); // today's haiku if (argc > 1)
// Construct a poem with 6 lines
// printf("An Hermetic Poem:\n\n");
int verseCount = 1; // haiku
for (int i = 0; i < verseCount; i++)
{ {
// error check strtol
switch (rand() % 100) char *endptr;
errno = 0;
days = strtol(argv[1], &endptr, 10);
if (errno != 0 || endptr == argv[1] || *endptr != '\0' || days <= 0)
{ {
case 0: fprintf(stderr, "Could not convert argument to integer\n");
printf("%s %s %s.\n", randomAdjective(), randomNoun(), randomVerb()); printf("Usage: %s [days]\n", argv[0]);
break; return 1;
case 1: }
printf("%s %s %s %s.\n", randomAdjective(), randomNoun(), randomVerb(), randomLocation()); }
break;
case 2: for (int day = 0; day < days; day++)
printf("Beneath the %s, the %s %s.\n", randomNoun(), randomAdjective(), randomVerb()); {
break;
case 3: if (days != 1)
printf("Through the %s, %s %s %s.\n", randomLocation(), randomAdjective(), randomVerb(), randomNoun()); {
break; time_t t = time(NULL);
case 4: t += day * 86400;
printf("%s %s, %s %s.\n", randomNoun(), randomVerb(), randomAdjective(), randomNoun()); struct tm tm = *localtime(&t);
break; printf("%d-%02d-%02d ", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday);
case 5: }
printf("%s %s %s, lost in the %s.\n", randomAdjective(), randomVerb(), randomNoun(), randomLocation()); srand(time(NULL) / 86400 + day);
break;
case 6: int verseCount = 1; // haiku
printf("A %s %s under the %s sky.\n", randomAdjective(), randomNoun(), randomNoun()); for (int i = 0; i < verseCount; i++)
break; {
case 7:
printf("In the %s of the %s, we %s.\n", randomLocation(), randomNoun(), randomVerb()); switch (rand() % 100)
break; {
case 8: case 0:
printf("%s whispers %s.\n", randomNoun(), randomVerb()); printf("%s %s %s.\n", randomAdjective(), randomNoun(), randomVerb());
break; break;
case 9: case 1:
printf("With the %s %s, a %s %s.\n", randomAdjective(), randomNoun(), randomNoun(), randomVerb()); printf("%s %s %s %s.\n", randomAdjective(), randomNoun(), randomVerb(), randomLocation());
break; break;
case 10: case 2:
printf("%s %s in the %s.\n", randomAdjective(), randomVerb(), randomLocation()); printf("Beneath the %s, the %s %s.\n", randomNoun(), randomAdjective(), randomVerb());
break; break;
case 11: case 3:
printf("%s %s, across the %s.\n", randomAdjective(), randomVerb(), randomLocation()); printf("Through the %s, %s %s %s.\n", randomLocation(), randomAdjective(), randomVerb(), randomNoun());
break; break;
case 12: case 4:
printf("A %s %s beyond the %s.\n", randomAdjective(), randomNoun(), randomLocation()); printf("%s %s, %s %s.\n", randomNoun(), randomVerb(), randomAdjective(), randomNoun());
break; break;
case 13: case 5:
printf("At the %s's edge, %s %s.\n", randomLocation(), randomVerb(), randomAdjective()); printf("%s %s %s, lost in the %s.\n", randomAdjective(), randomVerb(), randomNoun(), randomLocation());
break; break;
case 14: case 6:
printf("Among the %s, the %s %s.\n", randomNoun(), randomAdjective(), randomVerb()); printf("A %s %s under the %s sky.\n", randomAdjective(), randomNoun(), randomNoun());
break; break;
case 15: case 7:
printf("Through the %s %s %s.\n", randomNoun(), randomVerb(), randomLocation()); printf("In the %s of the %s, we %s.\n", randomLocation(), randomNoun(), randomVerb());
break; break;
case 16: case 8:
printf("%s calls %s, under the %s sky.\n", randomNoun(), randomVerb(), randomAdjective()); printf("%s whispers %s.\n", randomNoun(), randomVerb());
break; break;
case 17: case 9:
printf("%s in the %s, %s echoes.\n", randomVerb(), randomLocation(), randomNoun()); printf("With the %s %s, a %s %s.\n", randomAdjective(), randomNoun(), randomNoun(), randomVerb());
break; break;
case 18: case 10:
printf("A %s %s %s through the %s.\n", randomAdjective(), randomNoun(), randomVerb(), randomLocation()); printf("%s %s in the %s.\n", randomAdjective(), randomVerb(), randomLocation());
break; break;
case 19: case 11:
printf("%s the %s, %s %s.\n", randomVerb(), randomNoun(), randomAdjective(), randomVerb()); printf("%s %s, across the %s.\n", randomAdjective(), randomVerb(), randomLocation());
break; break;
case 20: case 12:
printf("%s %s, by the %s's edge.\n", randomVerb(), randomAdjective(), randomLocation()); printf("A %s %s beyond the %s.\n", randomAdjective(), randomNoun(), randomLocation());
break; break;
case 21: case 13:
printf("Beneath the %s, a %s %s.\n", randomLocation(), randomNoun(), randomVerb()); printf("At the %s's edge, %s %s.\n", randomLocation(), randomVerb(), randomAdjective());
break; break;
case 22: case 14:
printf("%s of the %s %s.\n", randomAdjective(), randomNoun(), randomVerb()); printf("Among the %s, the %s %s.\n", randomNoun(), randomAdjective(), randomVerb());
break; break;
case 23: case 15:
printf("With the %s, a %s %s.\n", randomNoun(), randomAdjective(), randomVerb()); printf("Through the %s %s %s.\n", randomNoun(), randomVerb(), randomLocation());
break; break;
case 24: case 16:
printf("Among the %s, we %s %s.\n", randomLocation(), randomVerb(), randomAdjective()); printf("%s calls %s, under the %s sky.\n", randomNoun(), randomVerb(), randomAdjective());
break; break;
case 25: case 17:
printf("A %s %s beneath the %s.\n", randomAdjective(), randomNoun(), randomLocation()); printf("%s in the %s, %s echoes.\n", randomVerb(), randomLocation(), randomNoun());
break; break;
case 26: case 18:
printf("%s %s within the %s.\n", randomAdjective(), randomVerb(), randomLocation()); printf("A %s %s %s through the %s.\n", randomAdjective(), randomNoun(), randomVerb(), randomLocation());
break; break;
case 27: case 19:
printf("%s %s, beneath the %s.\n", randomNoun(), randomVerb(), randomLocation()); printf("%s the %s, %s %s.\n", randomVerb(), randomNoun(), randomAdjective(), randomVerb());
break; break;
case 28: case 20:
printf("Through the %s, a %s %s.\n", randomLocation(), randomAdjective(), randomNoun()); printf("%s %s, by the %s's edge.\n", randomVerb(), randomAdjective(), randomLocation());
break; break;
case 29: case 21:
printf("Within the %s, the %s %s.\n", randomLocation(), randomAdjective(), randomVerb()); printf("Beneath the %s, a %s %s.\n", randomLocation(), randomNoun(), randomVerb());
break; break;
case 30: case 22:
printf("%s %s, under the %s sky.\n", randomAdjective(), randomVerb(), randomLocation()); printf("%s of the %s %s.\n", randomAdjective(), randomNoun(), randomVerb());
break; break;
case 31: case 23:
printf("By the %s, the %s %s.\n", randomLocation(), randomNoun(), randomVerb()); printf("With the %s, a %s %s.\n", randomNoun(), randomAdjective(), randomVerb());
break; break;
case 32: case 24:
printf("A %s %s through the %s.\n", randomAdjective(), randomNoun(), randomLocation()); printf("Among the %s, we %s %s.\n", randomLocation(), randomVerb(), randomAdjective());
break; break;
case 33: case 25:
printf("We %s beneath the %s %s.\n", randomVerb(), randomAdjective(), randomNoun()); printf("A %s %s beneath the %s.\n", randomAdjective(), randomNoun(), randomLocation());
break; break;
case 34: case 26:
printf("%s %s across the %s.\n", randomNoun(), randomVerb(), randomLocation()); printf("%s %s within the %s.\n", randomAdjective(), randomVerb(), randomLocation());
break; break;
case 35: case 27:
printf("%s, a %s %s.\n", randomLocation(), randomAdjective(), randomVerb()); printf("%s %s, beneath the %s.\n", randomNoun(), randomVerb(), randomLocation());
break; break;
case 36: case 28:
printf("Amidst the %s, a %s %s.\n", randomLocation(), randomAdjective(), randomNoun()); printf("Through the %s, a %s %s.\n", randomLocation(), randomAdjective(), randomNoun());
break; break;
case 37: case 29:
printf("By the %s's edge, the %s %s.\n", randomLocation(), randomNoun(), randomVerb()); printf("Within the %s, the %s %s.\n", randomLocation(), randomAdjective(), randomVerb());
break; break;
case 38: case 30:
printf("%s %s by the %s.\n", randomAdjective(), randomVerb(), randomLocation()); printf("%s %s, under the %s sky.\n", randomAdjective(), randomVerb(), randomLocation());
break; break;
case 39: case 31:
printf("%s %s, across the %s.\n", randomAdjective(), randomVerb(), randomLocation()); printf("By the %s, the %s %s.\n", randomLocation(), randomNoun(), randomVerb());
break; break;
case 40: case 32:
printf("Within the %s, a %s %s.\n", randomLocation(), randomAdjective(), randomNoun()); printf("A %s %s through the %s.\n", randomAdjective(), randomNoun(), randomLocation());
break; break;
case 41: case 33:
printf("%s of the %s %s.\n", randomNoun(), randomAdjective(), randomVerb()); printf("We %s beneath the %s %s.\n", randomVerb(), randomAdjective(), randomNoun());
break; break;
case 42: case 34:
printf("Through the %s, the %s %s.\n", randomLocation(), randomVerb(), randomAdjective()); printf("%s %s across the %s.\n", randomNoun(), randomVerb(), randomLocation());
break; break;
case 43: case 35:
printf("%s in the %s, we %s.\n", randomAdjective(), randomLocation(), randomVerb()); printf("%s, a %s %s.\n", randomLocation(), randomAdjective(), randomVerb());
break; break;
case 44: case 36:
printf("Among the %s, the %s %s.\n", randomLocation(), randomAdjective(), randomVerb()); printf("Amidst the %s, a %s %s.\n", randomLocation(), randomAdjective(), randomNoun());
break; break;
case 45: case 37:
printf("%s %s across the %s.\n", randomAdjective(), randomVerb(), randomLocation()); printf("By the %s's edge, the %s %s.\n", randomLocation(), randomNoun(), randomVerb());
break; break;
case 46: case 38:
printf("%s %s through the %s.\n", randomVerb(), randomNoun(), randomLocation()); printf("%s %s by the %s.\n", randomAdjective(), randomVerb(), randomLocation());
break; break;
case 47: case 39:
printf("In the %s, the %s %s.\n", randomLocation(), randomNoun(), randomVerb()); printf("%s %s, across the %s.\n", randomAdjective(), randomVerb(), randomLocation());
break; break;
case 48: case 40:
printf("A %s %s by the %s.\n", randomAdjective(), randomVerb(), randomLocation()); printf("Within the %s, a %s %s.\n", randomLocation(), randomAdjective(), randomNoun());
break; break;
case 49: case 41:
printf("%s whispers %s through the %s.\n", randomNoun(), randomVerb(), randomLocation()); printf("%s of the %s %s.\n", randomNoun(), randomAdjective(), randomVerb());
break; break;
case 50: case 42:
printf("Through the %s, the %s %s.\n", randomLocation(), randomNoun(), randomVerb()); printf("Through the %s, the %s %s.\n", randomLocation(), randomVerb(), randomAdjective());
break; break;
case 51: case 43:
printf("%s beyond the %s %s.\n", randomNoun(), randomLocation(), randomVerb()); printf("%s in the %s, we %s.\n", randomAdjective(), randomLocation(), randomVerb());
break; break;
case 52: case 44:
printf("%s %s amidst the %s.\n", randomAdjective(), randomVerb(), randomLocation()); printf("Among the %s, the %s %s.\n", randomLocation(), randomAdjective(), randomVerb());
break; break;
case 53: case 45:
printf("%s's %s echoes in the %s.\n", randomLocation(), randomVerb(), randomAdjective()); printf("%s %s across the %s.\n", randomAdjective(), randomVerb(), randomLocation());
break; break;
case 54: case 46:
printf("%s falls across the %s.\n", randomAdjective(), randomLocation()); printf("%s %s through the %s.\n", randomVerb(), randomNoun(), randomLocation());
break; break;
case 55: case 47:
printf("Beneath the %s, the %s %s.\n", randomLocation(), randomNoun(), randomVerb()); printf("In the %s, the %s %s.\n", randomLocation(), randomNoun(), randomVerb());
break; break;
case 56: case 48:
printf("A %s %s in the %s.\n", randomAdjective(), randomNoun(), randomLocation()); printf("A %s %s by the %s.\n", randomAdjective(), randomVerb(), randomLocation());
break; break;
case 57: case 49:
printf("In the %s, the %s %s.\n", randomLocation(), randomAdjective(), randomVerb()); printf("%s whispers %s through the %s.\n", randomNoun(), randomVerb(), randomLocation());
break; break;
case 58: case 50:
printf("At the %s's edge, we %s.\n", randomLocation(), randomVerb()); printf("Through the %s, the %s %s.\n", randomLocation(), randomNoun(), randomVerb());
break; break;
case 59: case 51:
printf("%s, fading through the %s.\n", randomAdjective(), randomLocation()); printf("%s beyond the %s %s.\n", randomNoun(), randomLocation(), randomVerb());
break; break;
case 60: case 52:
printf("With the %s, we %s through the %s.\n", randomAdjective(), randomVerb(), randomLocation()); printf("%s %s amidst the %s.\n", randomAdjective(), randomVerb(), randomLocation());
break; break;
case 61: case 53:
printf("A %s %s beneath the %s.\n", randomAdjective(), randomNoun(), randomLocation()); printf("%s's %s echoes in the %s.\n", randomLocation(), randomVerb(), randomAdjective());
break; break;
case 62: case 54:
printf("%s calls beneath the %s.\n", randomAdjective(), randomLocation()); printf("%s falls across the %s.\n", randomAdjective(), randomLocation());
break; break;
case 63: case 55:
printf("We %s through the %s.\n", randomVerb(), randomLocation()); printf("Beneath the %s, the %s %s.\n", randomLocation(), randomNoun(), randomVerb());
break; break;
case 64: case 56:
printf("%s stands by the %s.\n", randomNoun(), randomLocation()); printf("A %s %s in the %s.\n", randomAdjective(), randomNoun(), randomLocation());
break; break;
case 65: case 57:
printf("%s beneath the %s, a %s %s.\n", randomVerb(), randomLocation(), randomAdjective(), randomNoun()); printf("In the %s, the %s %s.\n", randomLocation(), randomAdjective(), randomVerb());
break; break;
case 66: case 58:
printf("In the %s, we %s the %s.\n", randomLocation(), randomVerb(), randomAdjective()); printf("At the %s's edge, we %s.\n", randomLocation(), randomVerb());
break; break;
case 67: case 59:
printf("With the %s, we %s the %s.\n", randomAdjective(), randomVerb(), randomLocation()); printf("%s, fading through the %s.\n", randomAdjective(), randomLocation());
break; break;
case 68: case 60:
printf("Through the %s, a %s %s.\n", randomLocation(), randomAdjective(), randomNoun()); printf("With the %s, we %s through the %s.\n", randomAdjective(), randomVerb(), randomLocation());
break; break;
case 69: case 61:
printf("%s %s through the %s.\n", randomNoun(), randomVerb(), randomLocation()); printf("A %s %s beneath the %s.\n", randomAdjective(), randomNoun(), randomLocation());
break; break;
case 70: case 62:
printf("Across the %s, the %s %s.\n", randomLocation(), randomVerb(), randomAdjective()); printf("%s calls beneath the %s.\n", randomAdjective(), randomLocation());
break; break;
case 71: case 63:
printf("%s the %s %s.\n", randomVerb(), randomAdjective(), randomNoun()); printf("We %s through the %s.\n", randomVerb(), randomLocation());
break; break;
case 72: case 64:
printf("We %s across the %s.\n", randomVerb(), randomLocation()); printf("%s stands by the %s.\n", randomNoun(), randomLocation());
break; break;
case 73: case 65:
printf("%s's %s resounds in the %s.\n", randomLocation(), randomVerb(), randomAdjective()); printf("%s beneath the %s, a %s %s.\n", randomVerb(), randomLocation(), randomAdjective(), randomNoun());
break; break;
case 74: case 66:
printf("%s whispers across the %s.\n", randomNoun(), randomLocation()); printf("In the %s, we %s the %s.\n", randomLocation(), randomVerb(), randomAdjective());
break; break;
case 75: case 67:
printf("%s the %s, a %s %s.\n", randomVerb(), randomNoun(), randomAdjective(), randomVerb()); printf("With the %s, we %s the %s.\n", randomAdjective(), randomVerb(), randomLocation());
break; break;
case 76: case 68:
printf("%s fades into the %s.\n", randomAdjective(), randomLocation()); printf("Through the %s, a %s %s.\n", randomLocation(), randomAdjective(), randomNoun());
break; break;
case 77: case 69:
printf("In the %s, the %s %s.\n", randomLocation(), randomAdjective(), randomVerb()); printf("%s %s through the %s.\n", randomNoun(), randomVerb(), randomLocation());
break; break;
case 78: case 70:
printf("We %s beyond the %s.\n", randomVerb(), randomLocation()); printf("Across the %s, the %s %s.\n", randomLocation(), randomVerb(), randomAdjective());
break; break;
case 79: case 71:
printf("%s echoes in the %s.\n", randomNoun(), randomLocation()); printf("%s the %s %s.\n", randomVerb(), randomAdjective(), randomNoun());
break; break;
case 80: case 72:
printf("%s %s under the %s.\n", randomNoun(), randomVerb(), randomLocation()); printf("We %s across the %s.\n", randomVerb(), randomLocation());
break; break;
case 81: case 73:
printf("Through the %s %s %s.\n", randomLocation(), randomVerb(), randomNoun()); printf("%s's %s resounds in the %s.\n", randomLocation(), randomVerb(), randomAdjective());
break; break;
case 82: case 74:
printf("In the %s, the %s %s.\n", randomLocation(), randomVerb(), randomAdjective()); printf("%s whispers across the %s.\n", randomNoun(), randomLocation());
break; break;
case 83: case 75:
printf("With the %s, a %s %s.\n", randomAdjective(), randomNoun(), randomVerb()); printf("%s the %s, a %s %s.\n", randomVerb(), randomNoun(), randomAdjective(), randomVerb());
break; break;
case 84: case 76:
printf("In the %s, we %s %s.\n", randomLocation(), randomVerb(), randomNoun()); printf("%s fades into the %s.\n", randomAdjective(), randomLocation());
break; break;
case 85: case 77:
printf("Through the %s, a %s %s.\n", randomLocation(), randomAdjective(), randomNoun()); printf("In the %s, the %s %s.\n", randomLocation(), randomAdjective(), randomVerb());
break; break;
case 86: case 78:
printf("A %s %s across the %s.\n", randomAdjective(), randomNoun(), randomLocation()); printf("We %s beyond the %s.\n", randomVerb(), randomLocation());
break; break;
case 87: case 79:
printf("%s calls, fading into the %s.\n", randomNoun(), randomLocation()); printf("%s echoes in the %s.\n", randomNoun(), randomLocation());
break; break;
case 88: case 80:
printf("By the %s's edge, the %s %s.\n", randomLocation(), randomNoun(), randomVerb()); printf("%s %s under the %s.\n", randomNoun(), randomVerb(), randomLocation());
break; break;
case 89: case 81:
printf("A %s stands in the %s.\n", randomAdjective(), randomLocation()); printf("Through the %s %s %s.\n", randomLocation(), randomVerb(), randomNoun());
break; break;
case 90: case 82:
printf("With the %s, the %s %s.\n", randomAdjective(), randomNoun(), randomVerb()); printf("In the %s, the %s %s.\n", randomLocation(), randomVerb(), randomAdjective());
break; break;
case 91: case 83:
printf("In the %s, we %s the %s.\n", randomLocation(), randomVerb(), randomAdjective()); printf("With the %s, a %s %s.\n", randomAdjective(), randomNoun(), randomVerb());
break; break;
case 92: case 84:
printf("Among the %s, the %s %s.\n", randomLocation(), randomNoun(), randomVerb()); printf("In the %s, we %s %s.\n", randomLocation(), randomVerb(), randomNoun());
break; break;
case 93: case 85:
printf("By the %s's edge, a %s %s.\n", randomLocation(), randomAdjective(), randomVerb()); printf("Through the %s, a %s %s.\n", randomLocation(), randomAdjective(), randomNoun());
break; break;
case 94: case 86:
printf("%s %s beneath the %s.\n", randomAdjective(), randomVerb(), randomLocation()); printf("A %s %s across the %s.\n", randomAdjective(), randomNoun(), randomLocation());
break; break;
case 95: case 87:
printf("Across the %s, a %s %s.\n", randomLocation(), randomAdjective(), randomVerb()); printf("%s calls, fading into the %s.\n", randomNoun(), randomLocation());
break; break;
case 96: case 88:
printf("Through the %s, the %s %s.\n", randomLocation(), randomAdjective(), randomVerb()); printf("By the %s's edge, the %s %s.\n", randomLocation(), randomNoun(), randomVerb());
break; break;
case 97: case 89:
printf("In the %s, a %s %s.\n", randomLocation(), randomAdjective(), randomVerb()); printf("A %s stands in the %s.\n", randomAdjective(), randomLocation());
break; break;
case 98: case 90:
printf("%s %s across the %s.\n", randomAdjective(), randomVerb(), randomLocation()); printf("With the %s, the %s %s.\n", randomAdjective(), randomNoun(), randomVerb());
break; break;
case 99: case 91:
printf("In the %s, the %s %s.\n", randomLocation(), randomVerb(), randomNoun()); printf("In the %s, we %s the %s.\n", randomLocation(), randomVerb(), randomAdjective());
break; break;
case 92:
printf("Among the %s, the %s %s.\n", randomLocation(), randomNoun(), randomVerb());
break;
case 93:
printf("By the %s's edge, a %s %s.\n", randomLocation(), randomAdjective(), randomVerb());
break;
case 94:
printf("%s %s beneath the %s.\n", randomAdjective(), randomVerb(), randomLocation());
break;
case 95:
printf("Across the %s, a %s %s.\n", randomLocation(), randomAdjective(), randomVerb());
break;
case 96:
printf("Through the %s, the %s %s.\n", randomLocation(), randomAdjective(), randomVerb());
break;
case 97:
printf("In the %s, a %s %s.\n", randomLocation(), randomAdjective(), randomVerb());
break;
case 98:
printf("%s %s across the %s.\n", randomAdjective(), randomVerb(), randomLocation());
break;
case 99:
printf("In the %s, the %s %s.\n", randomLocation(), randomVerb(), randomNoun());
break;
}
} }
} }
return 0; return 0;
} }