#include <stdio.h>
#include <string.h>
#include "euler.h"

typedef int (*problem_fn)(void);

typedef struct {
    const char *name;
    problem_fn fn;
} ProblemEntry;

int main(int argc, char **argv)
{
    printf("Built with %s\n\n", COMPILER_NAME);

    if (argc < 2) {
        printf("Usage: %s <problem>\n", argv[0]);
        return 1;
    }

    ProblemEntry table[] = {
        {"p1",  p1},
        {"p2",  p2},
        {"p3",  p3},
        {"p4",  p4},
        {"p5",  p5},
        {"p6",  p6},
        {"p7",  p7},
        {"p10", p10},
    };

    size_t count = sizeof(table) / sizeof(table[0]);

    for (size_t i = 0; i < count; i++) {
        if (strcmp(argv[1], table[i].name) == 0)
            return table[i].fn();
    }

    printf("Unknown problem: %s\n", argv[1]);
    return 1;
}
