Swift Wala

A Blog about Swift and iOS Development

My First Swift Code

| Comments

Ok so finally we see some real Swift code for the first time on this blog. Yay!! As I mentioned in my last post, my solution 1 for the Topcoder $100 Playground challenge is given below. It helped me to get started with some Swift syntax and get a bit comfortable using playground feature of Swift. Don’t worry about so many lines. Most of it is comments. Comments basically are instructions for participants on what needs to be done. Solution to the problem follows the comment.

I found myself referring Apple’s Swift Book many times to get the concepts right for each of these problems. Getting the Generics right took sometime and I also referred good old StackOverFlow a few times, specially to get the random number generation right.

Everything should be self-explanatory, but let me know if you don’t understand anything.


  1. I am sharing my solution since the contest is already over. I have also reached out to Topcoder over Twitter and email for clarifications regarding any violations. I haven’t heard back from them, but I don’t intend to violate any terms & conditions and if I will be made aware that it’s not ok to share the code from contest entry like this, I am ready to remove it from here.

Comments