中级
实现最少连接负载均衡
未完成
中级参考
代码结构已给出,请填写 ____ 处
def solve():
from pyodide.http import open_url
from io import StringIO
import pandas as pd
reg_csv = open_url(____).read()
reg = pd.read_csv(StringIO(____))
healthy = reg[(____)&(____)].copy()
def least_connections(____):
min_row = instances_df.loc[instances_df['____'].idxmin()]
return min_row['____'], int(____)
print(____)
current = healthy.copy()
for i in range(____):
inst, conns = least_connections(____)
print(____)
idx = current[current['____']==inst].index[____]
current.loc[idx,'____'] += ____
示例
输入
solve()
期望输出
最少连接负载均衡: 请求1: 选择 di-3(当前2连接) 请求2: 选择 di-3(当前3连接) 请求3: 选择 di-3(当前4连接) 请求4: 选择 di-3(当前5连接) 请求5: 选择 di-3(当前6连接)
👑
升级 VIP
解锁全部题目,畅通无阻地学习
- ✓ 解锁全部训练包所有题目
- ✓ 查看完整参考代码和提示
- ✓ 浏览器内直接运行 Python 代码
- ✓ 自动批改 + 进度追踪
30天
¥18
1年
¥99
2年
¥158
3年
¥199