Algorithm · Karat · Medium
You are working with a choose-your-own-path story book. Some pages lead straight to another page, while others give the reader two choices for which page to read next. Reading always begins on page 1. The task comes in several parts: Determine which ending the reader arrives at if they make the same choice (always the first option, or always the second) every time a page offers two options. Recognize when following the choices leads into a loop, meaning the reader returns to…