--------------020604010506010408090403
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Ruby Quiz wrote:

> This week's quiz is to write a program that displays LCD style numbers at
> adjustable sizes.

Here we go. I decided to add support for "-" and ".". My implementation 
does not actually enforce the argument to be a valid number thus also 
allowing it to render IP numbers:

> C:\dev\ruby\quizes\14>ruby lcd.rb -s 5 127.0.0.1                       
>          -----   -----           -----           -----                 
>       |       |       |         |     |         |     |               |
>       |       |       |         |     |         |     |               |
>       |       |       |         |     |         |     |               |
>       |       |       |         |     |         |     |               |
>       |       |       |         |     |         |     |               |
>          -----           -----           -----           -----         
>       | |             | |     | |     | |     | |     | |     |       |
>       | |             | |     | |     | |     | |     | |     |       |
>       | |             | |     | |     | |     | |     | |     |       |
>       | |             | |     | |     | |     | |     | |     |       |
>       | |             | |     | |     | |     | |     | |     |       |
>          -----           -----   -----   -----   -----   -----         

I decided to store the representation of digits as binary bit masks. I 
created a few helpers methods (line, horizontal, vertical, digit) so 
that I did not need to duplicate code.

I used .transpose in combination with .join for rendering the digits 
(which are represented as an Array of lines) next to each other instead 
of below each other.


--------------020604010506010408090403
Content-Type: application/x-ruby;
 namecd.rb"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
 filenamecd.rb"

bW9kdWxlIExDRA0KICBleHRlbmQgc2VsZg0KDQogICMgRGlnaXRzIGFyZSByZXByZXNlbnRl
ZCBieSBzaW1wbGUgYml0IG1hc2tzLiBFYWNoIGJpdCBpZGVudGlmaWVzIHdoZXRoZXIgYSBs
aW5lDQogICMgc2hvdWxkIGJlIGRpc3BsYXllZCBvciBub3QuIFRoZSBmb2xsb3dpbmcgQVND
SUkgZ3JhcGhpYyBzaG93cyB0aGUgbWFwcGluZyBmcm9tDQogICMgYml0IHBvc2l0aW9uIHRv
IHRoZSBiZWxvbmdpbmcgbGluZS4NCiAgIw0KICAjICA9Ng0KICAjIDUgIDQNCiAgIyAgPTMN
CiAgIyAyICAxDQogICMgID0wDQogIERpZ2l0c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