7
\$\begingroup\$

Here we go again! This is my last flag for now!

I originally wanted to do my national flag but I thought the stars were too hard so I posted Print the British Flag! instead, which itself was inspired by Print the American Flag!. This challenge would be better for 3 September (Australian National Flag Day) or 26 January (Australia Day) but I couldn't wait that long! The Commonwealth Star is a bit messy but I'm pleased with the rest of the design. Once again you need to view it at 90 degrees.

Produce the following design in the fewest bytes!

 ________________________________________________ 
|XXXXXXXXXXXXXXXXXXXXXXXX\  \XXXX  0000  XXXX//0/|
|XXXXXXXXXXXXXXXXXXXXXXXX0\  \XXX  0000  XXX//0/ |
|XXXXXXXXXXXXXXXXXXXXXXXX\0\  \XX  0000  XX//0/  |
|XXXXXXXXXXXXXXXXXXXXXXXX\\0\  \X  0000  X//0/  /|
|XXXXXXXXXXXXXXXXXXXXXXXXX\\0\  \  0000  //0/  /X|
|XXXXXXXXXXXXXXXXXXXXXXXXXX\\0\    0000  /0/  /XX|
|XXXXXXXXXXXXXXXXXXXXXXXXXXX\\0\   0000  0/  /XXX|
|XXXXXXXXXXXXXXXXXXXXXXXXXXXX\\0\  0000  /  /XXXX|
|XXXXXXXX|\XXXXX-/XXXXXXXXXXXX\\0  0000    /XXXXX|
|XXXXX-XX| \XX- /XXXXXXXXXXXXXX\\  0000   /XXXXXX|
|XXXXX\ -|      --XXXXXXX          0000          |
|XXXXXXX\          -XXXXX000000000000000000000000|
|XXXXXXX/          -XXXXX000000000000000000000000|
|XXXXX/ -|      --XXXXXXX          0000          |
|XXXXX-XX| /XX- \XXXXXXXXXXXXXX/   0000  \\XXXXXX|
|XXXXXXXX|/XXXXX-\XXXXXXXXXXXX/    0000  0\\XXXXX|
|XXXXXXXXXXXXXXXXXXXXXXXXXXXX/  /  0000  \0\\XXXX|
|XXXXXXXXXXXXXXXXXXXXXXXXXXX/  /0  0000   \0\\XXX|
|XXXXXXXXXXXXXXXXXXXXXXXXXX/  /0/  0000    \0\\XX|
|XXXXXXXXXXXXXXXXXXXXXXXXX/  /0//  0000  \  \0\\X|
|XXXX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XX|
|XXXXXXXXXXXXXXXXXXXXXXXXXXXX|\/|XXXXXXXXXXXXXXXX|
|XXXXXXXXXXXXXXXXXXXXXXXXXXX>    >XXXXXXXXXXXXXXX|
|XXXXXXXXXXXXXXXXXXXXXXXXXXXX|/\|XXXXXXXXXXXXXXXX|
|XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX|
|XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX|
|XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX|
|XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX|

Things to watch out for: there is a space at the end of the first line. No other trailing spaces are allowed. The dimensions are 50 x 49 (48 x 48 plus borders on three sides).The fifth star (5-pointed) in the Southern Cross is slightly smaller and a different design from the others (7-pointed). A trailing newline is allowed but not required.

My code editor has a thumbnail view of the code at the side. This is what this design looks like:

Thumbnail of ASCII-Art Australian Flag

Not bad!

\$\endgroup\$
  • 9
    \$\begingroup\$ At this rate, we are gonna need a flag tag! \$\endgroup\$ – Fatalize Jul 6 '15 at 8:25
  • 6
    \$\begingroup\$ Someone will finally want to print the Libya flag from 1977 to 2011. \$\endgroup\$ – jimmy23013 Jul 6 '15 at 11:27
  • 2
    \$\begingroup\$ I know this is the third flag question in three days, but this flag is a lot more difficult to compress than the previous ones. The OP's ASCII art skills alone deserve an upvote. \$\endgroup\$ – Dennis Jul 6 '15 at 14:53
  • 1
    \$\begingroup\$ @AlexA. I'd say it's more like the British version of Texas. But with more terrifying animals. =D \$\endgroup\$ – DJMcMayhem Jul 6 '15 at 17:45
  • 1
    \$\begingroup\$ We have Queens-land, Victoria and New South Wales and we speak English (as do Americans, arguably ;-P) but we haven't been British for a long time! \$\endgroup\$ – CJ Dennis Jul 7 '15 at 4:46
2
\$\begingroup\$

Python 2, 446 Bytes

Just decodes the Base64 and decompresses using zlib.

import zlib,base64
print zlib.decompress(base64.b64decode("eNrl1MFtwzAMBdCeMwUXEOgJPIcPBLqIhk8ofkq2QdFQb215iZDkgdSXZfpeLHrVY1JCJPpJtH2KSNfMG9c52WBORAUlRL7MDNJESsT6dGIiG8yNE4gjIzCdmMiJGyMQDwQGXUycSW2ncBS+GScQnZTPUhMtxPc+neAXJ0KlUqtS8Gfq5V2sxmAyvjS0TWoQXiW8PljbPuv25bp97kTkun1dWiJF7sKPEubhKLmdILrA5ETFOEqYlDCeRd++mYyYGIPBJARiXDGYhECcLrKZjJg4vy6ayQYzcXkpqXk4l6j+C6nCdY3s+ljti11Y6q9MbBJPEJ+TWTxBfKNLHE8Q32wvyZQx2bMpZ12k/jTkKMechDk+dQly/FMX+Q3ohQN5"))
\$\endgroup\$
2
\$\begingroup\$

dash, 261 bytes

0000000: 7a6361743c3c27270a1f8b0801010101010203e5d3c98d04  zcat<<''................
0000018: 410844d1fb58110ea4480bda0e0e48e308bef7fad5cc4a89  A.D..X...H....H.......J.
0000030: db2c717f0944a9f43a8c5ed2bf4948e1d748fb1ac9af31db  .,q..D..:.^..IH..H....1.
0000048: 96df938d8108a186040622444b3010210cd2198810de110c  .........."DK0.!........
0000060: 44889e6020889e602088b724c36f59f6c140847892e59e0a  D..` ..` ..$.oY..@.x....
0000078: f725441908a24868a5ee59cb1f118110be0be89907dadfa4  .%D...Hh..Y.............
0000090: 884d894d17e37c735f0a440d8744d4f924ed81cb20201bd3  .M.M..|s_.D..D..$...  ..
00000a8: 7c4a844114184823360403698541309056d4621848235c10  |J.A..H#6..i.A0.V.b.H#\.
00000c0: c734045104d31044114c431045309049fe0bc9b09c919324  .4.Q...D.LC.E0.I.......$
00000d8: 9d86532cf25736463dc7f541aa9ee3fa20554f5f5f7b8be5  ..S,.W6F=..A.... UO__{..
00000f0: f0fc135b8c1a8be3297d4f03424f13424f7ff847be        ...[....)}O.BO.BO..G.

It should be possible to beat this score with manual compression and a terse language, but if your going to use a widely available compressor (and don't think you can get away with calling zcat a non-Turing complete programming language), dash is probably the best option.

I chose zopfli as the compressor since it is compatible with the Coreutils program zcat and achieves better compression than gzip, bzip2 and xz.

Note that zcat will print a warning to STDERR, which is allowed by default per consensus on Meta.

Testing

This is how I created and tested the program:

$ echo "zcat<<''" > flag.sh
$ git clone https://github.com/google/zopfli.git
$ make -C zopfli
$ zopfli/zopfli -c --i100000 flag.txt >> flag.gz
$ head -c 252 flag.gz | tr \\000 \\001 >> flag.sh
$ dash flag.sh 2>&- | md5sum - flag.txt
168400d97bf59ebff194a6d13495cc26  -
168400d97bf59ebff194a6d13495cc26  flag.txt

Head strips the last 9 bytes from the gzip file, which aren't required for successful decompression.

Fortunately, the gzip file only contains NUL bytes in its header, which can be replaced with SOH bytes without affecting the output.

\$\endgroup\$
2
\$\begingroup\$

CJam, 250 246 231 bytes

S'_48*S"0H:+-86:0@6CEM00":i~'X*a*["3|\5-/2-2| \2- /3\ -| 0--4\00-"6,_s\'Xf*0S5*ter
sE/_W%{"\/"_W%er}:R%+"X|\/|X>  "_W%+6/___"XX/|X>   >XX\|"5/C,'X6*"//0/  /"+2*f>8f<
_2>\W%2>.{R" 00 ":_@}" 0 0"[A4A24].*+s_W%+24/]{..e&fm>m<}/{N'|@'|}/

The linefeeds are purely cosmetic and do not contribute to the byte count.

Try it online in the CJam interpreter.

Idea

We start by pushing the background of the flag, i.e., 48 strings of 48 X's each.

Now, we generate all 7 foreground images, i.e., the different types of stars and the miniature British flag.

"3|\5-/2-2| \2- /3\ -| 0--4\00-"

encodes the big star. After replacing each positive number with that many X's, each 0 with a string of 5 spaces and splitting the result into chunks of length 14, we obtain the following:

XXX|\XXXXX-/XX
-XX| \XX- /XXX
\ -|      --XX
XX\          -

If we repeat these strings, in reversed order, and swap the slashes, we obtain the desired big star:

XXX|\XXXXX-/XX
-XX| \XX- /XXX
\ -|      --XX
XX\          -
XX/          -
/ -|      --XX
-XX| /XX- \XXX
XXX|/XXXXX-\XX

For the middle star, we simply push the string "X|\/|X> ", concatenate it with a reversed copy of itself and chop the result into strings of length 6:

X|\/|X
>    >
X|/\|X

Now, we push the small star as "XX/|X> >XX\|" chopped into strings of length 5:

XX/|X
>   >
XX\|

(The missing X doesn't matter since the background already contains it.)

Finally, we push the small flag, using almost exactly the same approach as in Print the British Flag!

Now that we have all parts, we start to assemble them. By using twofold vectorized logical AND on the background and the big star, we can replace each truthy character of the background (and all are truthy) by the corresponding character of the big star.

We now rotate the array of strings, and the strings themselves as well, so that the first middle star should be in the upper left corner, then repeat the process from the last paragraph to incorporate this star.

In the same fashion, we paint the remaining stars and the small flag over the background.

After assembling all parts, we only have to add the vertical bars, linefeeds and underscores.

Code

S'_48*S  e# Push a space, a string of 48 underscores and another space.

"0H:+-86:0@6CEM00"

:i~      e# Cast each char to int and dump.
         e# This pushes 48 72 58 43 45 56 54 58 48 64 54 67 69 77 48 48.
         e# All but the last two integers are rotation amounts.
'X*      e# Push a string of 48 X's.
a*       e# Wrap 48 copies of that string in an array.
[        e#

  "3|\5-/2-2| \2- /3\ -| 0--4\00-"

  6,_s   e#   Push [0 1 2 3 4 5] and "012345".
  \'Xf*  e#   Replace the array with ["" "X" "XX" ... "XXXXX"].
  0S5*t  e#   Replace "" with "     ".
  er     e#   Perform transliteration.
  sE/    e#   Flatten and chop into chunks of length 14.
  _W%    e#   Copy and reverse the order of the chunks.
  {      e#   Define a function:
    "\/" e#     Push that string.
    _W%  e#     Push a reversed copy.
    er   e#     Perform transliteration.
  }:R%   e#   Save in R and map over the second array of chunks.
  +      e#   Concatenate.

  "X|\/|X>  "

  _W%    e#   Push a reversed copy.
  +6/    e#   Concatenate and chop into chunks of length 6.
  ___    e#   Copy the resulting array three more times.

  "XX/|X>   >XX\|"

  5/     e#   Split into chunks of length 5.

  C,'X6*"//0/  /"+2*f>8f<_2>\W%2>.{R" 00 ":_@}" 0 0"[A4A24].*+s_W%+24/

         e#   https://codegolf.stackexchange.com/a/52662
]

{        e# For each array of strings in the preceding array of arrays:
  ..e&   e#   Perform twofold vectorized logical AND.
  fm>    e#   Pop an integer from the stack and rotate each string that many
         e#   units to the right.
  m<     e#   Pop an integer from the stack and rotate the array of strings
         e#   that many units to the left/strings up.
}/       e#

{        e# For each string in the resulting array:
  N'|    e#   Push a linefeed and a vertical bar.
  @      e#   Rotate the string on top of them.
  '|     e#   Push an additional vertical bar.
}/       e#
\$\endgroup\$
1
\$\begingroup\$

Python 2 - 1258 bytes

import zlib
v=len
l=zlib.decompress("x\x9c\x95\x94I\x12\x83 \x10E\xaf\xc2\x05,F\xd1l<\x87\x0b\xaar\x11\x0f\x1f\t44\x9fv\xe1\"\xd5\x08y\xbfG\x08\xbb\xfaZ\xa5\xd4\xfd\xbb\\P\xe7m\x93+\xdf)(u\xe6\xf5mM\xb5\xf9[\xdfg\xc6\x16{1\xcep\xd6\x03\xebgV\x01\x9fP\xc3\x81\x86\x03\r\x07\x1aN\xd0\xb0\xa0ae\x8d\x9e\xcb*\xeb@\x1c\x12\x7f6\x8d8j\x84\xd1\xff\xc4:\xcen#\xebGv\xe0<\xe7\xf69n\xee\x93l`\xcc\xde\xd7i-\xeb\xe5\x1f\x9f\xebZ\xa4\x13*\xbf2\x9e\x18\x16\x7f\xeb[\xd5*\xf9\xd6\xde\x90\x96\xaf\xfbq\xd6J\x95\xc9\xec\x15K\xad\x97-\x9f\x99\xc2fK\xccFL\xd9[\xb2\xc6=\x07\x06\xce\xf5\xd3\xf9J\xe7/|>\xe4\xac!\xe7d\xcbLk?\xceM\x8ar\xfd5\xab\x7f\xca\xf5\xaf\xbd\x1az\xefz\x9fZ\xcfa\x8e\xf8\xff\xa9\x7f)\xc0|\xc1\xdc\x1a\xe8K\xe3<\xcc4r\xdcg\x00v\x98\xe9U\xf49\xc5\x8bq\x0fw*\xc8\x1a\xd2\xfd~\xd0\xe2\xef\x04\xc61\xbd3\xa8aA\xc3\x82\x86\xf4\xde\t\x1aC.\xc4J\xef,\xb0\x7f.\xec\xbd\x1eo\xd7\xb5\x07W\xd5+\xef\xddg\xaa\xefQ\xfbxX\x99\xd5-\x9e\xcf;\xffl\xee\x9b\x7f\xb7\xcf{\xc2\x9b\xd0b\xaa3\xd8\xbe\xf9]`\\\x8b\x91\xe9\xb7=\xae\xefl\xeb\x03\xcf\x91r;<\xf9\r\x13\x93\x90\x91r\xb1q\xbaw\xbd\xbe2\xdb\xeb\x1b\xdf\xd5\x97\xd6?\xd9\xaczF")
n=''.join([i[-1]*int(i[:v(i)-1].replace(' ',''))for i in[l[i:i+4]for i in range(0,v(l),4)]])
print''.join(n[i]if(i+2)%50 else n[i]+'\n'for i in range(v(n)))

I decided to encode the flag using run length encoding, then compressed it using zlib. In the program, it just decodes all of this and prints it to the console.

\$\endgroup\$
  • 1
    \$\begingroup\$ You have 232 occurrences of "\x"! That accounts for just under half of your data! \$\endgroup\$ – CJ Dennis Jul 6 '15 at 13:16
  • \$\begingroup\$ @CJDennis Haha that's just the printable version. That comes to over 1270 bytes \$\endgroup\$ – Beta Decay Jul 6 '15 at 13:20
  • \$\begingroup\$ So why only 12 bytes difference? \$\endgroup\$ – CJ Dennis Jul 6 '15 at 13:22
  • \$\begingroup\$ @CJDennis No idea :/ \$\endgroup\$ – Beta Decay Jul 6 '15 at 13:23
  • \$\begingroup\$ Could the downvoter care to explain him/herself? :| \$\endgroup\$ – Beta Decay Jul 6 '15 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.