• 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.


    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.

    A bit disappointed my actual sticker doesn't look like yours.

    "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." :/

    @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.

    If it helps anyone, vowels are red, consonants are blue.

    @mbomb007 Or more usefully, the letters with odd code points are red, and the letters with even code points are blue.

    Can red letters be one font and blue another, or red one size and blue another, or blue letters bold, etc.?

    @ETHproductions Also a stretch, so no.

    @Calvin'sHobbies - not to attack the challenge - but the initial part of your post is very misleading: _...then go out and vote_ ... _It only matters that you voted._ - Yes, everyone SHOULD vote (esp. with how many people don't), but everyone who votes has the responsibility to vote informed, and opt out if you deem yourself uninformed, or better yet, ensure yourself to never be uninformed. Your vote matters, and should be treated as such. Study the ballot ahead of time for all the different elections, and know your choice well before election day. Don't throw away your vote with ignorance.

    @James You make a fair point, but see the undeleted comments above.

    Ya know, seeing this in the HNQ on November 14th (2 hours away from the 15th) does make this a teensy weensy bit late...

    Does the program have to exit, or can it just hang?

    @anonymous2 A window where the message is drawn that stays open is fine, but if there's no gui, it should end normally.

    @allthepeoplewhoarearguingaboutgoingoutandvoting, check out this link about what Mike Rowe says about it. It's definitely something you might want to think about... https://www.facebook.com/TheRealMikeRowe/posts/1254500967893377

  • 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 or a world which is still generating).

    Wow. I'm speechless. That's a very clever answer!

    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! :)

    @Shebang http://gaming.stackexchange.com/questions/20219/is-minecraft-turing-complete Minecraft chat has (nearly) all the same commands as command blocks, and certainly all the commands from back when the question was asked :-)

    @HelkaHomba I'll be home in 2 hours! count on it then!

    Wait I thought they removed the ability to do that I remember spending a whole day trying to get colors

    Technically, in vanilla Minecraft, the `&`s should be `§`s

    Hmmm I think it can be done in Quake 3, too

    For what versions does this work? Certainly not for 1.10.

    @Oliver thankyou, I've added that possible interpretation. In vanilla minecraft, the ampersand is filtered and escaped. In Spigot (a modified server), the ampersand is not filtered.

    Note that this won't work on some Spigot (and other third-party servers) if the admin didn't decide to allow color-code formatting, which may very well be the case.

    Also, the server will kick the client any time it receives a § from a client, so a modded server is a requirement to use this exact code.

    @JustinKrejcha do you have a source for that? I've never had problems with the symbol before.

    @tuskiomi According to the wiki, the section symbol can only be entered into a book and quill and command blocks. Additionally, I just tried it on a test server (with a client that allows me to enter the symbol) and I got kicked for "Illegal characters in chat".

    I must say very impressed. Never would have thought of using Minecraft Chat!

    `&` isn't valid on spigot without plugins; if you allow it then you should count the code of the plugin that's translating it. However, it is valid on unmodified Minecraft Classic (though getting a classic server to work is somewhat difficult nowadays).

    @Pokechu22 It works on my pluginless spigot server.

    This was **Extremely `Impressive!`**!

  • 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:

    What does the `a"\x1B[%dm"` do?

    @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.

    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.

    However, if you want to clean up the output stream with a final `a` and `,0` (which you should when doing it live, but this is codegolf ;), the solution as stated is shorter by two bytes.

    You can save another 2 bytes with "\33" instead of "\x1B".

    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...

    @yellowantphil I've thought that too, but it would be hard to test on mobile :)

    I have an ssh app and keyboard that lets me type control characters, so I could do it if I wanted to. :) It works fine on my computer.

    @yellowantphil I tried making an hexdump but it didn't work, can you please post a dump with 0x1B (escape character)?

    @betseg I tried, but the edit reviewers said I was a spammer. I can't fit the hexdump in a comment, so never mind.

    This is truly unreadable. `a` should be `r` so as to have meaningful variable names :-) More seriously though, it's not a program, missing `main` as it is.

    @paxdiablo according to this meta thread, functions are OK for code golf.

    I stand corrected :-)

  • Google Blockly, 10 14 blocks, 28 41 35 blytes


    enter image description here


    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.

    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.

    You may find discussion here relevant. CC @HelkaHomba.

    Have you though about replacing those three spaces in `I o` with two em spaces?

    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.

    Wait so could Scratch be used?

  • HTML, 52 bytes

    I <c>V<e>o<c>t<e>e<c>d<style>*{color:red}c{color:0ff

    Remove spaces to save bytes

    @KritixiLithos you mean space (singular) instead of spaces (plural). The first can indeed be removed, the second however would change the text to `Ivoted`.

    Mind adding an image? (Or stack snippet.)

    Also, I think that `#FF0000` -> `#F00` and `#0000FF` -> `#00F` works

    Actually there is a constant for `#F00`: `red`.

    Also IMO `blue` instead of `#00F` looks nicer

    If you replace `b` with `c` you lose the boldness and if you nest, you can save 14 bytes
    `r{color:red}c{color:blue}<r>I</r> <c>v<r>o</r>t<r>e</r>d</c>`

    Also leaving out the last closing tag should work: `r{color:red}c{color:blue}<r>I</r> <c>v<r>o</r>t<r>e</r>d` (please test before editing)

    Also you can move `style` to the end to remove the closing tag for `style` and the last closing brace.

    `<r>I</r> <c>v<r>o</r>t<r>e</r>d</c>r{color:red}c{color:blue`67 bytes - credit @betseg

    also, you don't need the closing tags.

    Why not turn this into a Stack Snippet?

    `<r>I <c>V<r>o<c>t<r>e<c>dr{color:red}c{color:blue` works

    If you style `*`, you don't need `r` tags and save some bytes. You can also continue the "don't close the final tags" mentality and get an answer of 56 bytes: `I <c>v</c>o<c>t</c>e<c>d*{color:red}c{color:blue`

    actually you can just keep nesting without closing `I <c>V<e>o<c>t<e>e<c>d*{color:red}c{color:0ff`and note change to blue `0ff`

    @tolos `color:0ff` doesn't do anything for me in Firefox 49. What browser are you using?

    chrome 54, and other characters to reach the minimum required to post.

    @tolos It does indeed work in Chrome! But why?

    @tolos The technique described there applies to e.g. ``, but not `c { color: chucknorris; }`. I would expect `c { color: 0ff; }` to be cyan anyway, so I wonder what's really going on here...

    @Neil feel free to edit the question.

    @tolos it fails in Chrome.

    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.

    @Neil Stack snippets automatically insert a doctype. Omitting the `#` before the color value is only supported in quirks mode.

    `0ff` is invalid. It should be `#0ff`. Actually it should be `#00f`.

  • 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

    I would have thought LaTeX would typeset the `Vo` kerning prettier... But apparently it considers each letter separately due to the colours.

    @sanchises Since each letter is in a separate command, I think it destroys proper kerning.

    Yeah exactly. Although I'm sure it would be possible somehow if golfing was not a requirement.

    @sanchises this is definitely possible, but this is indeed longer than this ugly solution.

    `\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.

    @AndreïKostyrka Thanks!

    `\documentclass{proc}\input color\begin{document}\def\y{\color{blue}}\color{red}{I{\y~V}o{\y t}e{\y d}\enddocument` saves 13 more bytes. By the way, `\input color` doesn't work for me (`\usepackage{color}` does). What version of pdflatex are you using (`pdflatex --version`)? I'm using 3.14159265-2.6-1.40.17 (TeX Live 2016).

  • 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

    You can golf it down by 1 byte if you use `@color fc&echo I`...

    interesting, I didn't realise Windows terminal supported ANSI escape sequences

    @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.

    @wizzwizz4 ConEmu supports these too :) Indeed this is from Windows 10 anniversary (ie redstone 1)

    @Asu I installed XP over it.

  • 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

    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)``

    Doesn't work in Node.js either. :(

    I was surprised this actually works, but it does.

  • 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

    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.)

    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)`.

    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.

    Aren't the colours off? Shouldn't the "I" and "V" be different colours?

    If the colours aren't wrong, then `plot(7:1,0:6/Inf,pc=el(strsplit("detoV I","")),co=1:2*2)` is 56 bytes.

    Fair enough: add a space, `plot(8:1,0:7*0,pc=el(strsplit("detoV I","")),co=1:2*2)` is 55 bytes. (Edit: SO automatically reduces a double space to one space, but there should be two in the quoted string! Also saved two bytes by replacing `\Inf` with `*0`)

    Did you correct for the SO auto-correct? (I.e. the string should be "d-e-t-o-V-space-space-I")

    @JDL I must be stupid somehow. Updated the answer, thanks!

    I'm pretty sure `el()` improves 99% of all previous `strsplit` answers by 1 byte.

    Brings it back up to 60, but gets the colors correct as specified: `plot(c(1,3:7),0:5*0,pc=c("I","V","o","t","e","d"),co=c(2,4))` (red `I`, blue `V`).

    @JonathanCarroll I just changed `1:2*2` to `2:1*2` instead. Thanks, didn't notice the colors were still wrong though.

  • 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
    s(a,0,0)p('I o e')s(0,0,a)p(' V t d')end



    Fully ungolfed version:

    function love.draw()
    love.graphics.print('I o e')
    love.graphics.print(' V t d')

    I löve that you used something other than Java.

    So many 255… A variable for them?

    @manatwork Yep. Not sure how that slipped by. Thanks!

    I don't know the language--what would a full program look like?

    @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.

    @Geobits Whoa, that's pretty nifty.

    does lua support hexnumber literals? if so, you *could* change a=255 to a=FF.

    Not as a bare `FF`, no :/

    How come the spaces in the second `print` don't overwrite the chars in the first?

    @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".

    Can't you remove the alpha parameter while setting the colour, like `l.setBackgroundColor(a,a,a)`?

    @KritixiLithos Huh. I didn't even check that since there wasn't an overload listed like that for `setColor()`, but it appears it works for both. Thanks!

    And also, can you not shorten the `setBackgroundColor` by calling it with just one parameter `setBackgroundColor(a)` like my Processing answer?

    No, there is a one-arg variant, but it expects an rgb packed-int, so it ends up being longer that way.

    ever since I'm reading this site, this is the first LÖVE answer I see. I'm honestly touched

    @ZoltánSchmidt Thanks! There are a few other LÖVE answers, if you want to take a look through them :D

  • Hot Soup Processor, 48 bytes

    color 255
    mes"I o e
    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

    Why don't the spaces in the second `mes` overwrite the first?

    @cat Spaces don't actually draw anything, it just advances the cursor position in a sense

    Clever using -1 for 255. Have a +1

    @Cyoce Or maybe it's actually -255?

License under CC-BY-SA with attribution

Content dated before 7/24/2021 11:53 AM