FinishedDayFive
This commit is contained in:
@ -214,19 +214,20 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"execution_count": 105,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"ename": "SyntaxError",
|
||||
"evalue": "invalid syntax (3599436891.py, line 64)",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[1;36m Cell \u001b[1;32mIn[9], line 64\u001b[1;36m\u001b[0m\n\u001b[1;33m if a.map[round][]\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"79004094\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"#It is NOT an optimised solution, but it gets the job done!\n",
|
||||
"\n",
|
||||
"seedlist = []\n",
|
||||
"almanac = []\n",
|
||||
"\n",
|
||||
@ -268,6 +269,23 @@
|
||||
" return obj.map[index][0] + space\n",
|
||||
" \n",
|
||||
"\n",
|
||||
"def findseed(num):\n",
|
||||
" for i in range(len(almanac)-1, -1, -1):\n",
|
||||
" for j in range(len(almanac[i].map)):\n",
|
||||
" if num < almanac[i].map[0][0]:\n",
|
||||
" break\n",
|
||||
" if almanac[i].map[j][0] <= num and almanac[i].map[j][0] + almanac[i].map[j][2] > num:\n",
|
||||
" num = almanac[i].map[j][1] + (num - almanac[i].map[j][0])\n",
|
||||
" break\n",
|
||||
"\n",
|
||||
" for i in seedranges:\n",
|
||||
" if i[0] <= num and i[0] + i[1] > num:\n",
|
||||
" return True\n",
|
||||
" else:\n",
|
||||
" return False\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"with open(\"almanac.txt\", 'r') as reader:\n",
|
||||
" seedlist = reader.readline()\n",
|
||||
" maper = []\n",
|
||||
@ -286,16 +304,29 @@
|
||||
"seedlist = [eval(i) for i in seedlist.replace(\"seeds:\", '').split()]\n",
|
||||
"seedranges = [[seedlist[i], seedlist[i+1]] for i in range(0, len(seedlist), 2)]\n",
|
||||
"\n",
|
||||
"while True:\n",
|
||||
" round = 0\n",
|
||||
" value = 0\n",
|
||||
" for a in range(almanac[len(almanac)]):\n",
|
||||
" pass\n",
|
||||
" \n",
|
||||
" \n",
|
||||
" \n",
|
||||
"round = 0\n",
|
||||
"value = 0\n",
|
||||
"index = 0\n",
|
||||
"value = 0\n",
|
||||
"\n",
|
||||
"print(seedranges)\n"
|
||||
"with open(\"Elements.txt\", 'a') as writer:\n",
|
||||
" while True:\n",
|
||||
" if value % 500000 == 0:\n",
|
||||
" writer.write(str(value) + \"\\n\")\n",
|
||||
" if value > almanac[len(almanac)-1].map[index][0] + almanac[len(almanac)-1].map[index][2] and index < len(almanac[len(almanac)-1].map)-1:\n",
|
||||
" index += 1\n",
|
||||
" if findseed(value):\n",
|
||||
" break\n",
|
||||
" value += 1 \n",
|
||||
"\n",
|
||||
"print(value)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"79004094 ~22 min"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
Reference in New Issue
Block a user