114
\$\begingroup\$

Today is November 8th, 2016, Election Day in the United States of America.

If you are a U.S. citizen eligible to vote, then go out and vote if you haven't already before answering this challenge. Do not discuss who you voted for. It only matters that you voted.

If you are not a U.S. citizen or not eligible to vote, then, before answering this challenge, do the U.S. a favor by telling anyone you know who is an eligible citizen to go out and vote if they haven't already.

Challenge

Write a program that indicates that you voted, like a digital "I Voted" sticker.

It should take no input and must output in a reasonable way the phrase I Voted where the I, o, and e are red (#FF0000) and the V, t, and d are blue (#0000FF). The background must be white (#FFFFFF).

For example:

"I Voted" example graphic

These colors are of course representative of the American flag (though not the official colors). Red comes first simply because it comes first in the common idiom "red white and blue".

To be valid, an answer must:

  • Use the colors specified in the arrangement specified.

  • Use a single legible font and font size. The example uses 72pt Times New Roman bold but any common font above 6pt is probably fine.

  • Have just the phrase I Voted on a single line, capitalized correctly, with a clear space between the two words. It shouldn't look like IVoted.

  • Not indicate who the answerer voted for or supports for president or any down-ballot races. Let's not start any internet debates. This is about celebrating voting, not candidates.

Any reasonable way of displaying or producing the output is valid, such as:

  • Drawing the text to an image that is then displayed, saved, or output raw.

  • Writing the text to a console using color formatting. In this case you may approximate pure red and blue if necessary, and it's ok if only the area directly behind the text can be made white.

  • Displaying the text on a WPF/Windows form.

  • Outputting an HTML/RTF/PDF file with the text.

Please post an image of your output.

The shortest answer in bytes wins.

\$\endgroup\$
  • 29
    \$\begingroup\$ A bit disappointed my actual sticker doesn't look like yours. \$\endgroup\$ – Geobits Nov 8 '16 at 13:52
  • 39
    \$\begingroup\$ "It only matters that you voted." - @HelkaHomba ... That's like saying "it doesn't matter what code you write, as long as you wrote some code." :/ \$\endgroup\$ – Michael Yaeger Nov 8 '16 at 14:05
  • 41
    \$\begingroup\$ @MichaelYaeger Well, writing some code is better than writing none. Voting is better than not voting. Chances are people will put some thought into coding and voting if they choose to do it. But really I said that to help avoid angry debates. \$\endgroup\$ – Calvin's Hobbies Nov 8 '16 at 14:13
  • 43
    \$\begingroup\$ If it helps anyone, vowels are red, consonants are blue. \$\endgroup\$ – mbomb007 Nov 8 '16 at 15:09
  • 34
    \$\begingroup\$ @mbomb007 Or more usefully, the letters with odd code points are red, and the letters with even code points are blue. \$\endgroup\$ – Sp3000 Nov 8 '16 at 15:15

54 Answers 54

114
\$\begingroup\$

Minecraft Chat (vanilla 1.10 client, spigot 1.10 server): 19 bytes

&4I &1V&4o&1t&4e&1d

or from the clientside:

§4I §1V§4o§1t§4e§1d

Minecraft uses a color coding system with these colors programmed in.

enter image description here

Mind the rules:

  • Writing the text to a console using color formatting. In this case you may approximate pure red and blue if necessary, and it's ok if only the area directly behind the text can be made white.

All of these are true, as:
the red and blue ARE approximations (though still very similar).
The background in Minecraft chat is transparent, meaning that it's possible to put this on a white background. (such as an empty world)

\$\endgroup\$
  • 10
    \$\begingroup\$ Wow. I'm speechless. That's a very clever answer! \$\endgroup\$ – DJMcMayhem Nov 8 '16 at 17:58
  • 28
    \$\begingroup\$ I don't think Minecraft Chat is Turing-complete or considered a programming language (although this may no longer be a requirement). Very creative though! :) \$\endgroup\$ – Kade Nov 8 '16 at 17:58
  • 9
    \$\begingroup\$ @Shebang gaming.stackexchange.com/questions/20219/… Minecraft chat has (nearly) all the same commands as command blocks, and certainly all the commands from back when the question was asked :-) \$\endgroup\$ – tuskiomi Nov 8 '16 at 17:59
  • 14
    \$\begingroup\$ Technically, in vanilla Minecraft, the &s should be §s \$\endgroup\$ – Oliver Ni Nov 8 '16 at 23:33
  • 2
    \$\begingroup\$ Hmmm I think it can be done in Quake 3, too \$\endgroup\$ – Sarge Borsch Nov 9 '16 at 8:58
105
\$\begingroup\$

C, 82 80 78 74 54 bytes

Thanks to @WillihamTotland and @criptych for saving 2 bytes each!

f(){puts("␛[47;31mI␛[34m V␛[31mo␛[34mt␛[31me␛[34md");}

Where the ␛s represent 0x1B bytes (escape key). As this code contains unprintable control characters, here is a reversible hexdump:

00000000: 6628 297b 7075 7473 2822 1b5b 3437 3b33  f(){puts(".[47;3
00000010: 316d 491b 5b33 346d 2056 1b5b 3331 6d6f  1mI.[34m V.[31mo
00000020: 1b5b 3334 6d74 1b5b 3331 6d65 1b5b 3334  .[34mt.[31me.[34
00000030: 6d64 2229 3b7d                           md");}

Output on my phone:

\$\endgroup\$
  • 3
    \$\begingroup\$ @KritixiLithos that line defines a as "\x1B[%dm", which is an ANSI escape sequence for coloring, with a placeholder. The numbers in printf() fill those placeholders. \$\endgroup\$ – betseg Nov 8 '16 at 13:49
  • 1
    \$\begingroup\$ Two bytes can be shaved off by replacing a with "\x1B[47;31m" and defining b to "\x1B[34m", then using puts with alternating a and b prefixes. \$\endgroup\$ – Williham Totland Nov 9 '16 at 12:35
  • 3
    \$\begingroup\$ You can save another 2 bytes with "\33" instead of "\x1B". \$\endgroup\$ – criptych Nov 9 '16 at 16:46
  • 1
    \$\begingroup\$ Extending what criptych said, I don't know if this is allowed, but you'd save another four bytes by using a literal escape character instead of \33. Not sure what the C standard thinks of that... \$\endgroup\$ – user61954 Nov 10 '16 at 6:41
  • 3
    \$\begingroup\$ @paxdiablo according to this meta thread, functions are OK for code golf. \$\endgroup\$ – betseg Nov 11 '16 at 4:57
72
\$\begingroup\$

Google Blockly, 10 14 blocks, 28 41 35 blytes

Code

enter image description here

Output

enter image description here

Try it here

Not counting the hide turtle block because it's just aesthetics.

A blyte is a combination of a block and a byte, there's no meta post yet as how to count this, but I'll create one later. As for now, this is how I count:

  • I o e, 8 blytes
  • V t d, 10 blytes (2 leading spaces here)
  • Colours, 1 blyte each, 2 total
  • 90, 2 blytes
  • 999, 3 blytes
  • 0, 1 blyte
  • turn right, 2 blytes
  • move forward, 2 blytes
  • normal blocks, 1 blyte each, 5 total

Since Google Blockly is rarely used for golfing and I'm thinking waaay outside of the box for this challenge, I hope this is a valid submission.

\$\endgroup\$
  • 19
    \$\begingroup\$ For the record this is valid. It's nice to see unique languages. Though, unless there's a meta concensus on byte-counting in Google Blockly, I may ignore it when selecting a winner. \$\endgroup\$ – Calvin's Hobbies Nov 8 '16 at 14:47
  • 2
    \$\begingroup\$ You may find discussion here relevant. CC @HelkaHomba. \$\endgroup\$ – Scimonster Nov 8 '16 at 21:45
  • \$\begingroup\$ Have you though about replacing those three spaces in I o with two em spaces? \$\endgroup\$ – Andrea Lazzarotto Nov 11 '16 at 17:21
  • \$\begingroup\$ Google Blockly will be translated to JavaScript and then run. You need to Inspect Element and run code in Blockly API to get the real JavaScript code. \$\endgroup\$ – user61451 Nov 13 '16 at 14:27
  • 1
    \$\begingroup\$ Wait so could Scratch be used? \$\endgroup\$ – Adamawesome4 Nov 15 '16 at 22:30
46
\$\begingroup\$

HTML, 52 bytes

I <c>V<e>o<c>t<e>e<c>d<style>*{color:red}c{color:0ff
\$\endgroup\$
  • 2
    \$\begingroup\$ Also, I think that #FF0000 -> #F00 and #0000FF -> #00F works \$\endgroup\$ – Conor O'Brien Nov 8 '16 at 13:22
  • 46
    \$\begingroup\$ Why not turn this into a Stack Snippet? \$\endgroup\$ – Neil Nov 8 '16 at 13:35
  • 3
    \$\begingroup\$ <r>I <c>V<r>o<c>t<r>e<c>d<style>r{color:red}c{color:blue works \$\endgroup\$ – ASCII-only Nov 8 '16 at 13:35
  • 7
    \$\begingroup\$ actually you can just keep nesting without closing I <c>V<e>o<c>t<e>e<c>d<style>*{color:red}c{color:0ffand note change to blue 0ff \$\endgroup\$ – user21677 Nov 8 '16 at 14:17
  • 2
    \$\begingroup\$ Sadly the current version doesn't seem to work as a Stack Snippet, the latest version that works for me is the c{color:blue} version. \$\endgroup\$ – Neil Nov 9 '16 at 9:39
39
\$\begingroup\$

LaTeX, 147 126 bytes

\documentclass{proc}\input color\begin{document}\def\z{\color{red}}\def\y{\color{blue}}\z I \y V\z o\y t\z e\y d\end{document}

Saved 21 bytes and got better kerning thanks to @AndreïKostyrka.

This prints an a4 page with this on the first line (note that this also prints page 1 on the bottom):

enter image description here

\$\endgroup\$
  • 13
    \$\begingroup\$ I would have thought LaTeX would typeset the Vo kerning prettier... But apparently it considers each letter separately due to the colours. \$\endgroup\$ – Sanchises Nov 8 '16 at 17:21
  • \$\begingroup\$ @sanchises Since each letter is in a separate command, I think it destroys proper kerning. \$\endgroup\$ – Fatalize Nov 8 '16 at 18:30
  • \$\begingroup\$ Yeah exactly. Although I'm sure it would be possible somehow if golfing was not a requirement. \$\endgroup\$ – Sanchises Nov 8 '16 at 19:09
  • \$\begingroup\$ @sanchises this is definitely possible, but this is indeed longer than this ugly solution. \$\endgroup\$ – Fatalize Nov 8 '16 at 19:12
  • \$\begingroup\$ \documentclass{proc}\input color\begin{document}\def\z{\color{red}}\def\y{\color{blue}}\z I \y V\z o\y t\z e\y d\end{document} saves 21 bytes and results in 126 bytes of pure typographical beauty. \$\endgroup\$ – Andreï Kostyrka Nov 9 '16 at 9:39
35
\$\begingroup\$

Windows 10 Batch, 51 50 bytes

@color fc&echo I ␛[94mV␛[91mo␛[94mt␛[91me␛[94md␛[m

Where ␛ represents the ANSI Escape 0x1B character. Outputs using colour formatting. Edit: Saved 1 byte thanks to @brianush1. I tried writing the code to generate this but it took 97 bytes. Output:

I voted

\$\endgroup\$
  • 1
    \$\begingroup\$ You can golf it down by 1 byte if you use @color fc&echo I... \$\endgroup\$ – brianush1 Nov 9 '16 at 2:51
  • 1
    \$\begingroup\$ interesting, I didn't realise Windows terminal supported ANSI escape sequences \$\endgroup\$ – Mark K Cowan Nov 9 '16 at 15:40
  • 3
    \$\begingroup\$ @MarkKCowan It's only Windows 10, and (I think!) post Redstone Update. It's one of the few things that stop me from just installing XP over it. \$\endgroup\$ – wizzwizz4 Nov 9 '16 at 19:16
  • \$\begingroup\$ @wizzwizz4 ConEmu supports these too :) Indeed this is from Windows 10 anniversary (ie redstone 1) \$\endgroup\$ – Asu Jan 24 at 7:43
  • \$\begingroup\$ @Asu I installed XP over it. \$\endgroup\$ – wizzwizz4 Jan 24 at 7:43
27
\$\begingroup\$

JavaScript, 71 bytes

console.log('%cI %cV%co%ct%ce%cd',r='color:red',b='color:blue',r,b,r,b)

Makes use of console.log's ability to print in color. Doesn't work in a stack snippet so you should paste this answer to the console to test it.

enter image description here

Picture credits to @Mast

\$\endgroup\$
  • \$\begingroup\$ That's exactly what I just came up with, haha. I think the shortest alternative would be console.log([...' I Voted'].join`%c`,r='color:red',r,b='color:blue',r,b,r,b) \$\endgroup\$ – ETHproductions Nov 8 '16 at 15:33
  • \$\begingroup\$ Doesn't work in Node.js either. :( \$\endgroup\$ – Jordan Nov 8 '16 at 17:02
  • \$\begingroup\$ I was surprised this actually works, but it does. \$\endgroup\$ – Mast Nov 8 '16 at 19:58
22
\$\begingroup\$

R, 113 85 81 74 73 55 bytes

Edit: Saved a bunch of bytes thanks to @rturnbull and @JDL

plot(8:1,0:7*0,pc=el(strsplit("detoV  I","")),co=2:1*2)

The size of the output (and spacing etc) depends on the resolution of the currently open graphics device. Tested in RGui and RStudio on my monitor and produces:

enter image description here

\$\endgroup\$
  • 4
    \$\begingroup\$ Oh, I've never seen el() before. Thanks for helping me learn more R! Since text is vectorized, you can skip the for-loop and just write: text(seq(.3,.6,.05),.5,s,col=c("red","blue")). (I modified your x positions for golfier code, although the spacing may be a little less neat.) \$\endgroup\$ – rturnbull Nov 8 '16 at 15:03
  • 1
    \$\begingroup\$ Also, thanks to partial argument matching you can use co= rather than col=. And finally, 6:12*.05 is several bytes shorter than seq(.3,.6,.05). \$\endgroup\$ – rturnbull Nov 8 '16 at 15:17
  • 1
    \$\begingroup\$ Good catch! And now I realize that 6:12/20 is of course 1 byte shorter than 6:12*.05, apologies for leading you astray and suggesting suboptimal edits. \$\endgroup\$ – rturnbull Nov 8 '16 at 15:26
  • 1
    \$\begingroup\$ Aren't the colours off? Shouldn't the "I" and "V" be different colours? \$\endgroup\$ – JDL Nov 8 '16 at 15:37
  • 2
    \$\begingroup\$ I'm pretty sure el() improves 99% of all previous strsplit answers by 1 byte. \$\endgroup\$ – Vlo Nov 8 '16 at 20:44
21
\$\begingroup\$

LÖVE, 152 142 136 bytes

Let's show some löve for a fun little prototyping language! It's not perfect for the task of golfing (c'mon, it's LUA based), but it's easy to write.

function love.draw()l=love.graphics
a=255
l.setBackgroundColor(a,a,a)s=l.setColor
p=l.print
s(a,0,0)p('I   o e')s(0,0,a)p('  V  t d')end

Screenshot:

screenshot


Fully ungolfed version:

function love.draw()
    love.graphics.setBackgroundColor(255,255,255)
    love.graphics.setColor(255,0,0)
    love.graphics.print('I   o e')
    love.graphics.setColor(0,0,255)
    love.graphics.print('  V  t d')
end
\$\endgroup\$
  • 12
    \$\begingroup\$ I löve that you used something other than Java. \$\endgroup\$ – AdmBorkBork Nov 8 '16 at 14:24
  • 5
    \$\begingroup\$ So many 255… A variable for them? \$\endgroup\$ – manatwork Nov 8 '16 at 15:46
  • 1
    \$\begingroup\$ @ConorO'Brien This is a full program. love.draw() is a built-in function that you override, which runs on the draw step. There's also things like love.update() and love.load() for various parts of the render loop, but they're optional. It's a nice language, and you can get started with it very easily. I sometimes use it to prototype game ideas. \$\endgroup\$ – Geobits Nov 8 '16 at 16:01
  • 2
    \$\begingroup\$ @cat They just don't. It's not like I'm overprinting them on a console, it's a graphical print. So a space here is just "paint nothing in this area", not "paint this area background colored". \$\endgroup\$ – Geobits Nov 9 '16 at 2:50
  • 2
    \$\begingroup\$ @ZoltánSchmidt Thanks! There are a few other LÖVE answers, if you want to take a look through them :D \$\endgroup\$ – Geobits Nov 12 '16 at 21:46
18
\$\begingroup\$

Hot Soup Processor, 48 bytes

color 255
mes"I  o e
pos,0
color,,-1
mes"  V t d

The ungolfed version is:

color 255,0,0
mes "I  o e"
pos 0,0
color 0,0,255
mes "  V t d"

If you bear in mind that mes (message) is HSP's echo, I think this is fairly readable.

Weirdly, if you try to do pos or pos,, the blue line doesn't overwrite the red line and appears beneath it. Even weirder, color is only meant to take values in 0-255, but 0,0,-1 works for blue, 0,-1,0 works for green and -1,0,0 works for... black? (-257,0,0 and 511,0,0 work for red though, so something's funky about the mod 256 going on)

enter image description here

\$\endgroup\$
  • \$\begingroup\$ Why don't the spaces in the second mes overwrite the first? \$\endgroup\$ – cat Nov 9 '16 at 2:51
  • \$\begingroup\$ @cat Spaces don't actually draw anything, it just advances the cursor position in a sense \$\endgroup\$ – Sp3000 Nov 9 '16 at 3:41
  • 1
    \$\begingroup\$ Clever using -1 for 255. Have a +1 \$\endgroup\$ – Cyoce Nov 10 '16 at 1:44
  • \$\begingroup\$ @Cyoce Or maybe it's actually -255? \$\endgroup\$ – sagiksp May 25 '17 at 12:02
18
\$\begingroup\$

MATLAB, 74 bytes

We create a white 50x50 (one column for each state) background using imshow of an array of ones. We then display a text, using my trick of shortening property names to get the colours. Since the default font is not fixed width, the text is padded with spaces.

imshow(ones(50))
text(2,9,'I   o e','Co','r')
text(8,9,'V  t  d','Co','b')

enter image description here

MATLAB, 99 bytes, fixed width font

The first version uses fiddling with spaces and coordinates to get a proper kerning on the default font, and might not display properly on your computer. Instead, we can use a fixed width font, like Courier (or, for some more bytes, FixedWidth which works on any system that has a fixed width font installed). This does come at the cost of quite a few extra bytes. We can mitigate this slightly by using a for loop to print the text. The text and corresponding colours are stored in a cell array. The background needs to be a little bit larger.

imshow(ones(80))
for y={'I  o e ','  V t d';'r','b'}
text(9,9,y{1},'Co',y{2},'FontN','Courier')
end

enter image description here

Matlab, 80 bytes bonus edition

Sadly, underlined blue text is not allowed. Otherwise, this answer would have highlighted some interesting behaviour in MATLAB. You can print red text using fprintf(2,txt), and you can print blue underlined text with fprintf('<a href="">txt</a>'). Combining this works... sometimes. Completely at random, it may also create red underlined text. You can issue drawnow between consecutive f calls if this is the case on your system.

f=@(p)fprintf(2,'%s<a href>%s</a>',p(1:end-1),p(end));f('I V');f('ot');f('ed');fprintf('\n')

enter image description here

\$\endgroup\$
  • \$\begingroup\$ You can write <a href> instead of <a href="">. If you don't like it, you can use <a href=#>. \$\endgroup\$ – Ismael Miguel Nov 10 '16 at 19:28
  • \$\begingroup\$ @IsmaelMiguel Clever. <a> didn't work. \$\endgroup\$ – Sanchises Nov 10 '16 at 21:37
  • \$\begingroup\$ Using only <a> isn't considered a clickable link. to get it's blue color, it has to be considered as one. In CSS, the selector may be a[href]. As long as the attribute href is there, it is a clickable link. That's why using only <a> won't work. \$\endgroup\$ – Ismael Miguel Nov 11 '16 at 8:58
18
\$\begingroup\$

ImageMagick, 102 bytes

magick xc:[x60] -fill red -draw 'text 5,30 "I     o  e"' -fill blue -draw 'text 15,30 "V   t   d"' x:

Ungolfed:

magick convert canvas:white[60x60!] \
       -fill red  -draw 'text 5,30   "I     o  e"' \
       -fill blue -draw 'text 15,30      "V   t   d"' \
       show:

enter image description here

Golfing the full ImageMagick command consisted of

  • not explicitly calling the default convert utility

  • using xc: instead of canvas: (xc: is an old synonym for canvas:; I don't foresee ImageMagick ever eliminating it)

  • not specifying the canvas color but relying on ImageMagick's default, which happens to be white

  • removing the width 60 from the geometry (when it's omitted, width==height)

  • removing the "!" from the geometry which is only needed to produce a non-square canvas, like canvas:white[60x30!]

  • using the older x: instead of show: as the output file (assumes that ImageMagick was built with X support)

  • removing some whitespace that I had used to line up the text strings

  • joining the multiple lines of the command (removed the backslash-CR between lines)

If you are so inclined after the election, add 12 bytes -rotate 180 preceding the show: directive:

enter image description here

\$\endgroup\$
  • 4
    \$\begingroup\$ I love how the ungolfed version drastically differs from the golfed one. \$\endgroup\$ – Andreï Kostyrka Nov 11 '16 at 13:25
15
\$\begingroup\$

Bash, 35 bytes

My script looks like this

echo "^[[47;31mI hope^[[34md^H^H^Ht^H^H^Hv"

xxd of script file:

0000000: 6563 686f 2022 1b5b 3437 3b33 316d 4920  echo ".[47;31mI 
0000010: 686f 7065 1b5b 3334 6d64 0808 0874 0808  hope.[34md...t..
0000020: 0876 22                                  .v"

Typing it: ctrl-v-esc and ctrl-v-h will insert the escapes and backspaces (^[ and ^H).

enter image description here

\$\endgroup\$
  • \$\begingroup\$ How does this work? An explanation would be super \$\endgroup\$ – cat Nov 9 '16 at 19:16
  • 2
    \$\begingroup\$ @cat it appears to write all the red letters (with "h" and "p" as stand-ins), then sets the colour to blue and writes "d" at the end. Finally it moves the cursor left to add the "t" and "V" over the earlier stand-ins (ascii 0x08, represented by "^H" in the display above, moves left 1 character). Clever way of avoiding lots of escape sequences for colour changes. It also uses a literal escape character (0x1B, represented as "^[") which saves some space compared to similar answers like mine. \$\endgroup\$ – Dave Nov 9 '16 at 22:29
  • \$\begingroup\$ Also: could save 3 bytes by assuming the terminal is set to a white background by default (most other terminal answers already assume this). \$\endgroup\$ – Dave Nov 9 '16 at 22:31
  • \$\begingroup\$ You can save a byte by removing the two quotes and adding a backslash (escape character) before the semicolon. Also your script has a lower case v (your command line one is fine). \$\endgroup\$ – user56228 Nov 11 '16 at 5:08
15
\$\begingroup\$

Mathematica (REPL image output), 65 49 bytes

Overlay@{"I  o e"~Style~Red,"  V t d"~Style~Blue}

Graphical REPL expression.

\$\endgroup\$
  • 3
    \$\begingroup\$ "Private use?" What is that? \$\endgroup\$ – Conor O'Brien Nov 8 '16 at 13:14
  • 2
    \$\begingroup\$ @ConorO'Brien enwp.org/Private_Use_Areas \$\endgroup\$ – LegionMammal978 Nov 8 '16 at 13:15
  • \$\begingroup\$ This is 49 bytes: Overlay@{"I o e"~Style~Red," V t d"~Style~Blue} (there are supposed to be two spaces between I and o and before V) \$\endgroup\$ – Gerli Nov 11 '16 at 10:01
14
\$\begingroup\$

Java, 322 319 318 309 304 229 217 bytes

-9 Bytes thanks to kevin.
-75 Bytes thanks to Angzuril, nice callout on the old awt classes, always forget those exist.
-12 Bytes thanks to user902383.

import java.awt.*;
void n(){new Frame(){{add(new Panel(){public void paint(Graphics g){int i=0;for(String c:"IVoted".split("")){g.setColor(i%2<1?Color.RED:Color.BLUE);g.drawString(c,i++*8,10);}}});setVisible(0<1);}};}

Output:

enter image description here

\$\endgroup\$
  • 1
    \$\begingroup\$ JFrame j= can be golfed to Frame j=; (c==' '||i++%2==0)? can be golfed to c<33|i++%2<1? and true can be golfed to 1>0. Also, @HelkaHomba, is this a valid output? Since it also has spaces between the V o t e d? Oh, and why 0,0,999,99? 0,0,99,99 is large enough for the text on my screen. \$\endgroup\$ – Kevin Cruijssen Nov 8 '16 at 14:46
  • 1
    \$\begingroup\$ (c<33||i++%2<1)? can stil be golfed by three bytes by removing the parenthesis and change || to | \$\endgroup\$ – Kevin Cruijssen Nov 8 '16 at 15:25
  • 1
    \$\begingroup\$ I found some more things to golf: new JComponent to new Container (-1); remove char c="IVoted".charAt(i); and change g.drawString(c+"" to g.drawString("IVoted".charAt(i)+""(-8). \$\endgroup\$ – Kevin Cruijssen Nov 9 '16 at 12:52
  • 1
    \$\begingroup\$ First improvement, change Frame j=new JFrame();j.add(new JComponent() to Frame j=new Frame();j.add(new Container() and you can also drop the import import javax.swing.*; and g.setColor(Color.WHITE);g.fillRect(0,0,99,99) as a result (-63) \$\endgroup\$ – Angzuril Nov 10 '16 at 17:20
  • 1
    \$\begingroup\$ void n(){new Frame(){{add(new Panel(){public void paint(Graphics g){int i=0;for(String c:"IVoted".split("")){g.setColor(i%2<1?Color.RED:Color.BLUE);g.drawString(c,i++*8,10);}}});setVisible(0<1);}};} allows you to reduce by 12 bytes \$\endgroup\$ – user902383 Nov 11 '16 at 22:26
13
\$\begingroup\$

Bubblegum, 28 bytes

0000000: 938e 3636 ccf5 0492 e6b9 0a40 d224 370c  ..66.......@.$7.
0000010: 2c92 0f66 9780 d9a9 6076 0a00            ,..f....`v..

enter image description here

Does not work online since it uses ANSI color codes for coloring.

\$\endgroup\$
  • \$\begingroup\$ Is this a straight-up encoding, or is does it employ some other clever trick? \$\endgroup\$ – Conor O'Brien Nov 8 '16 at 15:56
  • 2
    \$\begingroup\$ @ConorO'Brien There is no such thing as clever tricks in Bubblegum. To be honest, this answer was mostly a side-effect of the actual answer I'm working on. \$\endgroup\$ – a spaghetto Nov 8 '16 at 15:57
13
\$\begingroup\$

PowerShell v2+, 71 59 57 55 bytes

"I Voted"[0..6]|%{Write-Host -b w -n -f (9,12)[$_%2]$_}

Saved two bytes thanks to @flashbang ... saved two more thanks to @ConnorLSW

Takes "I Voted" and turns it into a char-array, then loops |%{...}. Each letter, we execute Write-Host with the -background color to White, -noNewLine, and the -foreground color to be the appropriate index. This leverages the fact that odd ASCII values are Red, while even ASCII values are Blue via $_%2 as the index.

Console colors in PowerShell are very limited, so this is the closest approximation I could get. It would be golfier to use 4 (DarkRed) for the red, but it doesn't look right, so I'm sacrificing a couple bytes for the sake of color accuracy.

Below is the output, followed by the 16 available colors the console can display. Note that the background isn't truly white, since Microsoft in their wisdom opted to have the background colors ever-so-slightly-off from the foreground colors.

Console Output

\$\endgroup\$
  • \$\begingroup\$ IIRC, in ancient stuff, you had 4 bits for the foreground and 3 bits for the background, so backgrounds could only be the 'dark' colors 0-7. Is the console still following that? \$\endgroup\$ – Hurkyl Nov 8 '16 at 14:39
  • \$\begingroup\$ @Hurkyl Kinda. It appears to be based on the EGA color palette, but I'm not sure the historical reasons for PowerShell keeping that scheme. Likely something buried in the Win32 API backwards-compatibility that forced them to only use those 16 colors. \$\endgroup\$ – AdmBorkBork Nov 8 '16 at 15:03
  • \$\begingroup\$ It doesn't work if you set the background color to 15? \$\endgroup\$ – Random832 Nov 9 '16 at 7:21
  • \$\begingroup\$ @Random832 it is for the sake of the white background of the sticker. \$\endgroup\$ – geisterfurz007 Nov 9 '16 at 9:43
  • \$\begingroup\$ @geisterfurz007, TimmyD, I was asking if you could set the background to "15" rather than "white" [since the actual background in your image appears to be #7] to get a brighter white. But on looking at it more, your whole display looks strange - the borders between the lines in your example and the gray line between "I" and the following space don't make sense if PowerShell is being run in the console - are you using some other tool like ConEmu? If so it doesn't make sense to blame Microsoft for this. \$\endgroup\$ – Random832 Nov 9 '16 at 14:39
11
\$\begingroup\$

Python, 91 bytes + termcolor

Not gonna win, but posted it for fun.

from termcolor import*
for c in'I Voted':cprint(c,'brleude'[ord(c)%2::2],'on_white',end='')

Half the credit goes to Sp3000.

\$\endgroup\$
  • 2
    \$\begingroup\$ Using ANSI codes should be shorter \$\endgroup\$ – TuxCrafting Nov 8 '16 at 13:32
  • \$\begingroup\$ @TùxCräftîñg It isn't supported on all platforms, i.e. Windows. \$\endgroup\$ – Kade Nov 8 '16 at 13:34
  • 3
    \$\begingroup\$ Mind adding an image? \$\endgroup\$ – Calvin's Hobbies Nov 8 '16 at 13:36
  • 9
    \$\begingroup\$ You can save 5 bytes by changing 'blue' if c else 'red' to 'brleude'[c^1::2]. \$\endgroup\$ – Kade Nov 8 '16 at 13:37
  • 2
    \$\begingroup\$ You should probably put + termcolor in the title since it's not a standard module. Also: from termcolor import*\nfor c in'I Voted':cprint(c,'brleude'[ord(c)%2::2],'on_white',end='') \$\endgroup\$ – Sp3000 Nov 8 '16 at 13:45
8
\$\begingroup\$

Jolf, 53 bytes

"<z>I <w>V<z>o<w>t<z>e<w>d<style>w{ΞΩ4blue}z{ΞΩ4red

There are unprintables. Try it here!

Jolf's output is HTML capable. I tried doing something clever like modulus 2 to decide color, but that only wound up longer (around 69 bytes). So, the output is in HTML.

Output:

regular "I Voted"

(larger version)

large "I Voted"

\$\endgroup\$
  • 8
    \$\begingroup\$ This is terrible you've only saved three bytes over HTML :P \$\endgroup\$ – ASCII-only Nov 8 '16 at 13:41
  • \$\begingroup\$ @EriktheGolfer It really only works in firefox. \$\endgroup\$ – Conor O'Brien Nov 8 '16 at 15:28
  • \$\begingroup\$ @ConorO'Brien Oh, I use Chrome. Thanks. \$\endgroup\$ – Erik the Outgolfer Nov 8 '16 at 15:32
  • 1
    \$\begingroup\$ ...aand the HTML answer outgolfed this. \$\endgroup\$ – betseg Nov 8 '16 at 21:05
  • \$\begingroup\$ Can't blue be written as 00f? \$\endgroup\$ – Ismael Miguel Nov 10 '16 at 19:20
8
\$\begingroup\$

Python, 99 87 bytes

from turtle import*
up()
for c in"I Voted":color("brleude"[ord(c)%2::2]);write(c);fd(7)

Try it online

\$\endgroup\$
  • \$\begingroup\$ Mind adding an image? \$\endgroup\$ – Calvin's Hobbies Nov 8 '16 at 22:32
  • \$\begingroup\$ @HelkaHomba All you need to do it click the link. \$\endgroup\$ – mbomb007 Nov 8 '16 at 22:56
8
\$\begingroup\$

sh, 61 49 bytes

echo "[47;31;1mI [34mV[31mo[34mt[31me[34md"

Because this contains unprintables, here is a reversible xxd hexdump:

00000000: 6563 686f 2022 1b5b 3437 3b33 313b 316d  echo ".[47;31;1m
00000010: 4920 1b5b 3334 6d56 1b5b 3331 6d6f 1b5b  I .[34mV.[31mo.[
00000020: 3334 6d74 1b5b 3331 6d65 1b5b 3334 6d64  34mt.[31me.[34md
00000030: 22                                       "
I Voted
Xterm(322)

Thanks to 4198 (manatwork) for -12 bytes.

\$\endgroup\$
  • \$\begingroup\$ Why setting the background and foreground colors separately? Start it with [47;31;1m. And the 1 for bold persists until a 0, so no need to set it again and again for each letter. \$\endgroup\$ – manatwork Nov 8 '16 at 15:56
  • \$\begingroup\$ @manatwork Oh god, I thought you have to re-set it! \$\endgroup\$ – Erik the Outgolfer Nov 8 '16 at 16:00
  • \$\begingroup\$ If that sh is anything more modern than the old Bourne shell, some parameter expansion may help: s=":1;47;1mI :4mV:1mo:4mt:1me:4md";echo ${s//:/^[[3}. \$\endgroup\$ – manatwork Nov 8 '16 at 16:06
  • \$\begingroup\$ @manatwork It does not work. It seems it's not more modern. \$\endgroup\$ – Erik the Outgolfer Nov 8 '16 at 16:07
  • \$\begingroup\$ @manatwork ${VAR/FROM/TO} requires ksh93, bash or zsh, not just “anything more modern than the old Bourne shell”. POSIX requires the # and % parameter expansion modifiers but not /…/ or :…: \$\endgroup\$ – Gilles Nov 8 '16 at 21:05
8
\$\begingroup\$

SVG + bzip2, 1807 bytes

A vectorized version of the example image, then compressed with bzip2 to about half (4385 -> 1807 bytes). You can download it here. (direct GitHub Pages link)

BZh91AY&SY!�l�ß�x��>�ߠ/���`    0����Ҁ�D�5��ޠII�T񡤙�O!45J??��i�@JzH���
.�M�&�Q�vا����bB���� �쾾�4AV�8�8���)Z�ޣ�j�q}�����?�t�/
�±%��"A����B�X�(␌�[⎺;Z/┐├*��%�␤�       I���Uƒ�Y�9ǝK���B��┤�=���±?�W���
            ��ڰj�?�H��\����^��m�=X�d���>�!C�@�.���9�" DZ+��V1+�;�����58Q���-:�5,HDQŧ`A>����W�+h��>m��G�m�uWv�&�U�|mq�u���?=S�\{(��Z�a�I��G{Cd��;Bz���qX7��?P�@�Jt[w�]����%W���37f���-񴁭�iԳ]c��|�;i�k�H��
    sHz��Y�$�.�*�?�ڐ��Us=\뫅6%�Ud�9w���D
                                          ��H��^�Q��P��%n�O����l��+*q�U�"F%��*�     *b�� 
                                         @mP���Z�(ZL`
  bIv⦳�~�F=��>H�Ti����0@≠R≥��T�E��┴��D����␍│��2*◆=└6&⎽M�◆␊?�/�U�����r�.�`gƅ���E'��^��ILPz@���zR&u$��l^�U�n�'O\�Xj+چ�o�*�O�w��JP8���]���r��k=��N�b�ƵpM�8|���=7���N��W�M(����*�E�DݐT��Zi�v"���49�J�0}�F�*x�K���P��⎼*�������6[G,4� ү)UUT␍��%4D��Թ␉��⎻�8�CZ_3ɷwW�9��-&�Ov�a՜
�'ӥtߢ�>��^�m-������c�]:��*��2��촄Ujr�?"�J�"���DE�f?┴⎻��␍3·└���Ԉ��? ׌�5|ᫎ���|DO���%�4Ư`W�ƐV/=�]V`gˇ��^Z��cP������.{������6   o.*�sɽ���U?E.3�,�H$�{�?
             �%�0��2    ��n�C!%�>��]��
#߽v�E��K��?X|���5�ΰ@>A;#J���,��Q��$���ݨ��^����7�g�Xn�k����d욒�`fQ/7��vh|�ȥ*^M
                            �[����׈���i�I��    $��4��
  Y��`V.��ح��?�eT����5K˱~�瞯r�fL^I �#b�@�pBƞ���V`5��a��qH���Ş�t�V3��┌���T���1␉�␍$5��@T␤$�>$����π���S�[۸£�[ȟ␋CO≥�ގ^��>��]E�A��┘���I(�㴨Z�J'��:�-_┤±�K␌�ۓ#:�?m��^�Z�+�����G
�k�t�O��SD�4����^o��Z�n���6M�)!��r��w�3\�R����
�X6<#����.��p� Cj"�2�ĭ�*h�S�`}�L���C?�� �چZc'kG��

Not gonna win, but posted it for fun.

\$\endgroup\$
  • 1
    \$\begingroup\$ bzip2 is not a programming language. \$\endgroup\$ – Peter Taylor Nov 8 '16 at 20:55
  • 3
    \$\begingroup\$ @PeterTaylor Per meta rules, it doesn't have to be a programming language. (meta.codegolf.stackexchange.com/a/10426/41088 \$\endgroup\$ – noɥʇʎԀʎzɐɹƆ Nov 8 '16 at 20:56
  • 1
    \$\begingroup\$ should post a reversible xxd of the file \$\endgroup\$ – cat Nov 8 '16 at 22:04
  • \$\begingroup\$ try using brotli for even more compression \$\endgroup\$ – Sarge Borsch Nov 9 '16 at 9:03
  • 4
    \$\begingroup\$ If you're really interested in golfing this, it would probably make more sense to just create the SVG by hand with a couple text elements set to the right colors. Here's a starting point: <svg xmlns="http://www.w3.org/2000/svg"><text fill="blue"><tspan fill="red">I</tspan> V<tspan fill="red">o</tspan>t<tspan fill="red">e</tspan>d</text></svg> Note that this actually renders it outside the printable area and has no background color. Like I said, it's just a start. \$\endgroup\$ – trlkly Nov 9 '16 at 11:45
8
\$\begingroup\$

C, 65 bytes

i;main(c){for(;c="I Voted"[i++];printf("\33[3%dm%c",c&1?1:4,c));}

or, more accurately:

i;main(c){for(i=90;c="\0.noitcele ym saw ti fi enod evah dluow I sseug I tuB .hsitirB ma I esuaceb ,etov ton did I"[i--];printf("\33[3%dm%c",c&1?1:4,c));}

Uses the same bash colour technique used by betseg, but with the octal escape sequence instead of hex, and with Sp3000's observation that all odd codepoints are red.

Leaves the terminal in blue. Reset with:

printf "\33[0m";
\$\endgroup\$
  • \$\begingroup\$ If || works in C like it does in JavaScript (x||y -> x?x:y), you could do c&1||4 to save a byte. \$\endgroup\$ – ETHproductions Nov 8 '16 at 21:45
  • 1
    \$\begingroup\$ @ETHproductions doesn't work that way in C. While || and && are short-circuiting, they always return 1 or 0, regardless of the values involved. \$\endgroup\$ – Dave Nov 8 '16 at 21:50
  • \$\begingroup\$ @Dave I learned something today... \$\endgroup\$ – cat Nov 9 '16 at 2:56
  • \$\begingroup\$ This doesn't set the background color. Also, you could use a literal escape character instead of \33 to save two bytes, if that isn't against the rules somehow. \$\endgroup\$ – user61954 Nov 10 '16 at 6:51
  • \$\begingroup\$ @yellowantphil this assumes the default terminal background is set to white (since the challenge says it just needs to be possible to have it on a white background). In fact in OS X, the terminal is black-on-white out-of-the-box. \$\endgroup\$ – Dave Nov 10 '16 at 8:15
8
\$\begingroup\$

Node, 57 55 41 bytes

console.log("q47;91mI  o eHHHHq94mV t d")

Replace each q with the literal byte 1B and H with byte 08 before running.

Here's how it looks in the ConEmu terminal emulator on my Windows computer (zoomed in):

enter image description here

\$\endgroup\$
  • \$\begingroup\$ What terminal emulator is that!? \$\endgroup\$ – cat Nov 9 '16 at 19:05
  • 1
    \$\begingroup\$ @cat ConEmu: conemu.github.io \$\endgroup\$ – ETHproductions Nov 9 '16 at 20:20
8
\$\begingroup\$

Python IDLE, 97 96 78 69 bytes

Thanks to DrMcMoylex for shaving off some bytes!

EDIT: Figured out that a direct .write() was 9 bytes shorter

Not really a proper answer, more abuse of a standard theme. IDLE is Python's IDE, and unless it's customized, STDOUT is blue, STDERR is red, and the background is white. So, the following code:

from sys import*
for i in'I Voted':[stdout,stderr][ord(i)%2].write(i)

Prints this:

enter image description here

This works because ord(i)%2 checks the parity of the letter's code point and prints it to ERR/OUT accordingly.

\$\endgroup\$
8
\$\begingroup\$

REBOL, 100 90 95 bytes (-7 bytes with REPL for 88)

REBOL[]view layout[style b tt blue white space 0 across b"I"red b b"V"b"o"red b"t"b"e"red b"d"]

In REPL, the initial REBOL[] is not required. That's 7 bytes.

The ungolfed version is:

REBOL[]
view layout[
  ; by default, tt (text) has a grey background and a 2x2 padding
  style b tt blue white space 0
  ; this one doesn't appear in the golfed version as it's slightly shorter to just manually set red everywhere needed
  style r b red

  ; by default, vertical stack panel
  across
  r "I"
  r 
  b "V"
  r "o"
  b "t"
  r "e"
  b "d"
]

On the left, with "space 0x0" added to each text block, on the right, with the default 2x2 padding.

REBOL I Voted
(source: canardpc.com)

\$\endgroup\$
7
\$\begingroup\$

Perl, 57 + 17 = 74 bytes

Run with -MTerm::ANSIColor

sub c{color$a++%2?blue:red}say c,"I ",c,V,c,o,c,t,c,e,c,d

Your terminal may be blue at the end (append ,c("reset") at the end of the code to restore it to normal).

By default, terminals are usually black background, but they can be optionally changed to white, which I personally don't think is cheating.

With picture: enter image description here

\$\endgroup\$
7
\$\begingroup\$

PHP, 199 201 151 bytes

This script outputs image to standard output. Updated thanks to manatwork

imagefill($i=imagecreatetruecolor(99,99),0,0,2**24-1);foreach([I,' ',V,o,t,e,d]as$k=>$e)imagestring($i,2,$k*9,0,$e,!$k|$k&1?0xFF0000:255);imagepng($i);

Run it in the command line like this:

php -d error_reporting=0 -r "imagefill($i=imagecreatetruecolor(99,99),0,0,2**24-1);foreach([I,' ',V,o,t,e,d]as$k=>$e)imagestring($i,2,$k*9,0,$e,!$k|$k&1?0xFF0000:255);imagepng($i);" > output.png

Output:

enter image description here

\$\endgroup\$
  • 2
    \$\begingroup\$ Skip the header() call. Your code works fine run from command line too. As error_reporting's default value not shows notices, is generally acceptable to not quote your string literals. Or if you not like that, str_split("I Voted") is still shorter than enumerating the characters separately. And move the assignment to $i to its first usage. \$\endgroup\$ – manatwork Nov 9 '16 at 9:08
  • 1
    \$\begingroup\$ ~2**24 seems to work instead of 0xFFFFFF. Not sure if this is valid for all architectures. If not, 2**24-1 should be portable. \$\endgroup\$ – manatwork Nov 9 '16 at 9:19
  • \$\begingroup\$ @manatwork awesome thanks. That got it down to 152. I tried ~2**24 and 2**24-1 but I got errors. I don't even know how those work. \$\endgroup\$ – Kodos Johnson Nov 9 '16 at 18:49
  • \$\begingroup\$ Probably your PHP is older than 5.6.0: “Added an exponentiation operator (**).” – PHP changelog. Same as pow(), but handier for golfing. pastebin.com/jFn6ahFk \$\endgroup\$ – manatwork Nov 9 '16 at 18:57
  • \$\begingroup\$ Oh I see. Well since php 5.5 seems to be unsupported, I'll use your solution. Now it's 150. Thanks again. \$\endgroup\$ – Kodos Johnson Nov 9 '16 at 19:06
7
\$\begingroup\$

Xamarin.Forms C#, 317 313 bytes

using Xamarin.Forms;public class A:Application{public A(){var s=new StackLayout{BackgroundColor=Color.White,Orientation=(StackOrientation)1,VerticalOptions=LayoutOptions.End};foreach(var c in"I Voted")s.Children.Add(new Label{Text=c+"",TextColor=c%2<1?Color.Blue:Color.Red});MainPage=new ContentPage{Content=s};}}

VerticalOptions=LayoutOptions.End is needed for iOS, otherwise the text will be overlayed by status bar. No problem on Android so can save 34 bytes including comma.

Edit: 2016-11-14: -4 bytes

Ungolfed

using Xamarin.Forms;
public class A : Application
{
    public A()
    {
        // Make a horizontal StackLayout for labels
        var s = new StackLayout
        {
            BackgroundColor = Color.White,
            Orientation = (StackOrientation)1,   // StackOrientation.Horizontal
            VerticalOptions = LayoutOptions.End
        };
        foreach(var c in "I Voted")
            // Make a new label for each letter, then add to StackLayout
            s.Children.Add(new Label
                {
                    // Cast char to string
                    Text = c + "",
                    // Happens that 'I', 'o', and 'e' are all odd in ASCII, and 'V', 't', and 'd' are all even :)
                    TextColor = c%2<1 ? Color.Blue : Color.Red   
                }
            );
        // Set app MainPage to be a new ContentPage, where the content is the StackLayout above
        MainPage = new ContentPage { Content = s };
    }
}
\$\endgroup\$
  • 1
    \$\begingroup\$ Well that's a new kind of idea. +1 \$\endgroup\$ – Addison Crump Nov 9 '16 at 7:54
7
\$\begingroup\$

x86 machine code + DOS + BIOS, 25 bytes

Hexdump:

b8 02 13 b1 07 bd 0b 01 cd 10 c3 49 74 20 74 56
71 6f 74 74 71 65 74 64 71

Assembly code (suitable as input to debug.com, so all numbers are hexadecimal):

mov ax, 1302
mov cl, 7
mov bp, 10b
int 10
ret
db 'It tVqottqetdq'

It uses a BIOS routine to output the string to the display memory. The string will appear at a "random" position on screen (see below), like this:

screenshot

The string contains the letters I V o t e d, interleaved with "attributes"

74 74 71 74 71 74 71

that specify the colour of the letters. Here 7 as the most significant digit means "white background", and the least significant digit specifies the foreground (1=blue; 4=red).

The display position of the string is specified by the dx register. As mentioned here, the initial value of this register is equal to the value of the cs register. And the value of that one is the first available address in memory, after DOS is loaded.

The size of DOS is typically less than 64K, that is, the segment address of the loaded user's program is less than hexadecimal 1000. So the output will appear somewhere around the first 16 lines of text on the display. In my example, it appeared at line 8 (the upper half of dx, called dh, is equal to 8).

The low half of dx, called dl, contains the column at which the text is output. Experiments show that BIOS doesn't check overflow, so it doesn't matter if dx asks for output at e.g. column 100.

\$\endgroup\$
  • \$\begingroup\$ clever, short, and really intuitive. \$\endgroup\$ – tuskiomi Nov 14 '16 at 21:46

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.