Skip to content

Instantly share code, notes, and snippets.

@ambethia
Last active December 19, 2015 13:09
Show Gist options
  • Select an option

  • Save ambethia/5960316 to your computer and use it in GitHub Desktop.

Select an option

Save ambethia/5960316 to your computer and use it in GitHub Desktop.
Coder Night, for July 2013 Based on Ruby Quiz, #14

Note: Although the selected problem is from RubyQuiz, CoderNight is open to any program language.

LCD Numbers (RubyQuiz #14)

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

The digits to be displayed will be passed as an argument to the program. Size should be controlled with the command-line option -s follow up by a positive integer. The default value for -s is 2.

For example, if your program is called with:

> lcd.rb 012345

The correct display is:

 --        --   --        -- 
|  |    |    |    | |  | |   
|  |    |    |    | |  | |   
           --   --   --   -- 
|  |    | |       |    |    |
|  |    | |       |    |    |
 --        --   --        -- 

And for:

> lcd.rb -s 1 6789

Your program should print:

 -   -   -   - 
|     | | | | |
 -       -   - 
| |   | | |   |
 -       -   - 

Note the single column of space between digits in both examples. For other values of -s, simply lengthen the - and | bars.

- - - - - - - -
| | | | | | | | | | | | | |
- - - - - - -
| | | | | | | | | | | | |
- - - - - - -
---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
| | | | | | | | | | | | | |
| | | | | | | | | | | | | |
| | | | | | | | | | | | | |
| | | | | | | | | | | | | |
| | | | | | | | | | | | | |
| | | | | | | | | | | | | |
| | | | | | | | | | | | | |
| | | | | | | | | | | | | |
| | | | | | | | | | | | | |
| | | | | | | | | | | | | |
---------- ---------- ---------- ---------- ---------- ---------- ----------
| | | | | | | | | | | | |
| | | | | | | | | | | | |
| | | | | | | | | | | | |
| | | | | | | | | | | | |
| | | | | | | | | | | | |
| | | | | | | | | | | | |
| | | | | | | | | | | | |
| | | | | | | | | | | | |
| | | | | | | | | | | | |
| | | | | | | | | | | | |
---------- ---------- ---------- ---------- ---------- ---------- ----------
-- -- -- -- -- -- -- --
| | | | | | | | | | | | | |
| | | | | | | | | | | | | |
-- -- -- -- -- -- --
| | | | | | | | | | | | |
| | | | | | | | | | | | |
-- -- -- -- -- -- --
@ambethia
Copy link
Author

ambethia commented Jul 9, 2013

Feel free to discuss or ask questions about this month's problem!

@rwjblue
Copy link

rwjblue commented Jul 9, 2013

Looks like fun. Just to clarify: When the -s value is increased both the width and height are increased, right?

@ambethia
Copy link
Author

Yeah, I guess -s could stand for "size" or "segments".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment