SnIPPETsX › 1-omino
1-omino
Python · updated Nov 11, 2026 · 63 lines
main.py
import random
# 1-omino
#
# []
#
# 2-omino
#
# [] []
#
# 3-omino
#
# [] [] []
#
# []
# [] []
#
# 4-omino (non exhaustive)
#
# [] []
# [] []
#
# [] [] []
# []
# make an obj representation of an N omino
# Omino Object
rows, cols = 5, 5
ominoObj = [[0 for _ in range(cols)] for _ in range(rows)]
# print(ominoObj)
def isAdj(x, y):
directions = [(-1, 0), (1, 0), (0, -1), (0, 1)]
for dr, dc in directions:
nr, nc = x + dr, y + dc
# bounds check
if 0 <= nr < rows and 0 <= nc < cols:
if ominoObj[nr][nc] == 1:
return True
else:
return False
# 3
def createOmino(n):
# create n position placements randomly
for ominoPos in range(n):
# generate coords
# x
x = random.randint(0, rows)
y = random.randint(0, rows)
while not isAdj(x, y):
x = random.randint(0, rows)
y = random.randint(0, rows)
ominoObj[x][y] = 1
print(ominoObj)
print(createOmino(3))
Run this Python snippet
Open this snippet on SnIPPETsX to run the Python code in your browser, edit it together with others in real time, or fork it into your own copy. No install or account is needed.