yossi-iqt commited on
Commit
b29f340
·
1 Parent(s): 005f20d

initial commit

Browse files
Files changed (1) hide show
  1. bbq-calculator-app.py +128 -0
bbq-calculator-app.py ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ def calculate_meat_amount(adults, children, max_eater_amount, your_amount):
4
+ """
5
+ מחשב את כמות הבשר הכוללת הנדרשת למנגל (בגרמים)
6
+ """
7
+ try:
8
+ # Guard rails - check for valid input ranges
9
+ if (adults > 50 or children > 50 or
10
+ max_eater_amount > 2000 or your_amount > 2000 or
11
+ max_eater_amount < 200 or your_amount < 100):
12
+ return "argentinian"
13
+
14
+ CHILD_FACTOR = 0.4
15
+ REGULAR_ADULT_FACTOR = 0.7
16
+ WASTE_FACTOR = 1.1
17
+
18
+ regular_adult_amount = max_eater_amount * REGULAR_ADULT_FACTOR
19
+
20
+ total_meat = (
21
+ your_amount +
22
+ max_eater_amount +
23
+ (regular_adult_amount * (adults - 1)) +
24
+ (regular_adult_amount * CHILD_FACTOR * children)
25
+ )
26
+
27
+ # Guard rail - check for reasonable total
28
+ if total_meat > 50000: # More than 50kg
29
+ return "argentinian"
30
+
31
+ return int(total_meat * WASTE_FACTOR)
32
+ except:
33
+ return "argentinian"
34
+
35
+ # Set page config
36
+ st.set_page_config(
37
+ page_title="מחשבון בשר למנגל",
38
+ page_icon="🥩",
39
+ layout="wide"
40
+ )
41
+
42
+ # Custom CSS for RTL support and styling
43
+ st.markdown("""
44
+ <style>
45
+ .stMarkdown, .stButton, .stTextInput, .stNumberInput {
46
+ direction: rtl;
47
+ text-align: right;
48
+ }
49
+ button[kind="primary"] {
50
+ width: 100%;
51
+ }
52
+ .argentinian-response {
53
+ font-size: 24px;
54
+ text-align: center;
55
+ padding: 20px;
56
+ background-color: #f0f2f6;
57
+ border-radius: 10px;
58
+ margin: 20px 0;
59
+ }
60
+ </style>
61
+ """, unsafe_allow_html=True)
62
+
63
+ # Title
64
+ st.title("🥩 מחשבון בשר למנגל")
65
+ st.markdown("### חשב כמה בשר צריך להביא למנגל")
66
+
67
+ # Create two columns for input fields
68
+ col1, col2 = st.columns(2)
69
+
70
+ with col1:
71
+ adults = st.number_input("מספר מבוגרים (לא כולל אותך)",
72
+ min_value=1,
73
+ value=5,
74
+ help="כמה מבוגרים יהיו במנגל (לא כולל אותך)")
75
+
76
+ your_amount = st.number_input("כמה בשר (בגרם) אתה אוכל?",
77
+ min_value=100,
78
+ max_value=2000,
79
+ value=600,
80
+ step=50,
81
+ help="הכמות שאתה בדרך כלל אוכל במנגל")
82
+
83
+ with col2:
84
+ children = st.number_input("מספר ילדים",
85
+ min_value=0,
86
+ value=2,
87
+ help="כמה ילדים יהיו במנגל")
88
+
89
+ max_eater_amount = st.number_input("כמה בשר (בגרם) אוכל האדם שאוכל הכי הרבה?",
90
+ min_value=200,
91
+ max_value=2000,
92
+ value=800,
93
+ step=50,
94
+ help="כמות הבשר שאוכל האדם עם התיאבון הכי גדול")
95
+
96
+ if st.button("חשב כמות בשר"):
97
+ result = calculate_meat_amount(adults, children, max_eater_amount, your_amount)
98
+
99
+ st.markdown("---")
100
+
101
+ if result == "argentinian":
102
+ st.markdown("""
103
+ <div class="argentinian-response">
104
+ 🥩 סמוך עלי, אני ארגנטינאי 🥩
105
+ </div>
106
+ """, unsafe_allow_html=True)
107
+ else:
108
+ st.markdown(f"### התוצאות:")
109
+ # Display results
110
+ st.markdown(f"""
111
+ #### 🥩 סך כמות הבשר המומלצת: {result:,} גרם ({result/1000:.1f} ק\"ג)
112
+
113
+ הכמות הזו מבוססת על:
114
+ * {adults} מבוגרים (לא כולל אותך)
115
+ * {children} ילדים
116
+ * אדם שאוכל הכי הרבה: {max_eater_amount} גרם
117
+ * הכמות שאתה אוכל: {your_amount} גרם
118
+
119
+ ℹ️ הכמות כוללת תוספת של 10% למקרה של אובדן/שריפה/תוספות לא צפויות
120
+ """)
121
+
122
+ # Footer
123
+ st.markdown("---")
124
+ st.markdown("### 📝 הערות:")
125
+ st.markdown("""
126
+ * הנוסחה מניחה שמבוגר ממוצע אוכל כ-70% מכמות הבשר של האדם שאוכל הכי הרבה
127
+ * ילדים נחשבים כאוכלים כ-40% מכמות הבשר של מבוגר ממוצע
128
+ """)