Count the guitar strings
Original questionHow many dark strings visibly run from the guitar's headstock, along the neck, and across its body? Count each continuous thin path once. Answer 4, 5, 6, 7, or 8.
Forward program · scene → answer
Read the number of strings specified in the scene.
def analytic_gold(scene: dict) -> str:
return str(int(scene["string_count"]))Read full renderer and forward source ↗Inverse program · image → answer
Locate the bright bridge in the image, identify narrow dark runs across it, and count them. Three adjacent rows must agree.
# Take a three-row vote. Each qualifying string is a narrow dark run wholly
# inside the recovered bridge extent; body edges and sound hole lie outside.
counts = []
for y in range(y0 - 1, y0 + 2):
strip = rgb[y, xlo:xhi+1]
dark = strip.mean(axis=1) < 105
runs = [(a, b) for a, b in _runs(dark) if 1 <= b-a <= 7 and a > 2 and b < len(dark)-2]
counts.append(len(runs))
count = int(np.median(counts))
if count not in {4, 5, 6, 7, 8} or max(counts) != min(counts):
raise ValueError(f"ambiguous string runs: {counts}")
return str(count)Read full inverse source ↗






















