Skip to content

Commit

Permalink
Merge pull request #3 from B-AROL-O/alv67
Browse files Browse the repository at this point in the history
add days 1-4
  • Loading branch information
gmacario authored Dec 4, 2024
2 parents e256f04 + 1376a7b commit 29aa5e3
Show file tree
Hide file tree
Showing 8 changed files with 7,005 additions and 0 deletions.
89 changes: 89 additions & 0 deletions solutions/alv67/Day01/day01.ipynb
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
}
Loading

0 comments on commit 29aa5e3

Please sign in to comment.