# Triforce ReBoot [closed]

Seeing how hello world has backfired terribly, here is a harder one.

I love Zelda and I love ReBoot.

Create the following

Requirements:
It must be a window (can be ANY window even browsers and such).
The window can be of any size.
Window may not contain anything else except the picture.
Window should not close itself right away.
Triangles must be any shade of blue.
Circle must be any shade of green.
Smaller triangle must touch edges of the
No stealing images by providing links.

Condition: Shortest code wins.

PS: Yes ReBoot logo is slightly different but this is close enough to make it fun.

EDIT: I added another requirement. It seems like we have a lot of very genius people who enjoy finding loopholes :P I love you guys.

• "Triangles must be any shade of yellow." Picture conflicts? – Timtech Nov 29 '13 at 14:51
• @Timtech I am sorry, text got underlined as orange due to misspelling and I thought orange while wanting to write blue. – Quillion Nov 29 '13 at 15:02
• Okay, at least it's fixed now. And I'm even trying to get shorter comments - too much code golfing... – Timtech Nov 29 '13 at 15:04
• Do I get bonus points if the image fills the screen, and continues to as I resize the screen? (You have to allow the circle to be an oval then) – Cruncher Nov 29 '13 at 15:21
• Actually reading the requirements again, what's stop someone from just creating the image in paint, and making a program read the image? This would only be a couple of lines in python. Perhaps you should write a rule against that – Cruncher Nov 29 '13 at 15:23

# Mathematica 118 119 118 107 97

Edit: Shortened to 107 chars with help from Belisarius and to 97 with alephalpha.

CreateDialog[Graphics@{Blue,Polygon@Outer[Plus,#,#,1]&@{{0,0},{1,1},{2,0}}, Green,
{2,1}~Circle~1}]


• I was scared you had beat me :3 But that circle's gotta be green! – Timtech Nov 29 '13 at 16:17
• It's green now. Thanks for noting. – DavidC Nov 29 '13 at 16:23
• In 107: p=Polygon;a={1,1};b={2,0};CreateDialog[Graphics@{Blue,p@{0a,2b,2a},White,p@{a,b+a,b},Green,{2,1}~Circle~1}] – Dr. belisarius Nov 29 '13 at 22:36
• CreateDialog[Graphics@{Blue,Polygon@Outer[Plus,#,#,1]&@{{0,0},{1,1},{2,0}},Green,{2,1}~Circle~1}] – alephalpha Nov 30 '13 at 3:44
• I got a little help from my friends. – DavidC Nov 30 '13 at 4:46

## Dyalog APL (121116 115)

(Edit: use triangles 8 elements wide instead of 10, to shorten code a bit)

(Edit 2: I was only ever using M¨, so included the ¨ in the definition of M)

M←{' ',⍵,⍺,⍨4/0}¨⋄⎕SM←↑(256M⊃,/(⊂8 0)(⊂8 32)(⊂0 16)∘.+⊂(,⍳⍴Z)/⍨≤/¨,Z←⊖Z,⌽Z←2/⍳2/8),512M⌈0 16∘+¨1 2∘×¨8+8×1 2∘○¨⍳1e4


Graphics? Who needs graphics?

(Also, black is the default background, you didn't say to change it)

# Shell script: 166 163 characters

f=-fill
d=-draw
convert -size 64x32 xc: $f blue$d 'polygon 32,0 0,32 64,32' $f white$d 'polygon 32,32 16,16 48,16' $f none -stroke lime$d 'circle 32,16 32,0' x:


Sample output:

• this is more of imagemagick than shell – mniip Dec 9 '13 at 13:25
• @mniip, right. But as ImageMagick is primarily a library. If this was a PHP script using IMagick, the post heading would say PHP, not ImageMagick. Well, according to my logic. I am not against any heading improvement. But anyway, 2 of the 3 characters shortening since the first version are on shell side. :) – manatwork Dec 9 '13 at 13:44

# R, 124, 122, 111

frame()
p=polygon
p(c(1,3,5)/5,c(1,3,1)/5,c=4)
p(c(2,4,3)/5,c(2,2,1)/5,c="white")
symbols(.6,.4,.1,i=1,a=T,f=3)


This produces the following picture in a plot window:

• I think you can save one character by writing p=polygon, then p(c(1,3,5 etc. (BTW, on my system, the circle size scales differently than the triangles when the window is resized, and I have to play with it a bit to get the circle to intersect the corners of the "square".) – r.e.s. Dec 2 '13 at 4:57
• @r.e.s. Thanks for the tip. The size of the circle is the major drawback of this solution. I wasn't able to figure out a short code to solve this problem. – Sven Hohenstein Dec 2 '13 at 8:05
• @plannapus Great idea, thanks! This saved 11 characters. – Sven Hohenstein Dec 9 '13 at 16:39

## Java, 434358 349

import java.awt.*;
public class T
{
public static void main(String[] a)
{
new Frame()
{
public void paint(Graphics g)
{
g.setColor(Color.BLUE);
Polygon p=new Polygon(new int[]{50, 75, 100},new int[]{75, 50, 75},3);
g.fillPolygon(p);
p.translate(-25, 25);
g.fillPolygon(p);
p.translate(50, 0);
g.fillPolygon(p);
g.setColor(Color.green);
g.drawOval(50, 50, 50, 50);
}
}.show();
}
}


golfed

import java.awt.*;public class T{public static void main(String[] a){new Frame(){public void paint(Graphics g){g.setColor(Color.BLUE);Polygon p=new Polygon(new int[]{50,75,100},new int[]{75,50,75},3);g.fillPolygon(p);p.translate(-25,25);g.fillPolygon(p);p.translate(50,0);g.fillPolygon(p);g.setColor(Color.green);g.drawOval(50,50,50,50);}}.show();}}


Who knew golfing reduces code so much.

EDIT: Thanks manatwork for all your suggestions.

• Please golf your code. – Kevin Cox Nov 29 '13 at 17:30
• You still have useless spaces after parameter separator commas. And please use code block instead of inline code markup, so scripts like Code Golf UserScript Enhancement Pack can recognize it as code and displays its size. – manatwork Nov 29 '13 at 17:58

## Game Maker Language, 167165 155

EDIT 1 - I shaved off two characters by replacing c_green with 32768, the same value. The other color's values were longer than their predefined names.

EDIT 2 - Epic golf! Used variables for frequently used values, and forgot that newlines aren't needed (newlines count as two spaces).

The room (r) is predefined 64 by 32 with a white background. Object d is anywhere in room r. Draw Event code:

a=16b=32draw_set_color(c_blue)draw_triangle(0,b,64,b,b,0,0)draw_set_color(32768)draw_circle(b,a,a,1)draw_set_color(c_white)draw_triangle(a,a,48,a,b,b,0)


Result:

## Ti84-Basic - 54 characters (but output is black and white)

:Line(0,0,2,0
:Line(0,0,1,1
:Line(2,0,1,1
:Circle(1,.5,.5

• No pictures used! – Timtech Nov 29 '13 at 15:26
• Does the figure appear in its own window? – DavidC Nov 29 '13 at 15:39
• @DavidCarraher Yes. I used in-game screen capture, so the window doesn't show up. – Timtech Nov 29 '13 at 15:40
• You used draw_set_color three times. Can't you save characters by something like d=draw_set_character? – DavidC Nov 29 '13 at 16:42
• @DavidCarraher I tried that already; it doesn't work :( GML gets kind of stubborn sometimes. – Timtech Nov 29 '13 at 16:43

## HTML, 101

<img style=position:absolute;clip:rect(30px,130px,110px,20px) src=http://i.stack.imgur.com/iE6m9.png>

• There's a new requirement - "No stealing images by providing links." – Timtech Nov 29 '13 at 15:39
• I bet you could beat that with a simple: http://someshort.url (... and that this would create another requirement as well) – Olivier Dulac Nov 29 '13 at 18:32

## HTML+CSS, 352290261 257

<div style="width:0;border:50px solid #fff;border-bottom-color:#00f">
<p style="border:25px solid #00f;border-top-color:#fff;border-bottom:0;margin:25px 0 0 -25px">


http://jsfiddle.net/WF3hP/6/

Ungolfed:

<style>
#blue-triangle {
width:0;
border:50px solid #fff;
border-bottom-color:#00f
}
#white-triangle {
border:25px solid #00f;
border-top-color:#fff;
border-bottom:0;
margin:25px 0 0 -25px
}
#circle {
border:1px solid #0f0;
width:50px;
height:50px;
margin:-52px -26px
}
</style>
<div id="blue-triangle">
<p id="white-triangle">
<p id="circle">

• Instead of setting border-left and border-right separately, better set border then reduce the unneeded one like border-top:0: jsfiddle.net/WF3hP/2 – manatwork Nov 29 '13 at 16:41
• Yes, I'd recommend that too. It will make your code shorter. – Timtech Nov 29 '13 at 16:42
• @manatwork, even that can be improved with border-bottom-color instead of border-bottom on the first div and similarly border-top-color on the second div. And using 1em instead of 25px and 2em instead of 50px changes the size but saves a few characters. – Peter Taylor Nov 29 '13 at 16:51
• Thanks, @manatwork & Pete Taylor. I tried using em instead of px, but it's hard to get the circle centred if its border has to be 1px wide. – Danko Durbić Nov 29 '13 at 19:21
• Do the id's really have to be that long? – Timtech Dec 1 '13 at 23:57

## R, 108 characters

Very similar to Sven Hohenstein solution but differs in two interesting points, so I thought I would add it:

frame()
p=polygon
p(c(0:3,1:4)/5,c(0:1,0:1,1:2,1:0)/5,c=4)
t=seq(0,2*pi,.1)
p(.2*cos(t)+.4,.2*sin(t)+.2,b=3)


Instead of drawing a large blue triangle and a small white one, I draw a polygon representing already the three triangles. As for the circle, this one (whose code is clearly longer than Sven's) doesn't lose its contacts with the triangles on resize.
Finally instead of using the color names I used their number in R's default color palette (4 for blue and 3 for green).

### JavaScript (canvas, Firefox), 237 231 characters

<body onload=with(c=document.all.a.getContext('2d'))fillStyle='#00F',strokeStyle='#0F0',mozFillRule='evenodd',c.f=lineTo,moveTo(4,0),f(8,4),f(0,4),f(2,2),f(6,2),f(4,4),f(2,2),fill(),beginPath(),arc(4,2,2,0,7),stroke()><canvas id=a>


I couldn't find any hard requirements on the dimensions, so I decided to abuse that a bit and go with 8×4 pixels to cut down code size... also, relies on the Mozilla extension mozFillRule to get even-odd filling for the triforce.

### SVG 305 296

<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="1 3 9 10">
<path d="M 5,4 2.5,7 7.5,7 5,4 z M 7.5,7 5,10 10,10 7.5,7 z M 5,10 2.5,7 0,10 5,10 z"
fill="#00f" /><path d="m 7.5,7 a 2.5,3 0 0 1 -5,0 2.5,3 0 1 1 5,0 z"
fill="none" stroke="#0f0" stroke-width="0.02" /></svg>


• Instead of style="fill:#00f", you can use fill="#00f", I think. Same for the other styles. – Ry- Nov 30 '13 at 1:15
• @minitech: I must be able to save 5 more bytes in shifting this drawing up by 1: having vertical plan from 2 to 9 instead of 3 to 10... – F. Hauri Dec 3 '13 at 21:54

# HTML 118

<svg><path fill=#00f d="M0,2 2,0 4,2 2,2 3,1 1,1 2,2z"/><circle fill=none stroke-width=.1 stroke=#0f0 cx=2 cy=1 r=1 />


## Sage (CLI), 111 106

p=polygon;circle((2,1),1,color=(0,1,0))+p([(0,0),(2,2),(4,0)])+p([(1,1),(3,1),(2,0)],axes=0,color=(1,1,1))


This is via the Sage command line interface. (This works also in a Sage Notebook, but although the image appears in its own cell, that probably doesn't qualify as a "window".)

EDIT: Eliminated 5 minus signs and replaced the screenshot of a Sage Notebook cell with one of a Sage CLI window. (Credit @boothby)

• If you call .show() on a graphics object from the CLI, it will pop up a window. Also you can save a few characters by shifting everything (+2,+1). – boothby Dec 3 '13 at 18:08
• @boothby - Thanks for the idea to get rid of the minus signs. About the window, it turns out that running the program as-is (without .show()) produces the desired window from the Sage CLI. (Neither this nor the .show() version works when I run Sage under Linux in a virtual machine (Win7/VirtualBox). Works fine when I boot up Ubuntu and run Sage that way.) Thanks for the nudge to try the CLI. – r.e.s. Dec 4 '13 at 2:44

## Golf-Basic 84, 36 characters (Output is Black and White)

l;0,0,2,0l;0,0,1,1l;2,0,1,1c;1,.5,.5