Here is a quick sunday quiz. Create some kind of clock with as little code as possible. Even just a textfield and the date object would cut it, but preferably try to do something a little more interesting. Post your results in the comments. I’ll post my version on monday EOD.
[EDIT: my clock can be found here which I'll count as tomorrows post]
Today's quiz is not multiple choice. Instead, your task is to write a lisp style math parser. This may sound tricky, but it's surprisingly simple. (well... not simple exactly, it's just simple compared to what one might assume).
Lisp uses prefix notation... where the operator is placed before the operands:
10 * 10
* 10 10
You could think of this as a function "*" with two arguments (10, 10). In Lisp this is enclosed with parens:
(* 10 10)
Let's see a few more examples:
100 / 2 + 10
(+ (/ 100 2) 10)
2 * 4 * 6 * 7
(* 2 4 6 7)
(2 + 2) * (10 - 2) * 2
(* (+ 2 2) (- 10 2) 2)
Remember, thinking "functions" really helps. The above can be though of as:
multiply( add(2, 2), subtract(10 , 2), 2)
You should create a function called parsePrefix() that takes a string and returns a number:
Here is some code to test if your parser works properly:
This is probably the hardest quiz yet. After yesterdays very easy quiz I figured I'd do something really trickey... binary is always a good way to make a quiz hard... so most of the questions are about binary operators and ByteArray... there is also one question about Bezier math.
Number of Questions : 7
Difficulty : Hard
Topic : Binary and Bezier
Today's quiz is not multiple choice. Instead, use your choice of the Graphics class or BitmapData to write a function that generates the below image:
Your function need not take any arguments, it need only return a display object containing the above image.
Feel free to post your solution in the comments.
The solutions that have been posted in the comments so far are REALLY nice - they're all worth checking out... and I think everyone posted their code to wonderfl so you can see the result without needing to open flash....
My two solutions:
The first solution is a variation on an example from the book I wrote with Rich Shupe: First Solution
The next solution is actually in an old post from this site - it uses setPixel and HSV - RGB conversion: Second Solution
Thanks to everyone who posted solutions so far - I'm surprised again by how many people participate in this format of quiz.