Solving a Coding Challenge? Draw a Picture.

Joshua Alexander
Dec 8, 2019 · 2 min read
Initial flow chart to begin solving a challenge.

This is an update for my participation in the #100DaysOfCode Challenge.

“DRAW A PICTURE,” my physics professor would yell at us for the millionth time that semester. This usually followed the question “What do you do first?,” and was generally shouted after several seconds of mumbled guesses and blank stares. His frustration was understandable, given that on day one of the class, he outlined the steps necessary to solve every physics problem we would work through. Step one was, of course, to draw a picture of the problem.

That’s exactly what I did when I started working my way through the challenge I solved today. In fact, it’s something I’ve been working on doing regularly with each challenge. And my diagrams are starting to get better. Consequently, so is my problem solving.

The challenge I dealt with today was an exercise in mutating strings from a word into its Pig Latin counterpart. After reading the exercise, and thinking for a moment about the challenge, I drew the above diagram. And then I got to work. Having Regular Expressions (RegEx) on the brain after dealing with them in yesterday’s challenge, I was in a much better place mentally to be able to apply them to today’s challenge solution. It took a little work, but I applied some of the lessons I learned yesterday, as well as came to a better understanding of some elements of RegEx. Having the diagram to work from, it was almost simple to write out the code and apply the RegEx.

And I learned a new thing: in using RegEx as the parameter for the .split() method on a string, surrounding the search criteria in parentheses would cause the item at which the split occurs to be included in the resulting array instead of removed entirely.

That’s pretty cool.

32/100

{nonsensecodes}

My Journey to Developer

Joshua Alexander

Written by

Reading. Writing. Music. Yoga.

{nonsensecodes}

My Journey to Developer

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade