CREATE TABLE IF NOT EXISTS problem (
    id          INTEGER PRIMARY KEY,
    title       TEXT NOT NULL,
    description TEXT NOT NULL
);

CREATE TABLE IF NOT EXISTS user (
    id            INTEGER PRIMARY KEY,
    email         TEXT UNIQUE NOT NULL,
    username      TEXT UNIQUE NOT NULL,
    password_hash TEXT NOT NULL,
    is_admin      INTEGER NOT NULL
);

CREATE TABLE IF NOT EXISTS submission (
    id          INTEGER PRIMARY KEY,
    user_id     INTEGER NOT NULL,
    problem_id  INTEGER NOT NULL,
    language    TEXT NOT NULL,
    details     TEXT NOT NULL,
    code        TEXT NOT NULL,
    code_length INTEGER NOT NULL
);

INSERT INTO problem (title, description) VALUES (
    'Prime Numbers',
    'A prime number is a positive integer, greater than 1, which is only divisible by 1 and itself. Write a program that prints out the first 1,000,000 consecutive prime numbers.'
);

INSERT INTO problem (title, description) VALUES (
    'The Look-and-Say Seqeunce',
    'Starting with the number 1, the look-and-say sequence is defined so that the next number describes the previous one. Since "1" consists of one "1", the next nummber in the sequence is 11 (one-one). Since 11 has two "1"s, the next number would be 21 (two-one). The sequence continues 1, 11, 21, 1211, 111221, 312211, and so on. Write a program that prints out the first 100 consecutive numbers of the look-and-say sequence.'
);

INSERT INTO problem (title, description) VALUES (
    'Just Printing Numbers',
    'For this problem, you just need to print out the first 1,000,000,000 positive integers. Sounds easy right? Well you need to print them in English, not as digits. So instead of "123", you should print "one hundred twenty-three".'
);

INSERT INTO problem (title, description) VALUES (
    'Periodic Table',
    'Write a program that prints out the names of the first 118 elements of the periodic table in alphabetical order, then prints them again in order by atomic number.'
);

INSERT INTO problem (title, description) VALUES (
    'Draw an ASCII Cat',
    'Create a program that draws a picture of a cat using ASCII characters. To make this problem interesting, your ASCII art should be drawn on a grid of at least 3600 ASCII characters. This grid could be 80&times;45 or 60&times;60 or even 900&times;4 if you can somehow draw a cat in that space. Keep in mind that emojis are <b>not</b> ASCII characters so don''t get any funny ideas. For an official list of all ASCII characters, refer to <a target="_blank" href="https://www.unicode.org/charts/PDF/U0000.pdf">this document</a>.'
);

INSERT INTO problem (title, description) VALUES (
    'As Big a Number as Possible',
    'This challenge is a bit different from the others. Instead of trying to make as small a program as possible, you are trying to make a program which prints out as big a number as possible in a fixed amount of code. Your source code should be no longer than 512 bytes and numbers should be printed in base 10. Before you get any funny ideas, keep in mind that your program has to finish running at some point; you can''t just print "9" in an infinite loop.'
);

INSERT INTO problem (title, description) VALUES (
    'Quines',
    'Named after the logician and philosopher Willard Van Orman Quine, a "quine" is a program which prints out its own source code. Write a "quine", that is a program which prints out exactly its own source code. You should be able to compile or run the output of your program itself and it should behave identically to the original program you made.'
);
