Recently someone asked to come up with Scala code on an over the phone coding screen. I failed that interview of course. That is the bitter truth.
So this question here is only to educate myself on how to solve that problem. Perhaps it might just help me learn more about Scala . That is the intention.
Stressful as it was and the fact that I had to come up with a one-liner Scala expression quickly, did not help.
I forgot about scala.util.Random and I had totally forgotten about java’s Random class’s getInt().
So, the question was: Come up with code that generates a 4 character alphanumeric string like: W1234, or B2351, Z7891. Note that special characters are not allowed. Capitalization does not matter.
I could go into the scala,util.Random library and try writing the code myself. But I would like to request the Scala folks here to help me solve this problem, from scratch. I want to get a glimpse into the thought process of a seasoned, experienced, quick-thinking Scala programmer.
My goal is to learn from all this and start contributing my own solutions on this forum. Let this be the way to get all this started.