# 离线只读验证：不访问网络、不操作设备，只读取同目录合成输入。
import json, math, struct, statistics
from pathlib import Path
def check(d):
 good=[d['good'][c] for c in d['cells']]
 assert sorted(good)==list(range(1,7))
 vals=list(d['bad'].values())
 dup=sorted({v for v in vals if vals.count(v)>1})
 return dict(permutation=good,duplicate_channels=dup,missing_cells=[c for c in d['cells'] if c not in d['bad']])

if __name__=='__main__':
 fixture=json.loads(Path(__file__).with_name('fixture.json').read_text(encoding='utf-8'))
 actual=check(fixture['input'])
 assert actual==fixture['expected'], {'实际':actual,'预期':fixture['expected']}
 print(json.dumps({'状态':'通过','实际':actual,'边界':'仅离线合成样例，现场未测'},ensure_ascii=False))
