基于 SOC 职业分类
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/cxcscmu/SkillLearnBench --skill calendar-scheduling-logic命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
Handles reading, populating, and saving .docx files using the python-docx library. Use this skill for any tasks involving template filling or modifying Word documents.
Perform various data analysis on SEC 13-F and obtain some insights of fund activities such as number of holdings, AUM, and change of holdings between two quarters.
This skill includes search capability in 13F, such as fuzzy search a fund information using possibly inaccurate name, or fuzzy search a stock cusip info using its name.
| name | calendar-scheduling-logic |
| description | Find available time slots in a calendar and schedule meetings while respecting constraints |
This skill covers scheduling algorithms to find available time slots in a calendar, handle time conflicts, prioritize blue-colored flexible blocks, and match meeting requests with available time windows.
# Event representation
event = {
'name': 'Weekly Group Meeting',
'start_hour': 10,
'start_minute': 0,
'end_hour': 11,
'end_minute': 0,
'color': 'red', # 'red', 'blue', 'yellow', 'gray'
'is_flexible': True/False # Only blue is True
}
# 15-minute interval representation
# 9:00am = index 0, 9:15am = index 1, etc.
def time_to_minutes(hour, minute):
"""Convert hour:minute to total minutes since midnight"""
return hour * 60 + minute
def minutes_to_time(minutes):
"""Convert total minutes to (hour, minute) tuple"""
hour = minutes // 60
minute = minutes % 60
return (hour, minute)
def time_range_to_intervals(start_hour, start_min, end_hour, end_min, interval_minutes=15):
"""Convert a time range to 15-minute interval indices"""
start_total_min = time_to_minutes(start_hour, start_min)
end_total_min = time_to_minutes(end_hour, end_min)
intervals = []
current = start_total_min
while current < end_total_min:
intervals.append(current // interval_minutes)
current += interval_minutes
return intervals
def mark_busy_intervals(calendar_events, day_start_hour=0, day_end_hour=24):
"""Mark all busy intervals in a day"""
total_intervals = (day_end_hour - day_start_hour) * 60 // 15
busy = [False] * total_intervals
for event in calendar_events:
intervals = time_range_to_intervals(
event['start_hour'], event['start_minute'],
event['end_hour'], event['end_minute']
)
for i in intervals:
if 0 <= i < total_intervals:
busy[i] = True
return busy
def find_available_slots(busy_array, duration_intervals):
"""Find all available slots of at least duration_intervals length"""
available_slots = []
consecutive = 0
start_idx = None
for i, is_busy in enumerate(busy_array):
if not is_busy:
if consecutive == 0:
start_idx = i
consecutive += 1
if consecutive >= duration_intervals:
available_slots.append((start_idx, i + 1))
else:
consecutive = 0
return available_slots
def filter_by_availability_window(available_slots, user_start, user_end, interval_minutes=15):
"""Filter slots to only those within user's available window"""
user_start_intervals = time_to_minutes(user_start[0], user_start[1]) // interval_minutes
user_end_intervals = time_to_minutes(user_end[0], user_end[1]) // interval_minutes
filtered = []
for start_idx, end_idx in available_slots:
# Check if slot overlaps with user's availability
if end_idx > user_start_intervals and start_idx < user_end_intervals:
# Constrain to user's window
constrained_start = max(start_idx, user_start_intervals)
constrained_end = min(end_idx, user_end_intervals)
filtered.append((constrained_start, constrained_end))
return filtered
def select_earliest_slot(available_slots, duration_intervals):
"""Select the earliest slot that can fit the duration"""
for start_idx, end_idx in available_slots:
slot_duration = end_idx - start_idx
if slot_duration >= duration_intervals:
return (start_idx, start_idx + duration_intervals)
return None
def create_busy_with_overrides(calendar_events, allow_blue_override=True):
"""Mark busy intervals, but allow blue blocks to be overridden"""
total_intervals = 24 * 60 // 15
busy = [False] * total_intervals
blue_blocks = []
for event in calendar_events:
intervals = time_range_to_intervals(
event['start_hour'], event['start_minute'],
event['end_hour'], event['end_minute']
)
if event.get('color') == 'blue' and allow_blue_override:
blue_blocks.append((intervals[0], intervals[-1]))
else:
for i in intervals:
if 0 <= i < total_intervals:
busy[i] = True
return busy, blue_blocks
def schedule_meeting(calendar_events, request):
"""
Schedule a meeting respecting all constraints
request = {
'duration_hours': 1.0,
'available_times': {'start': (10, 0), 'end': (14, 0), 'timezone': None},
'timezone': 'US/Eastern'
}
"""
duration_minutes = request['duration_hours'] * 60
duration_intervals = duration_minutes // 15
# Get busy times and blue overridable blocks
busy, blue_blocks = create_busy_with_overrides(calendar_events)
# Find all available slots
available_slots = find_available_slots(busy, duration_intervals)
# Filter by user's availability window
if request['available_times']:
available_slots = filter_by_availability_window(
available_slots,
request['available_times']['start'],
request['available_times']['end']
)
# Select earliest slot
selected = select_earliest_slot(available_slots, duration_intervals)
if selected:
start_intervals, end_intervals = selected
start_hour, start_min = minutes_to_time(start_intervals * 15)
end_hour, end_min = minutes_to_time(end_intervals * 15)
return {
'start': (start_hour, start_min),
'end': (end_hour, end_min),
'success': True
}
return {'success': False, 'reason': 'No available slots'}
def schedule_multiple_meetings(calendar_events, requests, priority_fn=None):
"""
Schedule multiple meetings, resolving conflicts with priority function
priority_fn: function that returns numeric priority (higher = more important)
"""
# Sort by priority
if priority_fn:
requests = sorted(requests, key=priority_fn, reverse=True)
else:
# Default: earlier constraint window = higher priority
requests = sorted(
requests,
key=lambda r: time_to_minutes(r['available_times']['end'][0], r['available_times']['end'][1])
)
scheduled = []
working_events = calendar_events.copy()
for request in requests:
slot = schedule_meeting(working_events, request)
if slot['success']:
# Add booked meeting to calendar
working_events.append({
'name': f"Meeting: {request['sender']}",
'start_hour': slot['start'][0],
'start_minute': slot['start'][1],
'end_hour': slot['end'][0],
'end_minute': slot['end'][1],
'color': 'booked'
})
scheduled.append({: request, : slot})
scheduled