Not everything done
This commit is contained in:
commit
2773df212e
16 changed files with 8761 additions and 0 deletions
97
aoc6.ipynb
Normal file
97
aoc6.ipynb
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "14be2365-970d-41a2-bc43-000c718aac46",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Part 1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 26,
|
||||
"id": "47f56d42-e07f-4fdc-a3a3-0cd97c09bde9",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"1238"
|
||||
]
|
||||
},
|
||||
"execution_count": 26,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"with open(\"aoc6_input.txt\", \"r\") as f:\n",
|
||||
" read_str_before_packet = f.read(3)\n",
|
||||
" while c := f.read(1):\n",
|
||||
" read_str_before_packet += c\n",
|
||||
" if len(set(read_str_before_packet[-4:])) == 4:\n",
|
||||
" break\n",
|
||||
"\n",
|
||||
"len(read_str_before_packet)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "10e8a318-7517-4212-b619-ad1406f144e3",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"#### Part 2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 27,
|
||||
"id": "139b3b21-76a0-49d7-9533-caf170e18cb0",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"3037"
|
||||
]
|
||||
},
|
||||
"execution_count": 27,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"with open(\"aoc6_input.txt\", \"r\") as f:\n",
|
||||
" read_str_before_marker = f.read(13)\n",
|
||||
" while c := f.read(1):\n",
|
||||
" read_str_before_marker += c\n",
|
||||
" if len(set(read_str_before_marker[-14:])) == 14:\n",
|
||||
" break\n",
|
||||
"\n",
|
||||
"len(read_str_before_marker)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"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.10.7"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue