Skip to content
Closed
Show file tree
Hide file tree
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
Binary file not shown.
Binary file not shown.
Binary file added Week04/__pycache__/arrays_oguz_aydin.cpython-313.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
29 changes: 29 additions & 0 deletions Week04/arrays_sinem_gencer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import numpy as np

def replace_center_with_minus_one(d, n, m):
"""
Check if inputs are valid
"""
if d <= 0 or n <= 0 or m <= 0:
raise ValueError("Parameters d, n, and m must be positive integers.")
if m > n:
raise ValueError("Center size m cannot be greater than array size n.")
"""
Create array of nxn size filled with random values using d
"""
outer_min = 10 ** (d - 1)
outer_max = 10 ** d
arr = np.random.randint(outer_min, outer_max, size=(n, n))

"""
Get indices for center according to m value given
"""
start = (n - m) // 2
end = start + m

"""
Fill mxm array in the center with -1
"""
arr[start:end, start:end] = -1

return arr
Loading