© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2021
T. LaversLearn to Program with Kotlinhttps://doi.org/10.1007/978-1-4842-6815-5_13

13. Word Switch

Tim Lavers1  
(1)
Woonona, NSW, Australia
 
How can one turn “cave” into “home”? Here’s one way:
cave → came → come → home.

This is the word switch game: choose two words and then see if one can be transformed into the other by changing one letter at a time, such that a valid word is produced by each change.

In this chapter, we will write software that solves the word switch problem for any two words—if there is a solution—and lets us know if there is not. As well as being an interesting problem, this will give us yet more practice with object-oriented programming

Get Learn to Program with Kotlin: From the Basics to Projects with Text and Image Processing now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.