Saturday, September 21, 2013

Implementation of "Triangular Number Sequence" with Scala

Triangular Number Sequence is 1, 3, 6, 10, 15. This is very basic mathematical concept.
This sequence is getting generated from a pattern of dots which form a Triangle.

To know more about Triangular Number Sequence, please check this page => Triangular Number Sequence

At this page only I saw one very good example of how we can use this sequence in solving problems. One problem is given @: A Walk in The Desert

So I thought of solving the problem with Functional Programming i.e. Scala. 
The solution code is @ Solution to A Walk in The Desert

The strategy I followed:
  • Consideration: My starting position is {0, 0} [FYI: Always first X co-ordinate and then Y co-ordinate]
  • Strategy:
  • In every odd step => Either I am going towards North or toward South i.e. my X co-ordinate is constant
  • In every even step => Either I am going towards East or toward West i.e. my Y co-ordinate is constant
  • In every steps, my co-ordinate(either X or Y based on whether my step is even or odd) will  change the sign.
Feel free to provide your comment if you see any scope of improvement. Thanks.

Friday, September 20, 2013

Coursera Functional Programming Principles in Scala Course by Martin Odersky

Hurray!!! I was waiting for this course Functional Programming Principles in Scala Course by Martin Odersky since long time. It started now and it is really helping me to think differently. It is creating a habit inside me - "Can I do this in better way?". After spending 9 hours (sometime 10 hours) in office, I still manage to check Scala every day, ok sorry almost every day.

Just completed the first week's exercises and received 9.56/10. I think this is not a bad score. But again "Can I make this better?". Let's see if I can do that.

First week's (assignment + tutorial) not only educates me about basics of Scala programming Language & Functional Programming, It helped me to understand few basic mathematical stuffs also. I love the way how easily I can implement mathematical equations into Functional programming using Functions.

While browsing internet, I got this website. Math Is Fun. This website is having very good collections of mathematical concepts and most importantly quizzes to implement those concepts. Now my new target is to implement those mathematical concepts using Scala. All my source code will be available @ Github.

It's time to go for bed now. Good Night.

Tuesday, September 10, 2013