ludus

Card Battle

ld-0009 · 5 › █████░░░░░ · arrays, simulation · requires: arrays · oner lambdaless generalized golfed

You're looking to make a deck for a card game. Not just any deck; the best deck. To that end, you want to rank the cards by how they fare against each other.

Cards have three stats, formatted "Attack/Health/Speed". Each card goes 1v1 against every other card. The card with the higher Speed acts first each round; on its turn a card deals damage equal to its Attack to the other card's Health. A card dies when its Health reaches zero or below, and the survivor wins. If both cards have the same Speed they act simultaneously — and if that kills both in the same round, the battle is a draw.

A win scores 1 point, a draw 0.5, a loss 0. Produce two columns — card name and total score — sorted by score from highest to lowest. Cards with equal scores keep their input order. The grader swaps in card lists of different lengths, so cover the whole OUTPUT range with empty rows staying empty.

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:C22)

NameStats
Bruiser3/5/2
Flash2/2/4
Tank1/8/1
Mirror A2/4/3
Mirror B2/4/3

Expected output (Answer!B3:C22)

NameScore
Bruiser4
Mirror A2.5
Mirror B2.5
Tank1
Flash0

Adapted from "Card Battle" in the astral.cafe Community Practice Problems sheet.