File size: 2,219 Bytes
e2a7b28
 
081bb82
7d59763
3739ad0
 
 
 
 
081bb82
3739ad0
 
 
 
 
 
 
 
 
 
 
081bb82
3739ad0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
081bb82
3739ad0
 
 
 
081bb82
 
 
 
3739ad0
e2a7b28
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
import streamlit as st

# Prompt the user to input a value rather than using a slider
x = st.text_input("Enter a value, and I will guess your age!")

def estimate_age_from_input(x):
    try:
        # Convert to float and get absolute value
        x = abs(float(x))

        # Base probability of different age groups (skewed young due to internet usage)
        # Roughly based on internet usage demographics
        age_brackets = {
            (13, 17): 0.15,  # Teens
            (18, 24): 0.25,  # Young adults
            (25, 34): 0.30,  # Early career
            (35, 44): 0.15,  # Mid career
            (45, 54): 0.08,  # Late career
            (55, 64): 0.05,  # Pre-retirement
            (65, 100): 0.02  # Retirement
        }

        # Adjust probabilities based on input value
        if x > 1000000 or x < -1000000:
            # Very large/small numbers - likely young person testing limits
            return 18
        elif x > 10000 or x < -10000:
            # Large numbers - probably young
            return 22
        elif x == 69 or x == 420 or x == 80085:
            # Meme numbers - likely teen/young adult
            return 16
        elif x == 0:
            # Default/lazy input - use median young adult age
            return 25
        elif x == 1:
            # Simple input - slight skew older
            return 28
        elif 1 <= x <= 100:
            # Reasonable number - use weighted distribution
            if x <= 20:
                return 24  # Young skew for small numbers
            else:
                return min(int(x * 0.8 + 15), 75)  # Scale up but cap at 75
        else:
            # Other numbers - use base distribution
            import random
            brackets = list(age_brackets.items())
            weights = [p for _, p in brackets]
            chosen = random.choices(brackets, weights=weights)[0][0]
            return random.randint(chosen[0], chosen[1])

    except (ValueError, TypeError):
        # Non-numeric input - assume young user testing system
        return 19

# Only attempt to calculate if input is provided
if x:
    y = estimate_age_from_input(x)
    st.write(f'You entered: {x}, I think you are about {y} years old!')