← Back to challenges

Broken Bridge

PythonMediumlanguage_fundamentalsstringsvalidation

Instructions

Create a function which validates whether a bridge is safe to walk on (i.e. has no gaps in it to fall through).

Examples

is_safe_bridge("####") ➞ True

is_safe_bridge("## ####") ➞ False

is_safe_bridge("#") ➞ True

Notes

You can expect the bridge's ends connecting it to its surrounding.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Adding Parity Bits