http://qs321.pair.com?node_id=115967

If you're trying to make it completely proportional to an American flag in ASCII, you're going to fail. There are 7 stripes that are on level with the stars, but 9 lines of starts. How're you going to solve that?

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

Replies are listed 'Best First'.
Re: Re: American Flag?
by trantor (Chaplain) on Oct 02, 2001 at 11:07 UTC

It is possible indeed, if you consider acceptable a flag which is 117 ASCII lines long, with stars 7 lines "tall" and stripes 9 lines "tall".

Here's how. First, let's roughly split the flag into its areas:

```+-----------+--------------+
| A         |       B      |
|           |              |
|           |              |
|           |              |
+-----------+--------------+
|          C               |
|                          |
|                          |
+--------------------------+

Let's consider the height only. Area A is made of 9 rows of stars, area B is made of 7 stripes, Area C is made of 6 stripes.

Let x be the height of each star row, y be the height of each stripe, h the total height of the flag.

Then we have:

9x = 7y
13y = h

Where the first equation shows that 9 rows of stars must be as long as 7 stripes, the second shows that the flag is 13 stripes high.

With some simple algebraic operations we have:

x = 7h / 117
y = h / 13

Now, if we let h = 117, which is the minimum value satisfying these integer equations, we have that each row of stars must be 7 lines high and each stripe must be 9 characters high.

Doing this, areas A and B will both be 63 lines, area C will be 54 lines.

It is slightly imperfect because the flag has some space before the first row of stars and after the last, but it can work if each star is draw with a pattern like (dots instead of spaces for clarity, background and foreground swapped for clarity):

```..............
......XX......
..XX..XX..XX..
....XXXXXX....
....XX..XX....
..XX......XX..
..............