Making Mountains out of a mole-hill...! ;-) :)
It was Christmas, & I was lazing around with my friends in the utter cold weather...
And my dear friend Prashant "woke me" up with some of his suggestions on making 'nice-looking' mountain-ranges when he happened to see my following creation, which is essentially a Mathematica(l) plot of Sin(2x)+ Cos(2y) where both x & y are in the closed-interval [0, 3 Pi][click the pic below to see better! ]
He wondered if we can have better approximations to real mountain ranges...
And that got me thinking...(& literally, rummaging the cup-boards in my memory-p(a)lace (a dingy hut rather..!! :P))...
And soon, i found something interesting, an utterly simple way of making mountains...based on pairs of Parentheses which can be nested together as well as shown below...[click the pic below to see better! ]
And that got me thinking...(& literally, rummaging the cup-boards in my memory-p(a)lace (a dingy hut rather..!! :P))...
And soon, i found something interesting, an utterly simple way of making mountains...based on pairs of Parentheses which can be nested together as well as shown below...[click the pic below to see better! ]
I was working on an alternative way of making mountains out of "strings' while my dear friend Prashant came up with this beauty (http://on.fb.me/vOOgx0)... :)
Jusst made my own, "verbose" (like me moron..!:P) version...which is more like instructing a robotic arm(or a child) to draw the mountains, with a simple rule as below:
Jusst made my own, "verbose" (like me moron..!:P) version...which is more like instructing a robotic arm(or a child) to draw the mountains, with a simple rule as below:
- Traverse the string of brackets...given as input
- If you encounter a "(", ASCEND i.e., draw a line moving towards the UPPER-RIGHT hand corner.
- Else (if it is a ")"), DESCEND i.e., draw a line moving towards the LOWER-RIGHT hand corner.
Here's the output of my baby Mathematica(l) program: [click the pic below to see better! ]
As I came running DOWN the Stairs & shared with Prashant [it's always the Eureka! phenomenon, albeit with my clothes on..! ;) ], the thing of JOY (& BEAUTY!) that I discovered, & want to point out in this 'technique', is that it is a "look-see" device, or a sort of visual "check" fer whether a string of parentheses are properly 'balanced' or NOT! :-)
[
The simple heuristic/observation is that the brackets are 'okay' if the mountain-ranges reach 'back to ground-zero' i.e., the same height that they started out with/frem!
This assumes that the input-string begins with a "(" else, a trivial counter-example is : "())(" -- Can you see why..? :P
]
Any sort of 'imbalance' in the brackets, gives rise to a 'limping' Mountain-range...!:P
I request you to please check it out yourself!
The beauty of this is the utter simplicity; NO Need of sophisticated programs, nothing..!! :)
Even a child can doodle it & discover...& create a infinite number of mountain-ranges of different shapes & sizes...!
Even a child can doodle it & discover...& create a infinite number of mountain-ranges of different shapes & sizes...!
Note the following points:
- The deeper the nesting, the taller the mountains become.
- Also, YOU can 'guess &/or calculate & prove' the relationship between the TOTAL number of bracket-pairs & the TOTAL possible number of ways in which a 'proper' mountain range could be created.
Feel FREE to EXPLORE & share...!! <3 :)
Merry X-mas & a Wonder-Filled Happy New Year to YOU n oLL your dear ones..!
Take care, & Keep Smiling, AL(L)-ways..!
Love & Best Wishes,