File size: 4,587 Bytes
b29f340
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import streamlit as st

def calculate_meat_amount(adults, children, max_eater_amount, your_amount):
    """
    מחשב את כמות הבשר הכוללת הנדרשת למנגל (בגרמים)
    """
    try:
        # Guard rails - check for valid input ranges
        if (adults > 50 or children > 50 or 
            max_eater_amount > 2000 or your_amount > 2000 or
            max_eater_amount < 200 or your_amount < 100):
            return "argentinian"
            
        CHILD_FACTOR = 0.4
        REGULAR_ADULT_FACTOR = 0.7
        WASTE_FACTOR = 1.1
        
        regular_adult_amount = max_eater_amount * REGULAR_ADULT_FACTOR
        
        total_meat = (
            your_amount +
            max_eater_amount +
            (regular_adult_amount * (adults - 1)) +
            (regular_adult_amount * CHILD_FACTOR * children)
        )
        
        # Guard rail - check for reasonable total
        if total_meat > 50000:  # More than 50kg
            return "argentinian"
            
        return int(total_meat * WASTE_FACTOR)
    except:
        return "argentinian"

# Set page config
st.set_page_config(
    page_title="מחשבון בשר למנגל",
    page_icon="🥩",
    layout="wide"
)

# Custom CSS for RTL support and styling
st.markdown("""
    <style>
        .stMarkdown, .stButton, .stTextInput, .stNumberInput {
            direction: rtl;
            text-align: right;
        }
        button[kind="primary"] {
            width: 100%;
        }
        .argentinian-response {
            font-size: 24px;
            text-align: center;
            padding: 20px;
            background-color: #f0f2f6;
            border-radius: 10px;
            margin: 20px 0;
        }
    </style>
""", unsafe_allow_html=True)

# Title
st.title("🥩 מחשבון בשר למנגל")
st.markdown("### חשב כמה בשר צריך להביא למנגל")

# Create two columns for input fields
col1, col2 = st.columns(2)

with col1:
    adults = st.number_input("מספר מבוגרים (לא כולל אותך)", 
                            min_value=1, 
                            value=5,
                            help="כמה מבוגרים יהיו במנגל (לא כולל אותך)")
    
    your_amount = st.number_input("כמה בשר (בגרם) אתה אוכל?",
                                 min_value=100,
                                 max_value=2000,
                                 value=600,
                                 step=50,
                                 help="הכמות שאתה בדרך כלל אוכל במנגל")

with col2:
    children = st.number_input("מספר ילדים",
                              min_value=0,
                              value=2,
                              help="כמה ילדים יהיו במנגל")
    
    max_eater_amount = st.number_input("כמה בשר (בגרם) אוכל האדם שאוכל הכי הרבה?",
                                      min_value=200,
                                      max_value=2000,
                                      value=800,
                                      step=50,
                                      help="כמות הבשר שאוכל האדם עם התיאבון הכי גדול")

if st.button("חשב כמות בשר"):
    result = calculate_meat_amount(adults, children, max_eater_amount, your_amount)
    
    st.markdown("---")
    
    if result == "argentinian":
        st.markdown("""
        <div class="argentinian-response">
            🥩 סמוך עלי, אני ארגנטינאי 🥩
        </div>
        """, unsafe_allow_html=True)
    else:
        st.markdown(f"### התוצאות:")
        # Display results
        st.markdown(f"""
        #### 🥩 סך כמות הבשר המומלצת: {result:,} גרם ({result/1000:.1f} ק\"ג)
        
        הכמות הזו מבוססת על:
        * {adults} מבוגרים (לא כולל אותך)
        * {children} ילדים
        * אדם שאוכל הכי הרבה: {max_eater_amount} גרם
        * הכמות שאתה אוכל: {your_amount} גרם
        
        ℹ️ הכמות כוללת תוספת של 10% למקרה של אובדן/שריפה/תוספות לא צפויות
        """)
    
# Footer
st.markdown("---")
st.markdown("### 📝 הערות:")
st.markdown("""
* הנוסחה מניחה שמבוגר ממוצע אוכל כ-70% מכמות הבשר של האדם שאוכל הכי הרבה
* ילדים נחשבים כאוכלים כ-40% מכמות הבשר של מבוגר ממוצע
""")