From ff479a6fe2d8d8a312a63bb223aa425c42bc9ad0 Mon Sep 17 00:00:00 2001 From: Freezed Date: Thu, 16 Jul 2020 10:17:18 +0200 Subject: [PATCH] Change approach global instead local 1st idea was to manage propagation cells after cells. But this looks to generate a chain reaction that I cannot manage in a function. New idea is to manage the whole pile : * add a grain * find cells that reached 4 * change cell & update neighbors * find cells that reached 4 * change cell & update neighbors --- technical_tests/sand_grain_drop.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/technical_tests/sand_grain_drop.py b/technical_tests/sand_grain_drop.py index ab34797..82bf1d3 100644 --- a/technical_tests/sand_grain_drop.py +++ b/technical_tests/sand_grain_drop.py @@ -39,9 +39,7 @@ def main(pile, n): while n != 0: - if pile[center][center] < 3: - pile[center][center] += 1 - + pile[center][center] += 1 n -= 1 return pile