Constructing text with astericks
aberba
karabutaworld at gmail.com
Wed May 30 22:57:06 UTC 2018
I've been given a challenge to write texts using asterisks to
form the letters. D happen to have an unlimited amount of idioms
yet i'm out out ideas as to the simplest approach. Task is to
basically take a piece of text and write them as asterisks to the
console.
***** *
* *
***** *
* *
***** *
First solution I found was to create a class for each
letter...like new A(), new B() and implement the logic withing
each class. This doesn't scale and i'll have to write about 24 or
more classes.
Another complex but "makes sense" solution will be to use a GRID
system like old digital watches but i'll need a more complex grid
to draw complex letters using a dictionary of REPOPULATED indexes
of asterisk for each word. First use the length of the string to
compute the grid size and iterate over each character to
indentify the dictionary of a letter's indexes to use:
*****
*******
** **
*******
** ***
** *** (an R using a more complex Grid)
How will you approach this problem in D idiomatically?
More information about the Digitalmars-d-learn
mailing list