← Back to challenges

On/Off Switches

PythonMediumalgebramathlogic

Instructions

Create a function that returns how many possible arrangements can come from a certain number of switches (on / off). In other words, for a given number of switches, how many different patterns of on and off can we have?

Examples

pos_com(1) ➞ 2

pos_com(3) ➞ 8

pos_com(10) ➞ 1024

Notes

All numbers will be whole and positive.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Fix the Errors / Comparing Arrays