10
\$\begingroup\$

Inspired by Print the American Flag! this is a direct copy but with the British flag as it has some symmetries but is still quite complex!

Your challenge is to produce the following ASCII-Art in as few bytes as possible! Turn your head/screen (not both!) by 90 degrees to view it properly.

 __________________________________________ 
|\  \XXXXXXXXXXXX  000000  XXXXXXXXXXXX//0/|
|0\  \XXXXXXXXXXX  000000  XXXXXXXXXXX//0/ |
|\0\  \XXXXXXXXXX  000000  XXXXXXXXXX//0/  |
|\\0\  \XXXXXXXXX  000000  XXXXXXXXX//0/  /|
|X\\0\  \XXXXXXXX  000000  XXXXXXXX//0/  /X|
|XX\\0\  \XXXXXXX  000000  XXXXXXX//0/  /XX|
|XXX\\0\  \XXXXXX  000000  XXXXXX//0/  /XXX|
|XXXX\\0\  \XXXXX  000000  XXXXX//0/  /XXXX|
|XXXXX\\0\  \XXXX  000000  XXXX//0/  /XXXXX|
|XXXXXX\\0\  \XXX  000000  XXX//0/  /XXXXXX|
|XXXXXXX\\0\  \XX  000000  XX//0/  /XXXXXXX|
|XXXXXXXX\\0\  \X  000000  X//0/  /XXXXXXXX|
|XXXXXXXXX\\0\  \  000000  //0/  /XXXXXXXXX|
|XXXXXXXXXX\\0\    000000  /0/  /XXXXXXXXXX|
|XXXXXXXXXXX\\0\   000000  0/  /XXXXXXXXXXX|
|XXXXXXXXXXXX\\0\  000000  /  /XXXXXXXXXXXX|
|XXXXXXXXXXXXX\\0  000000    /XXXXXXXXXXXXX|
|XXXXXXXXXXXXXX\\  000000   /XXXXXXXXXXXXXX|
|                  000000                  |
|000000000000000000000000000000000000000000|
|000000000000000000000000000000000000000000|
|000000000000000000000000000000000000000000|
|                  000000                  |
|XXXXXXXXXXXXXX/   000000  \\XXXXXXXXXXXXXX|
|XXXXXXXXXXXXX/    000000  0\\XXXXXXXXXXXXX|
|XXXXXXXXXXXX/  /  000000  \0\\XXXXXXXXXXXX|
|XXXXXXXXXXX/  /0  000000   \0\\XXXXXXXXXXX|
|XXXXXXXXXX/  /0/  000000    \0\\XXXXXXXXXX|
|XXXXXXXXX/  /0//  000000  \  \0\\XXXXXXXXX|
|XXXXXXXX/  /0//X  000000  X\  \0\\XXXXXXXX|
|XXXXXXX/  /0//XX  000000  XX\  \0\\XXXXXXX|
|XXXXXX/  /0//XXX  000000  XXX\  \0\\XXXXXX|
|XXXXX/  /0//XXXX  000000  XXXX\  \0\\XXXXX|
|XXXX/  /0//XXXXX  000000  XXXXX\  \0\\XXXX|
|XXX/  /0//XXXXXX  000000  XXXXXX\  \0\\XXX|
|XX/  /0//XXXXXXX  000000  XXXXXXX\  \0\\XX|
|X/  /0//XXXXXXXX  000000  XXXXXXXX\  \0\\X|
|/  /0//XXXXXXXXX  000000  XXXXXXXXX\  \0\\|
|  /0//XXXXXXXXXX  000000  XXXXXXXXXX\  \0\|
| /0//XXXXXXXXXXX  000000  XXXXXXXXXXX\  \0|
|/0//XXXXXXXXXXXX__000000__XXXXXXXXXXXX\__\|

The block is 44 x 42 characters. Note that the first line ends with a single space! No other trailing spaces are allowed but a trailing new line is allowed on the last line.

I'm not aware of any date significance for the UK at the moment!

\$\endgroup\$
8
  • 21
    \$\begingroup\$ As a frenchman, my honor prevents me from doing this challenge \$\endgroup\$
    – Fatalize
    Commented Jul 5, 2015 at 17:20
  • 3
    \$\begingroup\$ @Fatalize I'll post a French Flag challenge for Bastille Day but you'll have to get the colours right! \$\endgroup\$
    – CJ Dennis
    Commented Jul 5, 2015 at 17:22
  • 3
    \$\begingroup\$ Newton's Principia Mathematica was published July 5, 1687, but I'm not sure if that counts. On the one hand it was under the Julian calendar; on the other hand our entire date system is more or less arbitrary anyway, so if it's called the same day, why not celebrate it? \$\endgroup\$
    – lirtosiast
    Commented Jul 5, 2015 at 17:22
  • 1
    \$\begingroup\$ @ThomasKwa Well, Princess Charlotte has been christened today, but I think Newton's achievement is more significant. Today is Independence Day for Algeria, Cape Verde and Venezuela, all of which have stars in their flags. \$\endgroup\$ Commented Jul 5, 2015 at 18:55
  • 9
    \$\begingroup\$ @Fatalize Here's a French flag for you in accordance with the colour scheme of this challenge: X 0. I hope that small token helps you to overcome your objections. \$\endgroup\$ Commented Jul 5, 2015 at 20:33

8 Answers 8

10
\$\begingroup\$

SpecBAS - 1137 bytes

Absolutely no hope of winning on characters, but the output is in colour...

1 PAPER 15: CLS 
2 PRINT AT 1,2;("_"*42): FOR y=2 TO 42: PRINT AT y,1;"|";AT y,44;"|": NEXT y
3 FOR y=4 TO 18: PRINT AT y,y-2;"\";AT y+1,y-2;"\": NEXT y: PRINT AT 19,17;"\"
4 FOR y=2 TO 14: PRINT AT y,y;"\  \";AT y+28,y+26;"\  \": NEXT y: FOR y=15 TO 17: PRINT AT y,y;"\";AT y+12,y+13;"\": NEXT y
5 FOR y=25 TO 39: PRINT AT y,y+3;"\\": NEXT y: PRINT AT 40,43;"\"
6 FOR y=2 TO 14: PRINT AT y,42-y;"/";AT y+1,42-y;"/": NEXT y: PRINT AT 2,41;"/"
7 FOR y=2 TO 17: PRINT AT y,45-y;"/";AT y+3,45-y;"/": NEXT y
8 FOR y=2 TO 16: PRINT AT y+23,18-y;"/";AT y+26,18-y;"/": NEXT y: PRINT AT 27,17;"/"
9 FOR y=1 TO 13: PRINT AT y+29,17-y;"//": NEXT y: PRINT AT 29,17;"/"
10 PRINT AT 42,18;"__";AT 42,26;"__";AT 42,41;"__"
11 INK 2
12 FOR y=2 TO 42: PRINT AT y,20;"0"*6: NEXT y
13 FOR y=21 TO 23: PRINT AT y,2;"0"*42: NEXT y
14 FOR y=3 TO 18: PRINT AT y,y-1;"0";AT y+23,y+25;"0": NEXT y
15 FOR y=2 TO 16: PRINT AT y,44-y;"0";AT y+26,19-y;"0": NEXT y
16 INK 1
17 FOR y=2 TO 13: LET l$="x"*(14-y): PRINT AT y,4+y;l$;AT y,28;l$;AT 44-y,4+y;l$;AT 44-y,28;l$: NEXT y
18 FOR y=6 TO 19: LET l$="x"*(y-5): PRINT AT y,2;l$;AT y,49-y;l$;AT 44-y,2;l$;AT 44-y,44-LEN l$;l$: NEXT y

enter image description here

\$\endgroup\$
4
  • \$\begingroup\$ How short is it without colour? \$\endgroup\$
    – Beta Decay
    Commented Jul 6, 2015 at 16:10
  • \$\begingroup\$ 12 characters less (the INK statements). Considering this is already 1000+ characters more than most entries, I'm not going to quibble about them. :-) \$\endgroup\$
    – Brian
    Commented Jul 6, 2015 at 16:12
  • 1
    \$\begingroup\$ Haha you know you could probably get this a lot shorter in BBC BASIC \$\endgroup\$
    – Beta Decay
    Commented Jul 6, 2015 at 16:19
  • \$\begingroup\$ I count 1554 bytes \$\endgroup\$ Commented Aug 25, 2016 at 14:12
4
\$\begingroup\$

Python 2, 223 bytes

o=""
x="X"*15
s=x+r"\  \0\\%s//0/  /"%x
exec'o+="|%s  000000  %s|\\n"%(s[18:2:-1],s[25:41]);s=s[1:]+s[0];'*18
print" "+"_"*42+" \n"+o+"\n".join("|%s000000%s|"%(c*18,c*18)for c in" 000 ")+o[:43:-1]+o[43::-1].replace(" ","_")

Still much to golf.

Despite its looks, the back half is the same as the front half reversed (barring the underscores), which is unusually nice for a pattern with slashes.

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

Python 3 361 331

p=print
p("","_"*42,"")
r='|'
w="X"*16
s="\\  \\0\\\\"
z="//0/  /"
O=" 000000 "
m=r+" "*18+"0"*3
o=w+s+w
e=w+z+w
T=e[::-1]
f=o[::-1]
R=range(18)
for i in R:p(r+o[i+19:i+3:-1],O,e[i+4:i+20]+r)
B="p(m+m[::-1]);"
exec(B+"p(r+'0'*42+r);"*3+B)
for i in R[1:]:p(r+T[i+1:i+17],O,f[i+16:i:-1]+r)
p(r+T[19:35]+"__000000__"+o[4:17]+"__\\|")

This program makes use of python's awesome string slicing capabilities to create a string that represents the stripes:

o = "XXXXXXXXXXXXXXX\  \0\\XXXXXXXXXXXXXXX" 

Then repeatedly print it backwards while shifting it to the right by increasing the start and end of the string slice to get this:

\  \XXXXXXXXXXX
0\  \XXXXXXXXXX
\0\  \XXXXXXXXX
\\0\  \XXXXXXXX
X\\0\  \XXXXXXX
XX\\0\  \XXXXXX
XXX\\0\  \XXXXX
XXXX\\0\  \XXXX
XXXXX\\0\  \XXX
XXXXXX\\0\  \XX
XXXXXXX\\0\  \X
XXXXXXXX\\0\  \
XXXXXXXXX\\0\  
XXXXXXXXXX\\0\ 
XXXXXXXXXXX\\0\  
XXXXXXXXXXXX\\0  
XXXXXXXXXXXXX\\ 

This is the top left corner.

I repeat this four times with variants on the original string (like reversing the bit in the middle) to get the other four corners.

\$\endgroup\$
5
  • \$\begingroup\$ @Sp3000 Is that better? \$\endgroup\$
    – DJMcMayhem
    Commented Jul 6, 2015 at 16:05
  • \$\begingroup\$ Now I think it's a tad too thin \$\endgroup\$
    – Sp3000
    Commented Jul 6, 2015 at 16:16
  • \$\begingroup\$ btw I think you overaliased - for 2 chars (e.g. -1, 17) you need to use it six times before you save anything \$\endgroup\$
    – Sp3000
    Commented Jul 6, 2015 at 16:21
  • \$\begingroup\$ @Sp3000 you're right, I thought that would save 2 each. \$\endgroup\$
    – DJMcMayhem
    Commented Jul 6, 2015 at 16:24
  • \$\begingroup\$ btw there's also a trailing space on the first line, which I don't think you print \$\endgroup\$
    – Sp3000
    Commented Jul 6, 2015 at 16:40
2
\$\begingroup\$

CJam, 131 126 102 99 bytes

S'_42*SK,'XE*"//0/  /"+2*f>Gf<_2>
\W%2>.{"\/"_W%er" 000 ":_@}" 0 0"
[I6I63].*+s_W%+42/{N"||"@*}/S'_er

The two linefeeds are included to prevent horizontal scrolling. Try it online in the CJam interpreter.

Idea

We start by modifying the string

XXXXXXXXXXXXXX//0/  /XXXXXXXXXXXXXX

by pushing 19 copies, discarding the first n characters for the nth copy and cutting off each results after the 16th character.

XXXXXXXXXXXXXX//
XXXXXXXXXXXXX//0
XXXXXXXXXXXX//0/
XXXXXXXXXXX//0/ 
XXXXXXXXXX//0/  
XXXXXXXXX//0/  /
XXXXXXXX//0/  /X
XXXXXXX//0/  /XX
XXXXXX//0/  /XXX
XXXXX//0/  /XXXX
XXXX//0/  /XXXXX
XXX//0/  /XXXXXX
XX//0/  /XXXXXXX
X//0/  /XXXXXXXX
//0/  /XXXXXXXXX
/0/  /XXXXXXXXXX
0/  /XXXXXXXXXXX
/  /XXXXXXXXXXXX
  /XXXXXXXXXXXXX
 /XXXXXXXXXXXXXX

By discarding the first two strings, we obtain the upper right quadrant of the flag.

Now, if we reverse the order of the strings, once again discard the first two and swap the inclinations of the slashes, we obtain the upper left quadrant.

By concatenating the corresponding strings, with " 000000 " in the middle and appending a few runs of spaces and zeroes, we obtain

\  \XXXXXXXXXXXX  000000  XXXXXXXXXXXX//0/
0\  \XXXXXXXXXXX  000000  XXXXXXXXXXX//0/ 
\0\  \XXXXXXXXXX  000000  XXXXXXXXXX//0/  
\\0\  \XXXXXXXXX  000000  XXXXXXXXX//0/  /
X\\0\  \XXXXXXXX  000000  XXXXXXXX//0/  /X
XX\\0\  \XXXXXXX  000000  XXXXXXX//0/  /XX
XXX\\0\  \XXXXXX  000000  XXXXXX//0/  /XXX
XXXX\\0\  \XXXXX  000000  XXXXX//0/  /XXXX
XXXXX\\0\  \XXXX  000000  XXXX//0/  /XXXXX
XXXXXX\\0\  \XXX  000000  XXX//0/  /XXXXXX
XXXXXXX\\0\  \XX  000000  XX//0/  /XXXXXXX
XXXXXXXX\\0\  \X  000000  X//0/  /XXXXXXXX
XXXXXXXXX\\0\  \  000000  //0/  /XXXXXXXXX
XXXXXXXXXX\\0\    000000  /0/  /XXXXXXXXXX
XXXXXXXXXXX\\0\   000000  0/  /XXXXXXXXXXX
XXXXXXXXXXXX\\0\  000000  /  /XXXXXXXXXXXX
XXXXXXXXXXXXX\\0  000000    /XXXXXXXXXXXXX
XXXXXXXXXXXXXX\\  000000   /XXXXXXXXXXXXXX
                  000000                  
000000000000000000000000000000000000000000
000000000000000000000

The second half of the flag contains almost exactly the same character, in inverted reading order (right to left, bottom to top).

All that's left to do to complete the entire flag is to push the first line, replace spaces with underscores in the last and introducing the vertical bars and actual linefeeds.

Code

S'_42*S   e# Push a space, a string of 42 underscores and another space.
K,        e# Push [0 ... 19].
'XE*      e# Push a string of 14 X's.
"//0/  /" e# Push that string.
+2*       e# Concatenate and repeat the result twice.
f>        e# Push copies with 0, ..., 19 character removed from the left.
Gf<       e# Truncate each result after 16 characters.
_2>       e# Copy the array and discard its first two elements.
\W%2>     e# Reverse the original array and discard its first two elements.

.{        e# For each pair of corresponding strings in the arrays:
  "\/"    e#   Push "\/".
  _W%     e#   Reverse a copy to push "/\\".
  er      e#   Perform transliteration on the string from the right array..
  " 000 " e#   Push that string.
  :_      e#   Duplicate each charcter to push "  000000  ".
  @       e#   Rotate the string from the left array on top.
}         e#

" 0 0"    e# Push that string.
[I6I63]   e# Push [18 6 18 63].
.*        e# Vectorized repetition.
+s        e# Concatenate ad flatten.
_W%+      e# Push a reversed copy and concatenate.
42/       e# Split into chunks of length 42.
{         e# For each chunk:
  N       e#   Push a linefeed.
  "||"@*  e#   Join the string "||", using the chunk as separator.
}/        e#
S'_er     e# Replace spaces with underscores in the last string.
\$\endgroup\$
0
1
\$\begingroup\$

Javascript ES6, 726 725 655 647 643 bytes

a="__";l=" ";b=l+l;c=`|
|`;d="X";e="0";f=b+e[r="repeat"](6)+b;g="\\  \\";h="//0/";i="/  /";Z="\\";A=Z+Z;j=A+0;k=d[r].bind(d);y=c+l[r](16)+f+l[r](16);z=c+e[r](42);B="/";C="\\0";D="0//";E=B+D;q=n=>k(n)+f+k(n);F=n=>g+q(n)+h;G=n=>c+k(n)+j+F(9-n)+k(3+n);H=n=>A+k(n+1)+c+k(n);I=n=>q(n)+g+e+H(8-n)+i+D;console.log(l+a[r](21)+` 
|`+F(12)+c+e+F(11)+d+c+C+F(10)+d+d+c+j+F(9)+k(3)+c+d+j+F(8)+k(4)+G(2)+G(3)+G(4)+G(5)+G(6)+G(7)+G(8)+y+z+z+z+y+c+k(14)+B+l+f+H(13)+B+b+f+e+H(12)+i+f+C+H(11)+i+e+f+l+C+H(10)+i+"0/"+f+b+C+H(9)+i+D+I(0)+I(1)+I(2)+I(3)+I(4)+I(5)+I(6)+I(7)+I(8)+q(9)+g+e+A+c+b+E+q(10)+g+e+Z+c+l+E+q(11)+g+e+c+E+k(12)+a+e[r](6)+a+k(12)+Z+a+Z+"|")
\$\endgroup\$
2
  • 2
    \$\begingroup\$ You're using ES6, why not fat-arrow functions? \$\endgroup\$
    – Downgoat
    Commented Jul 6, 2015 at 2:03
  • 1
    \$\begingroup\$ Also, template strings can cut of about two bytes for \n \$\endgroup\$
    – Downgoat
    Commented Jul 7, 2015 at 6:04
1
\$\begingroup\$

PHP, 240 bytes

 <?=str_pad(_,42,_)." ";for($o=18;$o--;)$r.="
".($s="|".substr("XXXXXXXXXXXXXX\\\\0\  \\XXXXXXXXXXXX//0/",$o,16)."  000").($v=strrev)(strtr($s,"\\","/"));echo$r;for(;$i<5;)echo"
",$s=str_pad("|",19,$i++%4?0:" ")."000",$v($s);echo"
",$v($r);

Note the space before the opening tag! Try it online.

\$\endgroup\$
0
\$\begingroup\$

SpecBAS again - 507 Bytes

Here's a similar version to Brian's above (I don't have enough reputation to comment yet) but without the colour. It uses a very different method to generate the display.

10 DEF FN rr$(r$)=r$(2 TO)+r$(1): DEF FN rl$(r$)=r$(LEN r$)+r$( TO LEN r$-1)
20 a$="\  \"+"x"*14+"\\0",b$="x"*12+"//0/  /xx",c$="x"*14+"/  /0//",d$="\\"+"x"*14+"\  \0",e$="  000000  ": ?" ";"_"*42: DO 18: ?"|";a$( TO 16);e$;b$( TO 16);"|": a$=FN rl$(a$),b$=FN rr$(b$): LOOP: ?"|";TAB 17;e$;TAB 43;"|"'("|"+("0"*42)+"|"+#13)*3;"|";TAB 17;e$;TAB 43;"|": DO 18: ?"|";c$( TO 16);e$;d$( TO 16);"|": c$=FN rr$(c$),d$=FN rl$(d$): LOOP: ?#11;TAB 17;"__";TAB 25;"__";TAB 40;"__"
\$\endgroup\$
0
\$\begingroup\$

Bubblegum, 213 bytes

00000000: b5d3 0106 4421 1080 6100 de29 e606 759c  ....D!..a..)..u.
00000010: 105d a4c3 6fdb 461f 030f f607 f019 994c  .]..o.F........L
00000020: 8cd7 c533 7b44 6f14 5177 118d 4aa9 653e  ...3{Do.Qw..J.e>
00000030: b3a2 13d6 c6c2 1d9d b076 6375 c2d8 b270  .........vcu...p
00000040: 5327 8c6d 5fac 4e18 bbb1 3a61 ecc1 6ab1  S'.m_.N...:a..j.
00000050: f662 b518 0b46 83b1 6034 180b 5683 b162  .b...F..`4..V..b
00000060: f5c5 58b1 1a8c 05a3 c158 b1fa 62ac 587d  ..X......X..b.X}
00000070: 3156 ac06 630f 8ed4 c1a9 85eb ebfe 8adf  1V..c...........
00000080: bf39 6da3 803b 67cc eab0 e08a 0663 0b93  .9m..;g......c..
00000090: d160 2c3f 8806 6b99 8c06 6bc1 1d0d c67a  .`,?..k...k....z
000000a0: 2968 3056 8c06 63c5 6830 568c 0663 c5e8  )h0V..c.h0V..c..
000000b0: 8bb5 62f5 c1d8 8cd1 1b6b 3346 2fac cd58  ..b......k3F/..X
000000c0: bdb0 3663 f4c6 da8c d10b 6f4b 63fc f018  ..6c......oKc...
000000d0: 4d3d 469f 1f                             M=F..

Try it online!

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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