This repository has been archived on 2024-06-23. You can view files and clone it, but cannot push or open issues or pull requests.
mathdeptv2/工具/寻找阶段末尾空闲题号.ipynb

75 lines
1.8 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"首个空闲id: 14784 , 直至 020000\n",
"首个空闲id: 22106 , 直至 030000\n",
"首个空闲id: 31382 , 直至 040000\n",
"首个空闲id: 40387 , 直至 999999\n"
]
}
],
"source": [
"import os,re,json\n",
"with open(r\"..\\题库0.3\\Problems.json\",\"r\",encoding = \"utf8\") as f:\n",
" database = f.read()\n",
"idlist = list(json.loads(database).keys())\n",
"freeidlist = {}\n",
"for id in idlist:\n",
" if not str(int(id)+1).zfill(6) in idlist:\n",
" freeidlist[id] = \"\"\n",
"for id in freeidlist:\n",
" largeridlist = [usedid for usedid in idlist if usedid > id]\n",
" if not largeridlist == []:\n",
" freeidlist[id] = str(int(min(largeridlist))-1).zfill(6)\n",
" else:\n",
" freeidlist[id] = \"999999\"\n",
"for id in freeidlist:\n",
" print(\"首个空闲id:\",str(int(id)+1),\", 直至\",freeidlist[id])\n",
" \n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "pythontest",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.15"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "91219a98e0e9be72efb992f647fe78b593124968b75db0b865552d6787c8db93"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}