Add Solution for 12 Part 2

This commit is contained in:
Tabledevil committed 2024-12-12 20:42:02 +01:00
1 parent 118e11df8c
commit 7d8cbc6f01
1 file changed
+50 -811
+50 -811
View File
@@ -2,64 +2,78 @@
"cells": [ "cells": [
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 126, "execution_count": 1,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"with open('testinput','r') as infile:\n", "with open('input','r') as infile:\n",
" data=[list(line.strip()) for line in infile.readlines()]" " data=[list(line.strip()) for line in infile.readlines()]"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 127, "execution_count": 2,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"import numpy as np\n", "import numpy as np\n",
"from scipy.ndimage import label\n", "from scipy.ndimage import label\n",
"\n", "\n",
"directions = [\n",
" (1, -1, 0), #up\n",
" (2, 1, 0), #down\n",
" (4, 0, -1), #left\n",
" (8, 0, 1), #right\n",
"]\n",
"\n",
"\n",
"def find_clusters_matrix(grid):\n", "def find_clusters_matrix(grid):\n",
" grid = np.array(grid)\n", " grid = np.array(grid) # Convert to numpy array if not already\n",
" unique_types = np.unique(grid)\n", " unique_types = np.unique(grid) # Get unique characters/types in the grid\n",
" clusters = []\n", " clusters = [] # List to store clusters\n",
" \n",
" for char in unique_types: # Iterate over each unique character/type\n",
"\n", "\n",
" for char in unique_types:\n",
" # Binary mask for current character\n", " # Binary mask for current character\n",
" binary_map = (grid == char)\n", " binary_map = (grid == char)\n",
" \n", " \n",
" # Label connected components\n", " # Identify islands (clusters) of the current character\n",
" labeled_map, num_features = label(binary_map)\n", " labeled_map, num_features = label(binary_map)\n",
" \n", " \n",
" # Iterate over each cluster found for the current character\n",
" for cluster_id in range(1, num_features + 1):\n", " for cluster_id in range(1, num_features + 1):\n",
" # Cluster size\n", " cluster_mask = (labeled_map == cluster_id) # Mask for current cluster\n",
" cluster_mask = (labeled_map == cluster_id)\n", " size = cluster_mask.sum() # Size of the cluster\n",
" size = cluster_mask.sum()\n", " bordermaps = np.zeros(grid.shape,dtype=int) # Initialize map to store border information\n",
"\n", "\n",
" # Border length\n", " for x, y in zip(*np.where(cluster_mask)): # Iterate over each pixel in the cluster\n",
" border_length = 0\n", " for direction, dx, dy in directions: # Iterate over each direction (1-up, 2-down, 4-left, 8-right)\n",
" for x, y in zip(*np.where(cluster_mask)):\n",
" for dx, dy in [(-1, 0), (1, 0), (0, -1), (0, 1)]:\n",
" nx, ny = x + dx, y + dy\n", " nx, ny = x + dx, y + dy\n",
" # Check if the pixel is on the border of the cluster \n",
" if nx < 0 or nx >= grid.shape[0] or ny < 0 or ny >= grid.shape[1] or grid[nx, ny] != char:\n", " if nx < 0 or nx >= grid.shape[0] or ny < 0 or ny >= grid.shape[1] or grid[nx, ny] != char:\n",
" border_length += 1\n", " bordermaps[x][y] |= direction # Mark the direction as a border using bitwise OR and the \n",
" \n", " border_length = 0\n",
" clusters.append({\"type\": char, \"size\": size, \"border_length\": border_length})\n", " border_sides = 0\n",
" \n", " for direction,dx,dy in directions: # Iterate over each direction (1-up, 2-down, 4-left, 8-right)\n",
" map = ((bordermaps & direction) != 0) # Convert the direction map to a binary array for each direction\n",
" border_length += np.sum(map) # Legacy code to calculate the total length of the border for Part 1\n",
" _, sides = label(map) # Label the connected straight segments of the border \n",
" border_sides += sides # Count the number of straight connected pieces of the border\n",
" clusters.append({\"type\": char, \"size\": size, \"border_length\": border_length, \"border_sides\":border_sides})\n",
" return clusters\n", " return clusters\n",
"\n" "\n"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 128, "execution_count": 3,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"[{'type': 'C', 'size': 14, 'border_length': 28}, {'type': 'C', 'size': 1, 'border_length': 4}, {'type': 'E', 'size': 13, 'border_length': 18}, {'type': 'F', 'size': 10, 'border_length': 18}, {'type': 'I', 'size': 4, 'border_length': 8}, {'type': 'I', 'size': 14, 'border_length': 22}, {'type': 'J', 'size': 11, 'border_length': 20}, {'type': 'M', 'size': 5, 'border_length': 12}, {'type': 'R', 'size': 12, 'border_length': 18}, {'type': 'S', 'size': 3, 'border_length': 8}, {'type': 'V', 'size': 13, 'border_length': 20}]\n" "[{'type': np.str_('A'), 'size': np.int64(40), 'border_length': np.int64(36), 'border_sides': 26}, {'type': np.str_('A'), 'size': np.int64(1), 'border_length': np.int64(4), 'border_sides': 4}, {'type': np.str_('A'), 'size': np.int64(59), 'border_length': np.int64(48), 'border_sides': 30}, {'type': np.str_('A'), 'size': np.int64(58), 'border_length': np.int64(56), 'border_sides': 32}, {'type': np.str_('A'), 'size': np.int64(4), 'border_length': np.int64(10), 'border_sides': 8}, {'type': np.str_('A'), 'size': np.int64(1), 'border_length': np.int64(4), 'border_sides': 4}, {'type': np.str_('A'), 'size': np.int64(1), 'border_length': np.int64(4), 'border_sides': 4}, {'type': np.str_('A'), 'size': np.int64(3), 'border_length': np.int64(8), 'border_sides': 6}, {'type': np.str_('A'), 'size': np.int64(8), 'border_length': np.int64(12), 'border_sides': 6}, {'type': np.str_('A'), 'size': np.int64(1), 'border_length': np.int64(4), 'border_sides': 4}, {'type': np.str_('A'), 'size': np.int64(100), 'border_length': np.int64(60), 'border_sides': 34}, {'type': np.str_('A'), 'size': np.int64(136), 'border_length': np.int64(82), 'border_sides': 50}, {'type': np.str_('A'), 'size': np.int64(10), 'border_length': np.int64(20), 'border_sides': 14}, {'type': np.str_('A'), 'size': np.int64(2), 'border_length': np.int64(6), 'border_sides': 4}, {'type': np.str_('A'), 'size': np.int64(155), 'border_length': np.int64(146), 'border_sides': 100}, {'type': np.str_('A'), 'size': np.int64(85), 'border_length': np.int64(74), 'border_sides': 48}, {'type': np.str_('A'), 'size': np.int64(3), 'border_length': np.int64(8), 'border_sides': 4}, {'type': np.str_('A'), 'size': np.int64(1), 'border_length': np.int64(4), 'border_sides': 4}, {'type': np.str_('A'), 'size': np.int64(35), 'border_length': np.int64(32), 'border_sides': 20}, {'type': np.str_('B'), 'size': np.int64(68), 'border_length': np.int64(60), 'border_sides': 38}, {'type': np.str_('B'), 'size': np.int64(91), 'border_length': np.int64(76), 'border_sides': 44}, {'type': np.str_('B'), 'size': np.int64(104), 'border_length': np.int64(80), 'border_sides': 50}, {'type': np.str_('B'), 'size': np.int64(1), 'border_length': np.int64(4), 'border_sides': 4}, {'type': np.str_('B'), 'size': np.int64(2), 'border_length': np.int64(6), 'border_sides': 4}, {'type': np.str_('B'), 'size': np.int64(1), 'border_length': np.int64(4), 'border_sides': 4}, {'type': np.str_('B'), 'size': np.int64(56), 'border_length': np.int64(42), 'border_sides': 26}, {'type': np.str_('B'), 'size': np.int64(4), 'border_length': np.int64(10), 'border_sides': 8}, {'type': np.str_('B'), 'size': np.int64(1), 'border_length': np.int64(4), 'border_sides': 4}, {'type': np.str_('B'), 'size': np.int64(3), 'border_length': np.int64(8), 'border_sides': 6}, {'type': np.str_('B'), 'size': np.int64(137), 'border_length': np.int64(88), 'border_sides': 56}, {'type': np.str_('B'), 'size': np.int64(1), 'border_length': np.int64(4), 'border_sides': 4}, {'type': np.str_('B'), 'size': np.int64(1), 'border_length': np.int64(4), 'border_sides': 4}, {'type': np.str_('B'), 'size': np.int64(1), 'border_length': np.int64(4), 'border_sides': 4}, {'type': np.str_('B'), 'size': np.int64(11), 'border_length': np.int64(14), 'border_sides': 6}, {'type': np.str_('B'), 'size': np.int64(4), 'border_length': np.int64(8), 'border_sides': 4}, {'type': np.str_('B'), 'size': np.int64(2), 'border_length': np.int64(6), 'border_sides': 4}, {'type': np.str_('B'), 'size': np.int64(53), 'border_length': np.int64(38), 'border_sides': 12}, {'type': np.str_('B'), 'size': np.int64(93), 'border_length': np.int64(82), 'border_sides': 42}, {'type': np.str_('B'), 'size': np.int64(1), 'border_length': np.int64(4), 'border_sides': 4}, {'type': np.str_('B'), 'size': np.int64(2), 'border_length': np.int64(6), 'border_sides': 4}, {'type': np.str_('B'), 'size': np.int64(3), 'border_length': np.int64(8), 'border_sides': 6}, {'type': np.str_('B'), 'size': np.int64(146), 'border_length': np.int64(86), 'border_sides': 50}, {'type': np.str_('B'), 'size': np.int64(1), 'border_length': np.int64(4), 'border_sides': 4}, {'type': np.str_('B'), 'size': np.int64(1), 'border_length': np.int64(4), 'border_sides': 4}, {'type': np.str_('B'), 'size': np.int64(30), 'border_length': np.int64(38), 'border_sides': 22}, {'type': np.str_('B'), 'size': np.int64(1), 'border_length': np.int64(4), 'border_sides': 4}, {'type': np.str_('B'), 'size': np.int64(103), 'border_length': np.int64(82), 'border_sides': 54}, {'type': np.str_('B'), 'size': np.int64(3), 'border_length': np.int64(8), 'border_sides': 4}, {'type': np.str_('B'), 'size': np.int64(86), 'border_length': np.int64(62), 'border_sides': 38}, {'type': np.str_('B'), 'size': np.int64(12), 'border_length': np.int64(18), 'border_sides': 8}, {'type': np.str_('B'), 'size': np.int64(3), 'border_length': np.int64(8), 'border_sides': 6}, {'type': np.str_('B'), 'size': np.int64(90), 'border_length': np.int64(46), 'border_sides': 24}, {'type': np.str_('B'), 'Line truncated
] ]
} }
], ],
@@ -68,18 +82,25 @@
"print(clusters)" "print(clusters)"
] ]
}, },
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Part 1"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 129, "execution_count": 4,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"1930" "np.int64(1494342)"
] ]
}, },
"execution_count": 129, "execution_count": 4,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@@ -97,646 +118,16 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 130, "execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"directions = [\n",
" (1, -1, 0),\n",
" (2, 1, 0),\n",
" (4, 0, -1),\n",
" (8, 0, 1),\n",
"]\n"
]
},
{
"cell_type": "code",
"execution_count": 134,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"from scipy.ndimage import label\n",
"\n",
"def find_clusters_matrix(grid):\n",
" grid = np.array(grid)\n",
" unique_types = np.unique(grid)\n",
" clusters = []\n",
" \n",
" for char in unique_types:\n",
" # Binary mask for current character\n",
" binary_map = (grid == char)\n",
" \n",
" # Label connected components\n",
" labeled_map, num_features = label(binary_map)\n",
" \n",
" for cluster_id in range(1, num_features + 1):\n",
" # Cluster size\n",
" cluster_mask = (labeled_map == cluster_id)\n",
" size = cluster_mask.sum()\n",
" bordermaps = np.zeros(grid.shape,dtype=int)\n",
"\n",
" # Border length\n",
" for x, y in zip(*np.where(cluster_mask)):\n",
" for direction, dx, dy in directions:\n",
" nx, ny = x + dx, y + dy\n",
" if nx < 0 or nx >= grid.shape[0] or ny < 0 or ny >= grid.shape[1] or grid[nx, ny] != char:\n",
" bordermaps[x][y] |= direction\n",
" print(bordermaps)\n",
" border_length = 0\n",
" border_sides = 0\n",
" for direction,dx,dy in directions:\n",
" map = (bordermaps & direction) != 0\n",
" border_length += np.sum(map)\n",
" map2, sides = label(binary_map)\n",
" print(map2)\n",
" border_sides += sides\n",
"\n",
" clusters.append({\"type\": char, \"size\": size, \"border_length\": border_length, \"border_sides\":border_sides})\n",
" \n",
" return clusters\n"
]
},
{
"cell_type": "code",
"execution_count": 135,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[ 0 0 0 0 0 0 5 9 0 0]\n",
" [ 0 0 0 0 0 0 4 2 11 0]\n",
" [ 0 0 0 0 0 5 10 0 0 0]\n",
" [ 0 0 0 7 1 10 0 0 0 0]\n",
" [ 0 0 0 0 12 0 0 0 0 0]\n",
" [ 0 0 0 0 6 9 0 0 0 0]\n",
" [ 0 0 0 0 0 14 0 0 0 0]\n",
" [ 0 0 0 0 0 0 0 0 0 0]\n",
" [ 0 0 0 0 0 0 0 0 0 0]\n",
" [ 0 0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n",
" [0 0 0 0 0 0 0 0 0 0]]\n",
"[{'type': 'C', 'size': 14, 'border_length': 28, 'border_sides': 8}, {'type': 'C', 'size': 1, 'border_length': 4, 'border_sides': 8}, {'type': 'E', 'size': 13, 'border_length': 18, 'border_sides': 4}, {'type': 'F', 'size': 10, 'border_length': 18, 'border_sides': 4}, {'type': 'I', 'size': 4, 'border_length': 8, 'border_sides': 8}, {'type': 'I', 'size': 14, 'border_length': 22, 'border_sides': 8}, {'type': 'J', 'size': 11, 'border_length': 20, 'border_sides': 4}, {'type': 'M', 'size': 5, 'border_length': 12, 'border_sides': 4}, {'type': 'R', 'size': 12, 'border_length': 18, 'border_sides': 4}, {'type': 'S', 'size': 3, 'border_length': 8, 'border_sides': 4}, {'type': 'V', 'size': 13, 'border_length': 20, 'border_sides': 4}]\n"
]
}
],
"source": [
"clusters = find_clusters_matrix(data)\n",
"print(clusters)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"532" "np.int64(893676)"
] ]
}, },
"execution_count": 120, "execution_count": 5,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@@ -744,163 +135,11 @@
"source": [ "source": [
"sum(cluster['size']*cluster['border_sides'] for cluster in clusters)" "sum(cluster['size']*cluster['border_sides'] for cluster in clusters)"
] ]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[{'type': 'C', 'size': 14, 'border_length': 28, 'border_sides': 8},\n",
" {'type': 'C', 'size': 1, 'border_length': 4, 'border_sides': 8},\n",
" {'type': 'E', 'size': 13, 'border_length': 18, 'border_sides': 4},\n",
" {'type': 'F', 'size': 10, 'border_length': 18, 'border_sides': 4},\n",
" {'type': 'I', 'size': 4, 'border_length': 8, 'border_sides': 8},\n",
" {'type': 'I', 'size': 14, 'border_length': 22, 'border_sides': 8},\n",
" {'type': 'J', 'size': 11, 'border_length': 20, 'border_sides': 4},\n",
" {'type': 'M', 'size': 5, 'border_length': 12, 'border_sides': 4},\n",
" {'type': 'R', 'size': 12, 'border_length': 18, 'border_sides': 4},\n",
" {'type': 'S', 'size': 3, 'border_length': 8, 'border_sides': 4},\n",
" {'type': 'V', 'size': 13, 'border_length': 20, 'border_sides': 4}]"
]
},
"execution_count": 121,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"clusters"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"a = np.full((3,3),'',dtype=object)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([['', '', ''],\n",
" ['', '', ''],\n",
" ['', '', '']], dtype=object)"
]
},
"execution_count": 98,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"a[:] = 'up'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"a[1][2]='down'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([['up', 'up', 'up'],\n",
" ['up', 'up', 'down'],\n",
" ['up', 'up', 'up']], dtype=object)"
]
},
"execution_count": 93,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[ True, True, True],\n",
" [ True, True, False],\n",
" [ True, True, True]])"
]
},
"execution_count": 101,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a=='up'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([['up', 'up', 'up'],\n",
" ['up', 'up', 'down'],\n",
" ['up', 'up', 'up']], dtype=object)"
]
},
"execution_count": 105,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
} }
], ],
"metadata": { "metadata": {
"kernelspec": { "kernelspec": {
"display_name": "Python 3", "display_name": "advent",
"language": "python", "language": "python",
"name": "python3" "name": "python3"
}, },
@@ -914,7 +153,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.8.10" "version": "3.13.0"
} }
}, },
"nbformat": 4, "nbformat": 4,