中级
检测传感器读数卡死(Stuck Value)
未完成
中级参考
代码结构已给出,请填写 ____ 处
def solve():
from pyodide.http import open_url
from io import StringIO
import pandas as pd
st_csv = open_url(____).read()
st = pd.read_csv(StringIO(____))
stuck_thresholds = {r['____']:r['____'] for _,r in st.iterrows()}
readings = [
(____),(____),(____),
(____),(____),(____),
(____),(____),
(____),(____),(____),
]
def detect_stuck(____):
threshold = int(stuck_thresholds.get(____))
if len(____) < threshold: return False, ____
last_n = values[-threshold:]
return len(set(____)) == ____, threshold
by_device = {}
for did, metric, val in readings:
key = (____)
by_device.setdefault(____).append(____)
for (____), vals in by_device.items():
stuck, n = detect_stuck(____)
flag = "____" + str(____) + "____" if stuck else "____"
print(did + "____" + metric + "____" + flag + "____" + str(____))
示例
输入
solve()
期望输出
ARD-002/temperature: STUCK (consecutive=8) values=[25.0, 25.0, 25.0, 25.0, 25.0] ARD-001/temperature: ok values=[24.5, 24.7, 25.0]
👑
升级 VIP
解锁全部题目,畅通无阻地学习
- ✓ 解锁全部训练包所有题目
- ✓ 查看完整参考代码和提示
- ✓ 浏览器内直接运行 Python 代码
- ✓ 自动批改 + 进度追踪
30天
¥18
1年
¥99
2年
¥158
3年
¥199