File size: 2,160 Bytes
0f06ae9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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 show_torch_code:
    #     st.code(inspect.getsource(day_1_torch))
    #     day_1_torch(day_input)

if day == 3 and (day_input is not None and day_input != ""):
    # if show_code:
    #     st.code(inspect.getsource(streamlit_3))
    #     streamlit_2(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 show_torch_code:
    #     st.code(inspect.getsource(streamlit_torch_3))
    #     streamlit_torch_3(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)
    # if show_torch_code:
    #     st.code(inspect.getsource(streamlit_torch_3))
    #     streamlit_torch_3(day_input)