ludus

Color Mixing

ld-0007 · 7 › ███████░░░ · arrays, graphs · requires: arrays · oner golfed generalized

Your client is an artist with a list of colors and their components. They tell you that ultimately, all pigments break down into the primary colors: Red, Yellow, and Blue.

Every color in the list is a mix of exactly two components. A component is either a primary color or another color from the list (possibly the same component twice). A color's breakdown is the sum of its two components' breakdowns; a primary's breakdown is one unit of itself. Mixtures never loop back on themselves.

Determine each color's breakdown into primaries, in the same row of OUTPUT as the color, formatted exactly like "3 Red, 2 Yellow, 1 Blue" (counts are not reduced). The grader swaps in color lists of different lengths, so cover the whole OUTPUT range: empty input rows must produce empty output rows.

Work on it

  1. Make a copy of the template — it becomes your private sheet.
  2. Solve it however you like — helper columns and extra tabs are fair game. The one rule: the grader swaps INPUT for other datasets, so never put your own content inside INPUT.
  3. Check yourself against the expected sample output shown in your copy (and below).
  4. Submit below — Share → "anyone with the link, Viewer", paste the link. Your sheet is graded against 2 hidden datasets, so hardcoded answers won't survive.

Sample

Input (Input!B2:D20)

NameComponent 1Component 2
DuskMintCoral
PeachRedYellow
EmberBlushStorm
MintYellowBlue
StormDuskSage
CoralPeachRed
SageMintYellow
BlushCoralPeach

Expected output (Answer!B3:B20)

Breakdown
2 Red, 2 Yellow, 1 Blue
1 Red, 1 Yellow, 0 Blue
5 Red, 6 Yellow, 2 Blue
0 Red, 1 Yellow, 1 Blue
2 Red, 4 Yellow, 2 Blue
2 Red, 1 Yellow, 0 Blue
0 Red, 2 Yellow, 1 Blue
3 Red, 2 Yellow, 0 Blue

Adapted from "Color Mixing" in the astral.cafe Community Practice Problems sheet.