From a84fdc6207ad28dd3cd1e61575e579d52d1a06e9 Mon Sep 17 00:00:00 2001 From: Luke Hubmayer-Werner Date: Tue, 21 Dec 2021 00:46:22 +1030 Subject: [PATCH] Rename inv_reduce to unfold to align with other implementations of the concept --- 2021/day20.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/2021/day20.py b/2021/day20.py index e9e8afe..aeec33a 100644 --- a/2021/day20.py +++ b/2021/day20.py @@ -1,6 +1,6 @@ import numpy as np -def inv_reduce(func, arg, n): +def unfold(func, arg, n): for _ in range(n): arg = func(arg) yield arg @@ -22,6 +22,6 @@ def visualize(array): print('\n'.join(''.join(['.','#'][c] for c in row) for row in array)) -simulated_lights = [t.sum() for t in inv_reduce(sample, np.pad(input_arr, 51), 50)] +simulated_lights = [t.sum() for t in unfold(sample, np.pad(input_arr, 51), 50)] print('Part 1: Lights after 2 enhancements:', simulated_lights[2-1]) print('Part 2: Lights after 50 enhancements:', simulated_lights[50-1])