Skip to content
Tactiverge

◇ Electronics · loops over arrays

Series and parallel resistors

Combine a list of resistors in series and in parallel.

  • Level 1 · Explorer
  • 6 tests
  • technically checked

Your task

Write two functions that take an array of resistances in ohms:

  • series(rs) returns the sum. An empty array is 0 Ω.
  • parallel(rs) returns 1 / (1/R₁ + 1/R₂ + …).

Two equal resistors in parallel give half the resistance: a handy trick when the drawer has no 50 Ω part.

Hints (0 of 2 shown)

    What gets checked

    • series([100, 220, 330]) → 650
    • parallel([100, 100]) → 50

    Plus 4 hidden tests for edge cases. They run in the sandbox like the others; only the result is shown.

    Tab indents · Esc then Tab leaves the editor · Ctrl/⌘ Enter runs · Ctrl/⌘ Shift Enter checks · Ctrl/⌘ / comments

    Starting the sandbox…

    Press Run to see what your program prints.

    Your code runs only in this browser, inside an isolated sandbox with no network access, and stops after 3 s. Nothing you type is sent to Tactiverge; drafts and progress are saved in this browser only.