DayFour
This commit is contained in:
@ -170,7 +170,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 92,
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@ -194,7 +194,6 @@
|
||||
"\n",
|
||||
"def neighbourlocator(line, index):\n",
|
||||
" neighbours = []\n",
|
||||
" #print(collection[line])\n",
|
||||
" if index > 0:\n",
|
||||
" numberbefore = index\n",
|
||||
" while numberbefore >= 0:\n",
|
||||
@ -203,11 +202,10 @@
|
||||
" else:\n",
|
||||
" break\n",
|
||||
" if index > numberbefore:\n",
|
||||
" #print(\"FRONT:\",collection[line][numberbefore : index])\n",
|
||||
" neighbours.append(int(collection[line][numberbefore : index]))\n",
|
||||
"\n",
|
||||
"\n",
|
||||
" if index + endindex < len(collection[line]):\n",
|
||||
" if index < len(collection[line]):\n",
|
||||
" numberafter = index\n",
|
||||
" while numberafter < len(collection[line]):\n",
|
||||
" if collection[line][numberafter+1].isnumeric():\n",
|
||||
@ -215,7 +213,6 @@
|
||||
" else:\n",
|
||||
" break\n",
|
||||
" if index < numberafter:\n",
|
||||
" #print(\"BACK:\", collection[line][index + 1 : numberafter+1], f\"index: {index}, and numberafter: {numberafter}\")\n",
|
||||
" neighbours.append(int(collection[line][index + 1 : numberafter+1]))\n",
|
||||
"\n",
|
||||
" if line > 0:\n",
|
||||
@ -258,10 +255,6 @@
|
||||
" numberswithneighbours.append(neighbours[0]*neighbours[1])\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"rl = loader('enginenumbers.txt')\n",
|
||||
"\n",
|
||||
"while True:\n",
|
||||
@ -275,7 +268,6 @@
|
||||
" if '*' == collection[i][e]:\n",
|
||||
" neighbourlocator(i, e)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"suma = sum(numberswithneighbours)\n",
|
||||
"print(suma)\n",
|
||||
" \n",
|
||||
|
Reference in New Issue
Block a user