Skip to content

Instantly share code, notes, and snippets.

View koorukuroo's full-sized avatar
🎯
Focusing

Kyunghoon Kim koorukuroo

🎯
Focusing
View GitHub Profile
import random
import pandas as pd
import plotly.graph_objects as go
def monty_hall_5doors_scenario():
"""Generate a single scenario (car location, player choice, etc.) for 5-door Monty Hall."""
doors = [0,1,2,3,4]
prize_door = random.randint(0, 4)
initial_choice = random.randint(0, 4)
import random
import pandas as pd
import plotly.graph_objects as go
def monty_hall_5doors(trials=1000, switch=True):
"""
Runs the Monty Hall game with 5 doors for multiple trials.
Returns a DataFrame with columns: [initial_choice, prize_door, result].
"""
data = []
import random
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import pandas as pd
# Monty Hall simulation function
def monty_hall_simulation(trials=1000, switch=True):
results = []
for _ in range(trials):
import random
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
# Monty Hall simulation function
def monty_hall(switch=True):
prize_door = random.randint(0, 2) # Randomly assign the prize behind one of the three doors
chosen_door = random.randint(0, 2) # Player's initial choice of door
doors = [0, 1, 2]
import numpy as np
import time
def monty_hall_numpy(trials=100000000, switch=True):
"""
Fully vectorized Monty Hall simulation using NumPy for maximum performance.
Parameters:
trials (int): Number of games to simulate.
switch (bool): If True, the player switches doors; otherwise, they stay.
import random
# Define the Monty Hall function
def monty_hall(switch=True):
"""
Simulates one round of the Monty Hall game.
Parameters:
switch (bool): If True, the player switches their choice after the host opens a door.
from moviepy.editor import VideoClip, TextClip
from tqdm import tqdm
def make_frame(t):
# Calculate remaining time in minutes and seconds
remaining_time = max(0, int(5*60 - t))
minutes, seconds = divmod(remaining_time, 60)
time_str = f"{minutes:01d}:{seconds:02d}"
# Create TextClip for the countdown with 4K resolution
import openai
openai.api_key = 'sk-API 키를 입력하세요'
def lambda_handler(event, context):
if 'm' in event['params']['querystring']:
input_message = event['params']['querystring']['m']
else:
input_message = "나는 신한투자증권에 입사하려는 개발자야. 클라우드를 공부해야 할 필요가 있을까?"
import openai
openai.api_key = 'sk-API키를 입력합니다'
def lambda_handler(event, context):
message = openai.ChatCompletion.create(
model="gpt-4o-mini", # 사용 모델
messages=[
from fastapi import FastAPI
import redis
app = FastAPI()
redis_client = redis.Redis(host='localhost', port=6379, db=0)
@app.get("/items/{id}")
def read_item(id: str):
value = redis_client.get(id)
if value: