generated from arol-polito/python-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from B-AROL-O/alv67
add days 1-4
- Loading branch information
Showing
8 changed files
with
7,005 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# -- DAY 1 --\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"The solution of Puzzle 1 is: 2756096\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"# --- Part One ---\n", | ||
"c1 = []\n", | ||
"c2 = []\n", | ||
"with open(\"input.txt\",\"r\") as file:\n", | ||
" for line in file:\n", | ||
" a , b = line.split()\n", | ||
" c1.append(int(a))\n", | ||
" c2.append(int(b))\n", | ||
"c1.sort()\n", | ||
"c2.sort()\n", | ||
"l = [abs(a - b) for a,b in zip(c1, c2)]\n", | ||
"\n", | ||
"print (f\"The solution of Puzzle 1 is: {sum(l)}\")\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 16, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"The solution of Puzzle 2 is: 23117829\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"# --- Part Two ---\n", | ||
"c1 = []\n", | ||
"c2 = []\n", | ||
"with open(\"input.txt\",\"r\") as file:\n", | ||
" for line in file:\n", | ||
" a , b = line.split()\n", | ||
" c1.append(int(a))\n", | ||
" c2.append(int(b))\n", | ||
"\n", | ||
"l = [a * c2.count(a) for a in c1]\n", | ||
"\n", | ||
"print (f\"The solution of Puzzle 2 is: {sum(l)}\")\n" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"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.12.1" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Oops, something went wrong.