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