|
import streamlit as st |
|
import os |
|
import importlib |
|
import inspect |
|
import numpy as np |
|
import torch |
|
from PIL import Image |
|
from aoc.year_2021.code.day_1 import streamlit_1, streamlit_torch_1 |
|
from aoc.year_2021.code.day_2 import streamlit_2 |
|
from aoc.year_2021.code.day_3 import streamlit_torch_3 |
|
from aoc.year_2021.code.day_4 import streamlit_4 |
|
from aoc.year_2021.code.day_5 import streamlit_5 |
|
|
|
|
|
st.sidebar.markdown("**AoC 2021 app** by Yassine Alouini") |
|
logo = Image.open('logo.png') |
|
st.sidebar.image(logo, width=64) |
|
|
|
day = st.sidebar.selectbox("Select the day: ", [1, 2, 3, 4, 5]) |
|
day_input = st.sidebar.text_area("Paste your input here: ", "") |
|
show_code = st.sidebar.radio("Show code? ", [True, False]) |
|
show_torch_code = st.sidebar.radio("Show PyTorch code? ", [True, False]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
if day == 1 and (day_input is not None and day_input != ""): |
|
if show_code: |
|
st.code(inspect.getsource(streamlit_1)) |
|
streamlit_1(day_input) |
|
if show_torch_code: |
|
st.code(inspect.getsource(streamlit_torch_1)) |
|
streamlit_torch_1(day_input) |
|
|
|
if day == 2 and (day_input is not None and day_input != ""): |
|
if show_code: |
|
st.code(inspect.getsource(streamlit_2)) |
|
streamlit_2(day_input) |
|
|
|
|
|
|
|
|
|
if day == 3 and (day_input is not None and day_input != ""): |
|
|
|
|
|
|
|
if show_torch_code: |
|
st.code(inspect.getsource(streamlit_torch_3)) |
|
streamlit_torch_3(day_input) |
|
|
|
if day == 4 and (day_input is not None and day_input != ""): |
|
if show_code: |
|
st.code(inspect.getsource(streamlit_4)) |
|
streamlit_4(day_input) |
|
|
|
|
|
|
|
|
|
if day == 5 and (day_input is not None and day_input != ""): |
|
if show_code: |
|
st.code(inspect.getsource(streamlit_5)) |
|
streamlit_5(day_input) |
|
|
|
|
|
|