Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Week04/arrays_sinem_isk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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 or n <= 0 or m < 0:
raise ValueError("d, n must be positive and m cannot be negative")

max_val = 10**d - 1 # d basamaklı maksimum sayı (örnek: d=2 -> 99)
arr = np.random.randint(0, max_val + 1, size=(n, n))

start = (n - m) // 2
end = start + m
arr[start:end, start:end] = -1

return arr

if __name__ == "__main__":
result = replace_center_with_minus_one(2, 5, 3)
print(result)