From 7a8a0945c6ca66c0693e54874df924d531b14b1c Mon Sep 17 00:00:00 2001 From: Freezed Date: Thu, 16 Jul 2020 09:48:31 +0200 Subject: [PATCH] Drop sand grains without propagation --- technical_tests/sand_grain_drop.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/technical_tests/sand_grain_drop.py b/technical_tests/sand_grain_drop.py index 93d5284..ab34797 100644 --- a/technical_tests/sand_grain_drop.py +++ b/technical_tests/sand_grain_drop.py @@ -37,7 +37,14 @@ def main(pile, n): center = int((len(pile) - 1) / 2) - return center + while n != 0: + + if pile[center][center] < 3: + pile[center][center] += 1 + + n -= 1 + + return pile if __name__ == "__main__":