An adventure down a side road
Not all side roads lead to nowhere. Sometimes the fun of an off the beaten track road leads you to new insights.
While trying to decide which way to turn next in my quest to re-write the company application in Objectscript, an email from Global Masters arrived. After guessing (incorrectly) on the Quiz (it was a health share related question I know nothing about but a chance for 15 points is worth a guess), I came across a new codeGolf challenge. I've seen these before but since I didn't have the first clue about ObjectScript, I always skipped them.
Today seemed like a good day to learn a little more ObjectScript and the challenge was interesting and not too complicated.
ClassMethod Detector(a As %String, b As %String) As %Boolean
{
SET a=$CHANGE(a," ","")
SET a=$ZCVT(a,"l")
SET b=$CHANGE(b," ","")
SET b=$ZCVT(b,"l")
SET c = ""
FOR i = 1 :1 :$L(a)
{
SET p = $F(b,$E(a,1))
if p { SET $E(b,p-1)="" } else { set c=c_$E(a,1) }
set $E(a,1)=""
}
if ($L(a) + $L(b) + $L(c) ) { q 0 } else { q 1 }
}
There are six old challenges that I'm planning to complete just for the experience. No prize - except for more experience with ObjectScript.
Comments
Post a Comment