Broken Bridge

Published by bangyen in

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.

Watch a quick demo on how Edabit works.