added lne length constraint to ea32f347 task

This commit is contained in:
joesharratt1229 2025-02-08 11:40:37 +00:00
parent a1494c4e5b
commit 4023efd311

View file

@ -1475,23 +1475,29 @@ def generate_ea32f347(rng: random.Random, diff_lb: float, diff_ub: float) -> dic
cols = difference(interval(0, 10, 1), (1, 2, 4))
h = unifint(rng, diff_lb, diff_ub, (5, 30))
w = unifint(rng, diff_lb, diff_ub, (5, 30))
a = unifint(rng, diff_lb, diff_ub, (3, 30))
max_l = min(h, w)
a = unifint(rng, diff_lb, diff_ub, (3, max_l))
b = unifint(rng, diff_lb, diff_ub, (2, a))
c = unifint(rng, diff_lb, diff_ub, (1, b))
if c - a == 2:
if a > 1:
a -= 1
elif c < min(h, w):
c += 1
bgc = rng.choice(cols)
remcols = remove(bgc, cols)
gi = canvas(bgc, (h, w))
go = canvas(bgc, (h, w))
inds = asindices(gi)
for col, l in zip((1, 4, 2), (a, b, c)):
ln1 = connect((0, 0), (0, l - 1))
ln2 = connect((0, 0), (l - 1, 0))
tmpg = fill(gi, -1, asindices(gi) - inds)
occs1 = occurrences(tmpg, recolor(bgc, ln1))
occs2 = occurrences(tmpg, recolor(bgc, ln2))
pool = []
@ -1499,12 +1505,15 @@ def generate_ea32f347(rng: random.Random, diff_lb: float, diff_ub: float) -> dic
pool.append((ln1, occs1))
if len(occs2) > 0:
pool.append((ln2, occs2))
ln, occs = rng.choice(pool)
loc = rng.choice(totuple(occs))
plcd = shift(ln, loc)
gi = fill(gi, rng.choice(remcols), plcd)
go = fill(go, col, plcd)
inds = (inds - plcd) - mapply(dneighbors, plcd)
return {"input": gi, "output": go}