"""本主题专属离线算法，仅读取同目录合成JSON，不联网、不控制设备。"""
import csv, json, math, re, struct
from pathlib import Path
from fractions import Fraction
BASE=Path(__file__).resolve().parent
data=json.loads((BASE/'input.json').read_text(encoding='utf-8'))['data']
rows=[]
for v in data['options']:
 assert 0<=v<=255
 preview=bool(v&0x80);terminated=bool(v&0x40)
 rows.append({'options_hex':f'{v:02x}','preview':preview,'stream_terminated':terminated,'ordinary_live_data_candidate_in_this_classifier':not preview and not terminated})
assert [(r['preview'],r['stream_terminated']) for r in rows]==[(False,False),(True,False),(False,True),(True,True)]
result={'rows':rows,'actual_output_or_failsafe_tested':False}
(BASE/'result.json').write_text(json.dumps(result,ensure_ascii=False,indent=2)+'\n',encoding='utf-8')
print(json.dumps(result,ensure_ascii=False))
