From db31d253f01995d4e50dc75261dad3c97b01a04c Mon Sep 17 00:00:00 2001 From: sedaozkaya <155262567+sedaozkaya@users.noreply.github.com> Date: Fri, 7 Nov 2025 22:44:36 +0300 Subject: [PATCH] Create arrays_seda_sengul_ozkaya.py --- Week04/arrays_seda_sengul_ozkaya.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Week04/arrays_seda_sengul_ozkaya.py diff --git a/Week04/arrays_seda_sengul_ozkaya.py b/Week04/arrays_seda_sengul_ozkaya.py new file mode 100644 index 0000000..3258b60 --- /dev/null +++ b/Week04/arrays_seda_sengul_ozkaya.py @@ -0,0 +1,28 @@ +import numpy as np + +def replace_center_with_minus_one(d, n, m): + + if m > n: + raise ValueError("m cannot be greater than n.") + if d <= 0: + raise ValueError("d must be positive.") + if n <= 0: + raise ValueError("n must be positive.") + if m < 0: + raise ValueError("m cannot be negative.") + + low = 10 ** (d - 1) + high = 10 ** d + arr = np.random.randint(low, high, size=(n, n)) + + + start = (n - m) // 2 + end = start + m + + if n % 2 == 0 and m % 2 == 1: + start -= 1 + end -= 1 + + arr[start:end, start:end] = -1 + + return arr