solve.sh 295 B

123456789101112
  1. #!/bin/bash
  2. set -e
  3. python3 - <<'PY'
  4. from pathlib import Path
  5. p = Path("/app/stats.py")
  6. src = p.read_text()
  7. old = 'amount = float(row["amount"])\n'
  8. new = old + ' if row["type"] == "refund":\n amount = -amount\n'
  9. assert old in src
  10. p.write_text(src.replace(old, new))
  11. PY