59
\$\begingroup\$

XKCD #99, with the title "Binary Heart" shows a simple image of ones and zeros, with some digits colored red.

enter image description here

The red heart is visible to the naked eye, but the message hidden in the binary sequence is not. If you remove all the spaces and newlines and interpret the binary sequence as 8 bit ASCII-code, you'll end up with the message:

iloveyOuilOveyouiloveyOuilOveyOuiloveyouilOveyouilOveyOuilOv

Cute right?

Pssst... The string isn't a pure string repetition.


Your challenge is to create this binary image with 21 digits across, and 23 digits down. There should be exactly one space between each digit in each row, and one newline for each new row. Note that the last bits are only the beginning of the letter e, since 21*23 isn't divisible by 8. You need those bits correct too.

The function or program should not take any input. Leading and trailing spaces and newlines are accepted.

The result of your code should look like this:

0 1 1 0 1 0 0 1 0 1 1 0 1 1 0 0 0 1 1 0 1
1 1 1 0 1 1 1 0 1 1 0 0 1 1 0 0 1 0 1 0 1
1 1 1 0 0 1 0 1 0 0 1 1 1 1 0 1 1 1 0 1 0
1 0 1 1 0 1 0 0 1 0 1 1 0 1 1 0 0 0 1 0 0
1 1 1 1 0 1 1 1 0 1 1 0 0 1 1 0 0 1 0 1 0
1 1 1 1 0 0 1 0 1 1 0 1 1 1 1 0 1 1 1 0 1
0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 1 0 0 0 1 1
0 1 1 1 1 0 1 1 1 0 1 1 0 0 1 1 0 0 1 0 1
0 1 1 1 1 0 0 1 0 1 0 0 1 1 1 1 0 1 1 1 0
1 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 1 0 0 0 1
0 0 1 1 1 1 0 1 1 1 0 1 1 0 0 1 1 0 0 1 0
1 0 1 1 1 1 0 0 1 0 1 0 0 1 1 1 1 0 1 1 1
0 1 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 1 0 0 0
1 1 0 1 1 1 1 0 1 1 1 0 1 1 0 0 1 1 0 0 1
0 1 0 1 1 1 1 0 0 1 0 1 1 0 1 1 1 1 0 1 1
1 0 1 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 1 0 0
0 1 0 0 1 1 1 1 0 1 1 1 0 1 1 0 0 1 1 0 0
1 0 1 0 1 1 1 1 0 0 1 0 1 1 0 1 1 1 1 0 1
1 1 0 1 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 1 0
0 0 1 0 0 1 1 1 1 0 1 1 1 0 1 1 0 0 1 1 0
0 1 0 1 0 1 1 1 1 0 0 1 0 1 0 0 1 1 1 1 0
1 1 1 0 1 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 1
0 0 0 1 0 0 1 1 1 1 0 1 1 1 0 1 1 0 0 1 1

This is code golf, so the shortest answer (in bytes) wins.


Leaderboard

var QUESTION_ID=94699,OVERRIDE_USER=31516;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>

\$\endgroup\$
7
  • 1
    \$\begingroup\$ I want you to know right now I'll find a way somehow? \$\endgroup\$ Sep 27, 2016 at 15:50
  • 25
    \$\begingroup\$ I will give a bounty to the shortest code which colours the output using red and black to make the heart \$\endgroup\$
    – Beta Decay
    Sep 27, 2016 at 21:56
  • \$\begingroup\$ I'm even more curious to know what the hidden message is in the capitalized Os from the ASCII output string! \$\endgroup\$ Sep 29, 2016 at 19:19
  • \$\begingroup\$ There is no message, or at least none has been discovered by explainxkcd.com who say "The mixture of upper-case and lower-case "O"s is presumed intentional to avoid a repeating pattern." \$\endgroup\$ Sep 29, 2016 at 20:45
  • 1
    \$\begingroup\$ @WeeingIfFirst Haha, you overestimate my programming skill :). I'll award the winner with a 100 rep bounty as well, when I can \$\endgroup\$
    – Beta Decay
    Oct 5, 2016 at 19:29

27 Answers 27

42
\$\begingroup\$

Jelly, 41 40 35 33 bytes

Thanks to @Dennis for making the end ṖṖCG! (complement C = 1-x in place of logical not ¬ )

“ƝƓỊ⁹Ȥ⁶Ị⁺‘ẋ8_“¤ÐŒ#'/‘¦32BFs21ṖṖCG

TryItOnline

How?

“ƝƓỊ⁹Ȥ⁶Ị⁺‘ẋ8_“¤ÐŒ#'/‘¦32BFs21ṖṖCG - Main link: no arguments
“ƝƓỊ⁹Ȥ⁶Ị⁺‘                        - code page indexes [150,147,176,137,154,134,176,138]
                                        (bitwise negated values of ordinals of "ilOveyOu")
          ẋ8                      - repeat eight times
            _                     - subtract
                     ¦            - apply to indexes
             “¤ÐŒ#'/‘             - code page indexes [3,15,19,35,39,47]
                                        (the indexes of the lowercase Os)
                      32          - literal 32 (subtracting 32 from the bitwise negated
                                                'O's makes them bitwise negated 'o's)
                        B         - binary (all are 8 bits, hence the negation)
                         F        - flatten list
                          s21     - split into slices of length 21
                             ṖṖ   - pop (remove the last two slices)
                               C  - complement (transform the bits to what they should be)
                                G - format as a grid
                                        (inserts both the spaces and line feeds)

"Colour" version, 77 bytes

“¤Ɓ¥J¬ ¥ƲėNėR½5ðḃḍCṬ’b19‘“Y^‘jĖŒṙḂ
“ƝƓỊ⁹Ȥ⁶Ị⁺‘ẋ8_“¤ÐŒ#'/‘¦32BFż¢Ḅị“¹0°1”s21ṖṖG

TryItOnline

Jelly has no colour output, but this is much easier for me to see anyway (I am colour blind)...

° ¹ ¹ ° ¹ ° ° ¹ ° ¹ ¹ ° ¹ ¹ ° ° ° ¹ ¹ ° ¹
¹ ¹ ¹ ° ¹ ¹ ¹ ° ¹ ¹ ° ° ¹ ¹ ° ° ¹ ° ¹ ° ¹
¹ ¹ ¹ ° ° ¹ ° ¹ ° ° ¹ ¹ ¹ ¹ ° ¹ ¹ ¹ ° ¹ °
¹ ° ¹ ¹ ° ¹ ° ° ¹ ° ¹ ¹ ° ¹ ¹ ° ° ° ¹ ° °
¹ ¹ ¹ ¹ ° 1 1 1 ° ¹ ¹ ° ° 1 1 0 ° ¹ ° ¹ °
¹ ¹ ¹ 1 0 0 1 0 1 1 ° 1 1 1 1 0 1 1 ¹ ° ¹
° ¹ ° 1 1 0 1 0 0 1 ° 1 1 0 1 1 0 0 ° ¹ ¹
° ¹ ¹ 1 1 0 1 1 1 0 1 1 0 0 1 1 0 0 1 ° ¹
° ¹ 1 1 1 0 0 1 0 1 0 0 1 1 1 1 0 1 1 ¹ °
¹ ° 1 0 1 1 0 1 0 0 1 0 1 1 0 1 1 0 0 ° ¹
° ° ¹ 1 1 1 0 1 1 1 0 1 1 0 0 1 1 0 0 ¹ °
¹ ° ¹ 1 1 1 0 0 1 0 1 0 0 1 1 1 1 0 ¹ ¹ ¹
° ¹ ° ¹ 0 1 1 0 1 0 0 1 0 1 1 0 ¹ ¹ ° ° °
¹ ¹ ° ¹ ¹ 1 1 0 1 1 1 0 1 1 0 0 ¹ ¹ ° ° ¹
° ¹ ° ¹ ¹ ¹ 1 0 0 1 0 1 1 0 1 ¹ ¹ ¹ ° ¹ ¹
¹ ° ¹ ° ¹ ° ¹ 1 0 1 0 0 1 0 ¹ ¹ ° ¹ ¹ ° °
° ¹ ° ° ¹ ¹ ¹ ¹ 0 1 1 1 0 ¹ ¹ ° ° ¹ ¹ ° °
¹ ° ¹ ° ¹ ¹ ¹ ¹ ° 0 1 0 ¹ ¹ ° ¹ ¹ ¹ ¹ ° ¹
¹ ¹ ° ¹ ° ¹ ° ¹ ¹ ° 1 ° ° ¹ ° ¹ ¹ ° ¹ ¹ °
° ° ¹ ° ° ¹ ¹ ¹ ¹ ° ¹ ¹ ¹ ° ¹ ¹ ° ° ¹ ¹ °
° ¹ ° ¹ ° ¹ ¹ ¹ ¹ ° ° ¹ ° ¹ ° ° ¹ ¹ ¹ ¹ °
¹ ¹ ¹ ° ¹ ° ¹ ° ¹ ¹ ° ¹ ° ° ¹ ° ¹ ¹ ° ¹ ¹
° ° ° ¹ ° ° ¹ ¹ ¹ ¹ ° ¹ ¹ ¹ ° ¹ ¹ ° ° ¹ ¹

How?

“¤Ɓ¥J¬ ¥ƲėNėR½5ðḃḍCṬ’b19‘“Y^‘jĖŒṙḂ - Link 1: no arguments
“¤Ɓ¥J¬ ¥ƲėNėR½5ðḃḍCṬ’              - base 250 of a big number
                     b19           - convert to base 19, yields a list of integers
                        ‘          - increment those numbers
                         “Y^‘      - get code page indexes [89,94]
                             j     - join: [89,3,5,3,8, ... ,3,19,1,94]
                                         - {left-right, top-bottom} runs of colours
                              Ė    - enumerate [[1,89],[2,3],[3,5],[4,3],[5,8], ...]
                               Œṙ  - run-length decode [89 1s, 3 2s, 5 3s, 3 4s, 8 5s, ...]
                                 Ḃ - mod 2

“ƝƓỊ⁹Ȥ⁶Ị⁺‘ẋ8_“¤ÐŒ#'/‘¦32BFż¢Ḅị“¹0°1”s21ṖṖG - Main link: no arguments
“ƝƓỊ⁹Ȥ⁶Ị⁺‘ẋ8_“¤ÐŒ#'/‘¦32BF                 - same as the original to get 1s and 0s
                          ż                - zip with
                           ¢               - last link (1) as a nilad
                            Ḅ              - binary to integer (vectorises)
                             ị             - index into
                              “¹0°1”       - string "¹0°1"
                                    s21    - split into length 21 slices
                                       ṖṖ  - pop last two unused slices
                                         G - format as a grid
\$\endgroup\$
13
  • 27
    \$\begingroup\$ If you remove the¬ , the last four bytes can become ṖṖCG. :) \$\endgroup\$
    – Dennis
    Sep 28, 2016 at 16:38
  • 2
    \$\begingroup\$ Oh wow, of course - that just has to be done! \$\endgroup\$ Sep 28, 2016 at 16:47
  • 1
    \$\begingroup\$ Pardon my pedantry; perhaps the proper term is complement? \$\endgroup\$
    – Sherlock9
    Oct 2, 2016 at 16:26
  • \$\begingroup\$ @Sherlock9, yep; fixed & thanks - I can't spell all that well, so will often get words wrong if spellchecking gives no flag! \$\endgroup\$ Oct 2, 2016 at 22:35
  • \$\begingroup\$ @WeeingIfFirst - I didn't check, but hope this is still good enough to be considered coloured. \$\endgroup\$ Oct 6, 2016 at 10:36
41
\$\begingroup\$

Actually, 58 bytes

73*8╙:13542├`≈"÷≥"E`M"«%s₧ªn%s6û"7*%"♠n≥6û"+¿├`' +`M╪♂Σ♂Ri

Try it online!

Explanation

There are three main parts here, so I'm going to break it down accordingly.

Part 1: Constructing the base-256 string

We're actually going to construct the binary string reversed, to take advantage of Actually's stack-based (LIFO) structure and to avoid complications with leading zeros in the binary string. Thus, the target binary string is 110011011101111001000110110100101101010111011110010100111101010011001101110111100100011011010010110101011101111011010011110101001100110111011110010001101101001011010101110111101101001111010100110011011101111011000110110100101101010111011110010100111101010011001101110111100100011011010010110101011101111001010011110101001100110111011110110001101101001011010101110111101101001111010100110011011101111001000110110100101101010111011110010100111101010011001101110111101100011011010010110, which is equivalent to 20083405242288679348048842451418880256193335738939042905519679590571514414673488599852759703515507690399267425671627412178904636115120346432419478 in decimal. In base-256 (using the CP437 character table for conversion), the corresponding string is ♠n≥6û«≥₧ªn≥6û«÷₧ªn≥6û«÷₧ªn÷6û«≥₧ªn≥6û«≥₧ªn÷6û«÷₧ªn≥6û«≥₧ªn÷6û. To construct the original binary string, we construct the base-256 string (taking advantage of the pattern in it), and perform base conversions to decimal and binary.

The base-256 string has the following format (spaces and newlines added for clarity):

♠n≥6û
« (either ≥ or ÷) ₧ªn (either ≥ or ÷) 6û
  (7 times)

Thus, each of the 7 middle sections can be formed by using the scaffold «%s₧ªn%s6û and replacing the %s parts with either or ÷.

The specific sequence of s and ÷s we need is ≥≥÷≥÷÷≥≥≥÷÷≥≥÷. Since we need this as a list of length-1 strings, the naïve way of representing this would be "≥≥÷≥÷÷≥≥≥÷÷≥≥÷"# (push the string, make it into a list). However, we can do slightly better. By interpreting that string as a binary number (where represents 1 and ÷ represents 0), we get 13542 in decimal. By converting this back to binary (using the traditional 1s and 0s), and indexing into a length-2 string, we can get the list using one less byte than the naïve method.

:13542├`≈"÷≥"E`M"«%s₧ªn%s6û"7*%"♠n≥6û"+
:13542├                                  push 13542, convert to binary
       `≈"÷≥"E`M                         for each bit:
        ≈                                  convert to integer (from string)
         "÷≥"E                             index into "÷≥"
                "«%s₧ªn%s6û"7*           push the scaffold for the middle section
                              %          old-style Python string formatting to fill in the scaffold
                               "♠n≥6û"+  prepend the beginning piece

Part 2: Converting to binary

This part is much more straightforward. If Actually had the capability to directly convert base-256 to binary, we'd use that. Unfortunately, it doesn't, so we'll have to use decimal as an intermediary format.

The , in the following code represents the code from Part 1 - for explanatory purposes, I've replaced the Part 1 code with , to read the output from Part 1 from STDIN. It is not part of the actual final code.

8╙,¿├
  ,    Part 1 result
8╙ ¿   convert from base-256 to decimal
    ├  convert to binary

Part 3: Formatting

If the challenge was to merely output the binary string as-is, we'd be done. However, we still have some formatting to do to get the binary string into a 21 x 23 rectangle.

As in Part 2, the , represents the output from the previous part, and is not part of the actual code.

73*,`' +`M╪♂Σ♂Ri
   ,              output from Part 2
    `' o`M        insert a space after every character
73*       ╪       chunk into 21 pieces
           ♂Σ     concatenate each piece
             ♂R   reverse each piece
               i  flatten
                  (implicitly print)

For those keeping track at home, this is the equivalent Python 3 code (481 bytes):

print('\n'.join([''.join(' '+c for c in bin(sum('\x00☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■\xa0'.index(c)*256**i for i,c in enumerate(("♠n≥6û"+("«%s₧ªn%s6û"*7)%tuple("÷≥"[int(b)]for b in bin(13542)[2:]))[::-1])))[2:])[i*42:-~i*42][::-1]for i in range(23)][::-1]))
\$\endgroup\$
8
  • 46
    \$\begingroup\$ You know, it's programming like this that makes me believe the Egyptians where actually very advanced and successful programmers and hieroglyphics was simply their language of choice. +1 \$\endgroup\$
    – MonkeyZeus
    Sep 27, 2016 at 14:27
  • \$\begingroup\$ What language was this? Also, is this answer compiled? \$\endgroup\$
    – Jack
    Sep 29, 2016 at 14:47
  • \$\begingroup\$ @Jack This is Actually. No compilation involved. \$\endgroup\$
    – user45941
    Sep 29, 2016 at 14:47
  • 1
    \$\begingroup\$ @Mego :0 You are a BOSS then for writing this code \$\endgroup\$
    – Jack
    Sep 29, 2016 at 14:49
  • 1
    \$\begingroup\$ What happens if you need the digit 34 in a base 256 number? (the string enclosing character) \$\endgroup\$ Oct 6, 2016 at 11:48
22
\$\begingroup\$

JavaScript (ES6), 169 ... 136 135 bytes

let f =

_=>"0213021203131214".replace(x=/./g,v=>0+[a=1768714102,a-8192,a-=66265089,a+8192,3][v].toString(2)).replace(x,(c,i)=>` 
`[+!(i%21)]+c)

console.log(f());

Saved 2 bytes thanks to Andrakis
Saved 4 bytes thanks to Hedi
Saved 3 5 bytes thanks to Neil

Colored version, 249 bytes (237 bytes of JS + 12 bytes of CSS)

The JS code outputs the ASCII art with bold tags for the heart. 12 bytes of CSS are required to colorize in red. (Is that byte count fair?)

let f =

_=>"0213021203131214".replace(x=/./g,v=>0+[a=1768714102,a-8192,a-=66265089,a+8192,3][v].toString(2)).replace(x,(c,i)=>` 
`[+!(y=i/21|0,x=i%21)]+([57568,a=261112,a,b=524280,b+4,b+4,b,a+1024,65520][y-4]&1<<x|y>12&x>y-9&x<29-y?c.bold():c))

document.getElementById("o").innerHTML = f();
b{color:red}
<pre id="o"></pre>

\$\endgroup\$
4
  • 2
    \$\begingroup\$ You can save some bytes by replacing your replace: s=>s.replace(/./g,'$& '). I've been working on a pretty much identical solution. \$\endgroup\$
    – Andrakis
    Sep 27, 2016 at 14:44
  • 1
    \$\begingroup\$ Couldn't s.replace(/./g,'$& ') be replaced by s.split``.join` `? \$\endgroup\$
    – Hedi
    Sep 27, 2016 at 17:11
  • 2
    \$\begingroup\$ [...s].join` ` \$\endgroup\$
    – Neil
    Sep 27, 2016 at 19:37
  • 1
    \$\begingroup\$ I think replace(/./g,(c,i)=>c+=++i%21?' ':'\n') (obviously using a literal newline there) saves a further byte. There may well be an even better way of expressing that idea. \$\endgroup\$
    – Neil
    Sep 27, 2016 at 19:51
21
\$\begingroup\$

Jelly, 36 33 32 bytes

“ḅUɗaṚPXṙ’Bṁ484¬“½:J⁺ȤṾ‘Ḥ¤¦Ḋs21G

Thanks to @JonathanAllan for golfing off 3 bytes!

Try it online!

How it works

The main link

“ḅUɗaṚPXṙ’Bṁ484¬“½:J⁺ȤṾ‘Ḥ¤¦Ḋs21G

is executed niladically (i.e., without any arguments) when the program is run. Its return value will be printed implicitly.

“ḅUɗaṚPXṙ’

find the indices of the quoted characters in Jelly's code page and interprets them as digits of a bijective base 250 number. This yields the integer 13021639057551959994.

          B

converts the generated integer to binary. This yields the bit array 1011010010110110001001111011101100110010101111001010011110111010 which corresponds to the UTF-8 encoding of the string ilOveyOu, shifted one bit to the left.

Shifting is necessary because B cannot return a bit array with a leading 0. Other options include negating the binary digits or computing the square in reverse, but this approach saves one byte.

            ṁ484

molds the generated array like the range from 1 to 484, i.e., it repeats the contents of the array as many times as necessary to achieve a length of 484.

This is one more bit than we need, to account for the shift. We could remove the first bit now, but doing so later means that all bits that have to get swapped lie at even indices, which allows us to save the aforementioned byte.

                 “½:J⁺ȤṾ‘Ḥ¤

takes the code points of the characters between and ([10, 58, 74, 138, 154, 186]), then "unhalves" them, i.e., multiples them by 2 ([20, 116, 148, 276, 308, 372]).

                ¬           ¦

conditionally negates the bits at those indices. This corresponds to the O/o variations in the original pattern.

Finally,

                             Ḋs21G

dequeues the bit array (removing the first bit), splits the remaining array into rows of 21 elements and prints the resulting matrix as a grid.

\$\endgroup\$
4
  • 2
    \$\begingroup\$ You can save 3 more bytes by having uppercase O as the default, I think this does it: “ỊḂr×C)ḃȯ’B¬ṁ483¬“Œ` ° @‘+\¤¦s21G \$\endgroup\$ Sep 28, 2016 at 3:27
  • \$\begingroup\$ Right, there are more uppercase O's than lowercase ones. Thanks! \$\endgroup\$
    – Dennis
    Sep 28, 2016 at 4:03
  • 4
    \$\begingroup\$ So this is what black magic looks like.. \$\endgroup\$ Sep 28, 2016 at 11:21
  • 2
    \$\begingroup\$ @BassdropCumberwubwubwub Now there should be effort to turn it into red and black magic \$\endgroup\$ Mar 22, 2017 at 10:37
20
\$\begingroup\$

05AB1E, 77 54 53 44 43 41 bytes

Uses CP-1252 encoding.

’i„΀î’8ו1žä¿*•S·£™J¦'iìÇb0ìJ011JSðý42ô»

Explanation

’i„Î€î’   # the string "iloveyou"
8×        # repeated 8 times
•1žä¿*•   # the number 3262264221 encoded in base 214
S·        # split to list and multiplied by 2, gives [6, 4, 12, 4, 4, 12, 8, 4, 4, 2]
£         # split the "iloveyou..." string into chunks of these lengths
™J        # title-case the chunks and join, giving the string with capitalized O's
¦'iì      # replace the faulty capitalized "I" in the beginning with a lower case "i"
Ç         # convert to list of ascii values
b0ì       # convert each to binary and prepend a 0 to each binary string
J011J     # join the strings and append "011"
Sðý       # add a space between each digit
42ô       # split in pieces of 42 (21 digits, 21 spaces)
»         # merge on newline

Try it online!

\$\endgroup\$
3
  • 3
    \$\begingroup\$ You seem to have a relevant profile picture \$\endgroup\$
    – tomsmeding
    Sep 28, 2016 at 6:08
  • 3
    \$\begingroup\$ @tomsmeding: Indeed! He drew me a hat guy when we met a couple of years ago, so that's who I am now :) \$\endgroup\$
    – Emigna
    Sep 28, 2016 at 6:10
  • \$\begingroup\$ I know it's been 2.5 years, but you can golf the Sðý42ô» to S21ô», since » joins inner lists by spaces implicitly (and the •1žä¿*• should now be •Å¾$6•, since integers are encoded in base-255 now instead of base-214). \$\endgroup\$ Jan 28, 2019 at 17:00
15
\$\begingroup\$

CJam, 48 bytes

19560Yb"Oo"f="uilvey"8*3/.\s:i2fb0a*7>21/W<Sf*N*

Collaboration with @MartinEnder, who took off a tricky 3 bytes with the "uilvey"3/ string. Online interpreter.

19560Yb        Convert 19560 to base 2
"Oo"f=         Index each bit into the string "Oo" to give "ooooOOooOOOooOoOOO"
"uilvey"8*3/   Repeat the string "uilvey" 8 times then split into chunks of 3
.\s            Vectorised swap (insert the Os into the right places) then stringify
:i2fb          Convert each char to int then take base 2
0a*            Join with 0s
7>             Remove the first 7 bits
21/            Split into chunks of length 21
W<             Drop the last row
Sf*            Join each row with spaces
N*             Join the rows with newlines
\$\endgroup\$
12
+50
\$\begingroup\$

Javascript ES6 REPL, 124 121 119 113 bytes

Saved 6 bytes thanks to @ETHproductions

This is a full program which can be pasted in the REPL/console to produce the correct result.

for(i=r='';i<483;)r+=(`il${"Oo"[21>>i/64&1]}vey${"oO"[77>>i/64&1]}u`.charCodeAt(i/8%8)>>7-i%8&1)+(++i%21?` `:`
`)

f=

_=>{for(i=0,r='';i<483;)r+=(`il${"Oo"[21>>(a=i/64)&1]}vey${"oO"[77>>a&1]}u`.charCodeAt(i/8%8)>>7-i%8&1)+(++i%21==0?`
`:` `);return r}

a.innerHTML = f()
<pre id=a>

More verbose

for (i=0, r='';                         // r == the result
     i < 483;)                          // 483 == 21 * 23
r+= (                                   // construct "iloveyou"
        `il${                           // il
            "Oo"[21 >> (a = i/64) & 1]  // position in the loop defines the o or O
         }vey${                         // vey
            "oO"[77 >> a & 1]           // position in the loop defines the o or O
         }u`                            // u
        .charCodeAt(                    // "i" == 105 == 01101001
            i / 8 % 8                   // find the correct bit to append
        ) >> 7-i%8 & 1                  // shift it to select 1 or 0
    )
+                                       // add a space or newline
    (
        ++i%21 == 0 ? `
` : ` `                                 // every 21 characters add a new line, 
                                           otherwise a space
    )
;                                       // Javascript implicitly returns the last value 
                                           edited in a for loop

Coloured JavaScript only heart, 281 bytes

for(i=z=r='',h=[],g=[90,...[...'353871767176G4H4H5G5F7CABB9D7F5H3J1'].map(n=>parseInt(n,20)),-1];i<483;)r+=`%c`+(`il${"Oo"[21>>i/64&1]}vey${"oO"[77>>i/64&1]}u`.charCodeAt(i/8%8,--g[+z]||z++,h[i]=z%2)>>7-i%8&1)+(++i%21?` `:`
`);console.log(r,...h.map(H=>`color:${H?'red':'black'}`))

This works by switching colours every n bits and makes use of the console.log ability to log colours

Coloured CSS Heart, 229+12 bytes

If using css is allowed, the coloured heart can be reduced even further to 229 bytes of JavaScript code and 12 bytes of CSS

for(i=z=r='',g=[90,...[...'353871767176G4H4H5G5F7CABB9D7F5H3J1'].map(n=>parseInt(n,20)),-1];C=`il${"Oo"[21>>i/64&1]}vey${"oO"[77>>i/64&1]}u`.charCodeAt(i/8%8,--g[+z]||z++)>>7-i%8&1,i++<483;)r+=(z%2?(''+C).bold():C)+(i%21?` `:`
`)

let f = 
    
    _=>{for(i=z=r='',g=[90,...[...'353871767176G4H4H5G5F7CABB9D7F5H3J1'].map(n=>parseInt(n,20)),-1];C=`il${"Oo"[21>>i/64&1]}vey${"oO"[77>>i/64&1]}u`.charCodeAt(i/8%8,--g[+z]||z++)>>7-i%8&1,i++<483;)r+=(z%2?(''+C).bold():C)+(i%21?` `:`
`);return r}

document.getElementById("b").innerHTML = f();
b{color:red}
<pre id="b">

\$\endgroup\$
7
  • \$\begingroup\$ Reason I did it this way is because this can be considered a full program. There are no hardcoded variables which should be changed by the user, instead this can be copy pasted and it works as is. I call it a snippet but it might as well be a full program. Thoughts? \$\endgroup\$ Sep 27, 2016 at 14:34
  • \$\begingroup\$ It relies on REPL behavior, which means the language is "Javascript ES6 REPL" (source). \$\endgroup\$
    – user45941
    Sep 27, 2016 at 14:35
  • \$\begingroup\$ @Mego Thanks, edited my answer accordingly \$\endgroup\$ Sep 27, 2016 at 14:38
  • 1
    \$\begingroup\$ I'm pretty sure you can get rid of a and just use num>>i/64&1 in both places, saving 1 byte. Also, ++i%21==0?newline:space is the same as ++i%21?space:newline. \$\endgroup\$ Oct 5, 2016 at 21:57
  • \$\begingroup\$ Another tip: change i=0,r='' to i=r=''; '' is automatically coerced to 0. \$\endgroup\$ Oct 6, 2016 at 2:24
9
\$\begingroup\$

MATL, 56 55 bytes

'!?u<TgGU*lB7SE1q3s.?Su(q6)iM'F'eilovyOu'Za8&B!FTTv21e!

Try it Online

Explanation

'!?u<TgGU*lB7SE1q3s.?Su(q6)iM'      % Previously compressed version of the string
F'eilovyOu'Za                       % Decompress this string
8&B                                 % Convert each char to 8-bit binary number
!                                   % Transpose the result
FTTv                                % Append [0 1 1] to the end to take care of 
                                    % the partial "e" bits
21e!                                % Reshape it into the appropriate shape
                                    % Implicitly display the result     
\$\endgroup\$
9
\$\begingroup\$

PowerShell v2+, (UTF-16) 300 bytes

Corrected erroneous byte count thanks to @Mego

'ږƍ໬ƕ๓ƺ֥˄ϝӊ༭ǝ֥ţϝɥޔǮ૒ƱϝIJ˲ӷʴ˘ͻ֙ץŻ઴Ŭɻˌʼֽ͖ҶɻŦʼʞݖɛĽƳ'-split'(..)'-ne''|%{(-join($_[0,1]|%{[convert]::ToString(+$_,2)})).PadLeft(21,'0')-replace'(.)','$1 '}

Not the shortest, but a different approach. I manually took each line and sliced them into pairs each (roughly) 9-11 significant bits in length. Converted each of those binary values to a char (Note: PowerShell uses UTF-16 by default, not UTF-8), and mushed that into a string. That's the '...' at the beginning.

We then -split that into strings of length 2, and loop through each pair. Those pairs are split into a char-array via $_[0,1], and each of those are cast as an int +$_, and [convert]ed into a binary (,2) String. That's -joined together into a single string, then PadLeft'd to get the proper length, then each element is -replaced with itself and a space '$1 '.

Those strings are all left on the pipeline, and output is implicit, with the default Write-Output sticking a newline between elements.

PS C:\Tools\Scripts\golfing> 'ږƍ໬ƕ๓ƺ֥˄ϝӊ༭ǝ֥ţϝɥޔǮ૒ƱϝIJ˲ӷʴ˘ͻ֙ץŻ઴Ŭɻˌʼֽ͖ҶɻŦʼʞݖɛĽƳ'-split'(..)'-ne''|%{(-join($_[0,1]|%{[convert]::ToString(+$_,2)})).PadLeft(21,'0')-replace'(.)','$1 '}
0 1 1 0 1 0 0 1 0 1 1 0 1 1 0 0 0 1 1 0 1 
1 1 1 0 1 1 1 0 1 1 0 0 1 1 0 0 1 0 1 0 1 
1 1 1 0 0 1 0 1 0 0 1 1 1 1 0 1 1 1 0 1 0 
1 0 1 1 0 1 0 0 1 0 1 1 0 1 1 0 0 0 1 0 0 
1 1 1 1 0 1 1 1 0 1 1 0 0 1 1 0 0 1 0 1 0 
1 1 1 1 0 0 1 0 1 1 0 1 1 1 1 0 1 1 1 0 1 
0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 1 0 0 0 1 1 
0 1 1 1 1 0 1 1 1 0 1 1 0 0 1 1 0 0 1 0 1 
0 1 1 1 1 0 0 1 0 1 0 0 1 1 1 1 0 1 1 1 0 
1 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 1 0 0 0 1 
0 0 1 1 1 1 0 1 1 1 0 1 1 0 0 1 1 0 0 1 0 
1 0 1 1 1 1 0 0 1 0 1 0 0 1 1 1 1 0 1 1 1 
0 1 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 1 0 0 0 
1 1 0 1 1 1 1 0 1 1 1 0 1 1 0 0 1 1 0 0 1 
0 1 0 1 1 1 1 0 0 1 0 1 1 0 1 1 1 1 0 1 1 
1 0 1 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 1 0 0 
0 1 0 0 1 1 1 1 0 1 1 1 0 1 1 0 0 1 1 0 0 
1 0 1 0 1 1 1 1 0 0 1 0 1 1 0 1 1 1 1 0 1 
1 1 0 1 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 1 0 
0 0 1 0 0 1 1 1 1 0 1 1 1 0 1 1 0 0 1 1 0 
0 1 0 1 0 1 1 1 1 0 0 1 0 1 0 0 1 1 1 1 0 
1 1 1 0 1 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 1 
0 0 0 1 0 0 1 1 1 1 0 1 1 1 0 1 1 0 0 1 1 
\$\endgroup\$
4
  • \$\begingroup\$ I count 300 UTF-16 bytes. Python 3: len("'ږƍ໬ƕ๓ƺ֥˄ϝӊ༭ǝ֥ţϝɥޔǮ૒ƱϝIJ˲ӷʴ˘ͻ֙ץŻ઴Ŭɻˌʼֽ͖ҶɻŦʼʞݖɛĽƳ'-split'(..)'-ne''|%{(-join($_[0,1]|%{[convert]::ToString(+$_,2)})).PadLeft(21,'0')-replace'(.)','$1 '}".encode('utf-16be')) \$\endgroup\$
    – user45941
    Sep 28, 2016 at 11:02
  • \$\begingroup\$ @Mego Oh, durr. Just because I'm counting UTF-16 for the string doesn't mean I get to magically count UTF-8 for the rest of the code. Hah. Thanks for the assist. \$\endgroup\$ Sep 28, 2016 at 12:42
  • \$\begingroup\$ Glad to help :) \$\endgroup\$
    – user45941
    Sep 28, 2016 at 12:43
  • \$\begingroup\$ If it didn't look so intimidating, I would actually open a PowerShell terminal and run it. \$\endgroup\$ Sep 30, 2016 at 16:44
6
\$\begingroup\$

///, 237 bytes

/2/\/\///3/0 24/1 25/0
26/1
27/4428/3329/772A/432B/A732C/937A782D/B48B72E/8A4892F/98B93/373A3A737837367A7A7878AA674E37A45D83A5C78A45F7A63D83463C78A639E3745AD8368C7845A9E3763AD8573C7863AF46AAD35348C735AAF673AD5848C753AA9E57AAB48B468348C41

Try it online!

\$\endgroup\$
4
\$\begingroup\$

Python 3, 147 144 bytes

lambda i=0:exec("print(' '.join(''.join('0'+bin(ord(chr(j+30)in' ,0@DL'and'o'or c))[2:]for j,c in enumerate('ilOveyOu'*8))[i:i+21]));i+=21;"*23)

Test it at ideone

Initialises i to 0 in the function declaration, then repeats this 23 times:
makes the whole binary string without spaces (see below);
slices a row from within using [i:i+21];
inserts the spaces with ' '.join(...);
prints; and
increments i by 21 with i+=21

To make the whole binary string:
it repeats "ilOveyOu" eight times;
replaces O with o where necessary (at indexes [2,14,18,34,38,46]);
- - - this is achieved with chr(j+30)in' ,0@DL' to save 3 bytes
converts each char to it's ordinal;
casts each ordinal to a binary string ('0bxxxxxxx');
removes the leading '0b' from each using [2:];
prepends each with a '0'; and
joins the whole thing up with ''.join(...)

\$\endgroup\$
2
  • \$\begingroup\$ You don't need a lambda. Do i=0\nexec(...) or i=0;exec(...) for 137 bytes. \$\endgroup\$
    – mbomb007
    Oct 5, 2016 at 13:47
  • \$\begingroup\$ Unless you really need Python 3, you can use Python 2 to change exec("...") to exec"..." and print(...) to print... \$\endgroup\$
    – mbomb007
    Oct 5, 2016 at 13:53
4
\$\begingroup\$

Powershell, 110 bytes

'uil','vey'*8|%{$s+=$_+'oOOooOOOooOoOOO'[$i++]}
-join(8..490|%{(+$s[$_-shr3]-shr(7-$_%8))%2
' 
'[!(++$j%21)]})

Explanation:

The first line of the script takes the substrings and inserts a letter O between them. The result is the string uiloveyOuilOveyouiloveyOuilOveyOuiloveyouilOveyouilOveyOuilOvey. Note that the first and last characters are redundant.

The loop outputs all the necessary (8..490) bits from the characters of the string, as well as a space or a line feed.

The riddle of the recipient of the valentine letter

It can be seen that small and large symbol O themselves make up the bit encoding. There are 15 symbols (bits). There is only one partition on the bits to get ASCII characters: oOOooOOO+ooOoOOO[o]. We had to add a small o instead of 0 at the end. This ASCII symbols are: g.

Who is this mysterious g.?

\$\endgroup\$
3
\$\begingroup\$

PHP+HTML+CSS, 173 Bytes Colored 367 Bytes

CLI only PHP 173 Bytes

$o=2841;for($i=0;$i<16;)$t.=il.Oo[$o>>$i++&1].vey.Oo[$o>>$i++&1].u;foreach(str_split($t)as$c)$x.="0".decbin(ord($c));for($i=0;$i<504;$i++){$i%21?:print"\n";echo$x[$i]." ";}}

conform to the bounty spec content type text/html

<?=gzinflate(base64_decode("jVNbDoIwELwKJ9Ctn9hwF9HGmFQwiB+GeHcRd7ezvDQEAmWmMzuT+nv7jKG4dddDc75UOW124foqu0OM+aO6h3Z/rGPd5E04vfz2C/a3gjLXXzTcxG/pSem7xzr4hxhn2BZLZvfpDjRg/3FBjBWuL78fflsWAOVl0uWk8rmG3yDCMNnMLMsshHpq0jLVQLKj6RrIbHBCYoq6WclPHHJ+PNdqjEZlpLNgbaTy2xoTHAQ3kBasKZyg3/XUDAVV5urVcDE5mQXsGWugIJqikibVmcZTJIrL0Bq3NKdgjxhak2q5ukmpWuXS+QJPEBVi52vE025VJy7Yw18u3g==");

b{all:unset;color:red} instead of b{all:unset;color:#911;background:red} in the first version

PHP+HTML+CSS, 392 Bytes

heart red +black which looks more pretty

Maybe call the color number in the CSS Part

<?=gzinflate(base64_decode("jVTLDoIwELyb+A8m3nXrzdrwL7xijAgG8GAI/67WdpktD00DoWWmMztLMU37LPLo3t3i+nwpNe0O+a1Purgo9KNs8vaUVkVV6+1RqVMSp9dzXT3KTNd51pv9l7xemXtEG/UeZC9yT8OdhrlFK3iLKCX4IZqEwngPcuh/vBCjPd8k34nZJxGA3TLxMip9hgWAkAP67cTyUBOhJluVXDYxWIKsBWgyRE9jEntayNL75CxdfYuRBkqB1ozBkdJvg46iRIiWNmOQCSQ6vpygIEmlqYZz1LAN1AQmhUFQUfBBhjVzbWE1SFIbNOi6NqUSHkI06JvtmjlqMzR37gSCMxEboicbG/wVpPbICzv5y8sL"));

add this before it looks nicer

<style>*{word-spacing:1em;}</style>

Output first version it is the ugliest HTML Code in my live

red-black heart

<style>*{word-spacing:1em;}</style><style>p{margin:0.2em}b{all:unset;color:#911;background:red}</style>
<p>0 1 1 0 1 0 0 1 0 1 1 0 1 1 0 0 0 1 1 0 1
<p>1 1 1 0 1 1 1 0 1 1 0 0 1 1 0 0 1 0 1 0 1
<p>1 1 1 0 0 1 0 1 0 0 1 1 1 1 0 1 1 1 0 1 0
<p>1 0 1 1 0 1 0 0 1 0 1 1 0 1 1 0 0 0 1 0 0
<p>1 1 1 1 0 <b>1 1 1</b> 0 1 1 0 0 <b>1 1 0</b> 0 1 0 1 0
<p>1 1 1 <b>1 0 0 1 0 1 1</b> 0 <b>1 1 1 1 0 1 1</b> 1 0 1
<p>0 1 0 <b>1 1 0 1 0 0 1</b> 0 <b>1 1 0 1 1 0 0</b> 0 1 1
<p>0 1 1 <b>1 1 0 1 1 1 0 1 1 0 0 1 1 0 0 1</b> 0 1
<p>0 1 <b>1 1 1 0 0 1 0 1 0 0 1 1 1 1 0 1 1</b> 1 0
<p>1 0 <b>1 0 1 1 0 1 0 0 1 0 1 1 0 1 1 0 0</b> 0 1
<p>0 0 1 <b>1 1 1 0 1 1 1 0 1 1 0 0 1 1 0 0</b> 1 0
<p>1 0 1 <b>1 1 1 0 0 1 0 1 0 0 1 1 1 1 0</b> 1 1 1
<p>0 1 0 1 <b>0 1 1 0 1 0 0 1 0 1 1 0</b> 1 1 0 0 0
<p>1 1 0 1 1 <b>1 1 0 1 1 1 0 1 1 0 0</b> 1 1 0 0 1
<p>0 1 0 1 1 1 <b>1 0 0 1 0 1 1 0 1</b> 1 1 1 0 1 1
<p>1 0 1 0 1 0 1 <b>1 0 1 0 0 1 0</b> 1 1 0 1 1 0 0
<p>0 1 0 0 1 1 1 1 <b>0 1 1 1 0</b> 1 1 0 0 1 1 0 0
<p>1 0 1 0 1 1 1 1 0 <b>0 1 0</b> 1 1 0 1 1 1 1 0 1
<p>1 1 0 1 0 1 0 1 1 0 <b>1</b> 0 0 1 0 1 1 0 1 1 0
<p>0 0 1 0 0 1 1 1 1 0 1 1 1 0 1 1 0 0 1 1 0
<p>0 1 0 1 0 1 1 1 1 0 0 1 0 1 0 0 1 1 1 1 0
<p>1 1 1 0 1 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 1
<p>0 0 0 1 0 0 1 1 1 1 0 1 1 1 0 1 1 0 0 1 1

    <style>p{margin:0.2em}b{all:unset;color:red}</style>
    <p>0 1 1 0 1 0 0 1 0 1 1 0 1 1 0 0 0 1 1 0 1
    <p>1 1 1 0 1 1 1 0 1 1 0 0 1 1 0 0 1 0 1 0 1
    <p>1 1 1 0 0 1 0 1 0 0 1 1 1 1 0 1 1 1 0 1 0
    <p>1 0 1 1 0 1 0 0 1 0 1 1 0 1 1 0 0 0 1 0 0
    <p>1 1 1 1 0 <b>1 1 1</b> 0 1 1 0 0 <b>1 1 0</b> 0 1 0 1 0
    <p>1 1 1 <b>1 0 0 1 0 1 1</b> 0 <b>1 1 1 1 0 1 1</b> 1 0 1
    <p>0 1 0 <b>1 1 0 1 0 0 1</b> 0 <b>1 1 0 1 1 0 0</b> 0 1 1
    <p>0 1 1 <b>1 1 0 1 1 1 0 1 1 0 0 1 1 0 0 1</b> 0 1
    <p>0 1 <b>1 1 1 0 0 1 0 1 0 0 1 1 1 1 0 1 1</b> 1 0
    <p>1 0 <b>1 0 1 1 0 1 0 0 1 0 1 1 0 1 1 0 0</b> 0 1
    <p>0 0 1 <b>1 1 1 0 1 1 1 0 1 1 0 0 1 1 0 0</b> 1 0
    <p>1 0 1 <b>1 1 1 0 0 1 0 1 0 0 1 1 1 1 0</b> 1 1 1
    <p>0 1 0 1 <b>0 1 1 0 1 0 0 1 0 1 1 0</b> 1 1 0 0 0
    <p>1 1 0 1 1 <b>1 1 0 1 1 1 0 1 1 0 0</b> 1 1 0 0 1
    <p>0 1 0 1 1 1 <b>1 0 0 1 0 1 1 0 1</b> 1 1 1 0 1 1
    <p>1 0 1 0 1 0 1 <b>1 0 1 0 0 1 0</b> 1 1 0 1 1 0 0
    <p>0 1 0 0 1 1 1 1 <b>0 1 1 1 0</b> 1 1 0 0 1 1 0 0
    <p>1 0 1 0 1 1 1 1 0 <b>0 1 0</b> 1 1 0 1 1 1 1 0 1
    <p>1 1 0 1 0 1 0 1 1 0 <b>1</b> 0 0 1 0 1 1 0 1 1 0
    <p>0 0 1 0 0 1 1 1 1 0 1 1 1 0 1 1 0 0 1 1 0
    <p>0 1 0 1 0 1 1 1 1 0 0 1 0 1 0 0 1 1 1 1 0
    <p>1 1 1 0 1 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 1
    <p>0 0 0 1 0 0 1 1 1 1 0 1 1 1 0 1 1 0 0 1 1

375 Bytes for create the HTML Page with PHP directly

<?$o=2841;for(;$i<16;)$t.=il.Oo[$o>>$i++&1].vey.Oo[$o>>$i++&1].u;foreach(str_split($t)as$c)$x.="0".decbin(ord($c));$a=[1,9,20,28,41,49,62,82,103,125,146,168,190,212,234,256,278,300];$z=[3,11,26,34,47,55,77,98,119,140,160,179,200,220,240,260,280,300];for($i=0;$i<483;$i++)echo $i%21?"":"<p>",in_array($i-88,$a)?"<b style=color:red>":"",$x[$i],in_array($i-88,$z)?"</b>":""," ";
\$\endgroup\$
1
  • 2
    \$\begingroup\$ Just replacing color:#911;background:red with color:red; makes it conform to the bounty spec as well as saving a few bytes. \$\endgroup\$
    – Emigna
    Oct 5, 2016 at 12:22
3
\$\begingroup\$

C (gcc), 102 bytes

f(i){for(i=0;i<483;)printf("\n%2d"+!!(i++%21),(i/8%4^2|35609>>i/32&1?"iloveyou"[i/8%8]:79)>>7-i%8&1);}

Rundown

f(i){
for(i=0;i<483;)         Loop through bits.
printf("\n%2d"
+!!(i++%21),            Decide if newline in format string should be skipped.
(i/8%4^2|               Are we at a non-'o' letter?
                        (They occur every 4th letter, starting at index 2.)
35609>>i/32&1?          Check with magic number if the 'o' should be capital.
"iloveyou"[i/8%8]:      If not-'o' or not capital, use current letter.
79)                     Otherwise, use the letter 'O'.
>>7-i%8&1               Extract bit to write.
);}

Try it online!

\$\endgroup\$
3
\$\begingroup\$

q/kdb+, 107 93 85 55 53 bytes

Solution:

23 21#0 1(,/)0b vs'@[61#"ilOveyOu";0x020e1222262e;_:]

Example:

q)23 21#0 1(,/)0b vs'@[61#"ilOveyOu";0x020e1222262e;_:]
0 1 1 0 1 0 0 1 0 1 1 0 1 1 0 0 0 1 1 0 1
1 1 1 0 1 1 1 0 1 1 0 0 1 1 0 0 1 0 1 0 1
1 1 1 0 0 1 0 1 0 0 1 1 1 1 0 1 1 1 0 1 0
1 0 1 1 0 1 0 0 1 0 1 1 0 1 1 0 0 0 1 0 0
1 1 1 1 0 1 1 1 0 1 1 0 0 1 1 0 0 1 0 1 0
1 1 1 1 0 0 1 0 1 1 0 1 1 1 1 0 1 1 1 0 1
0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 1 0 0 0 1 1
0 1 1 1 1 0 1 1 1 0 1 1 0 0 1 1 0 0 1 0 1
0 1 1 1 1 0 0 1 0 1 0 0 1 1 1 1 0 1 1 1 0
1 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 1 0 0 0 1
0 0 1 1 1 1 0 1 1 1 0 1 1 0 0 1 1 0 0 1 0
1 0 1 1 1 1 0 0 1 0 1 0 0 1 1 1 1 0 1 1 1
0 1 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 1 0 0 0
1 1 0 1 1 1 1 0 1 1 1 0 1 1 0 0 1 1 0 0 1
0 1 0 1 1 1 1 0 0 1 0 1 1 0 1 1 1 1 0 1 1
1 0 1 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 1 0 0
0 1 0 0 1 1 1 1 0 1 1 1 0 1 1 0 0 1 1 0 0
1 0 1 0 1 1 1 1 0 0 1 0 1 1 0 1 1 1 1 0 1
1 1 0 1 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 1 0
0 0 1 0 0 1 1 1 1 0 1 1 1 0 1 1 0 0 1 1 0
0 1 0 1 0 1 1 1 1 0 0 1 0 1 0 0 1 1 1 1 0
1 1 1 0 1 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 1
0 0 0 1 0 0 1 1 1 1 0 1 1 1 0 1 1 0 0 1 1

Explanation:

23 21#0 1(,/)0b vs'@[61#"ilOveyOu";0x020e1222262e;_:] / the solution
                   @[             ;              ;  ] / apply[input;indices;function]
                                                  _:  / lowercase
                                   0x020e1222262e     / 2 14 18 34 38 46 represented in hex
                    61#"ilOveyOu"                     / 61 take "ilOveyOu" (wraps around)
             0b vs'                                   / convert into 8-bit representation
         (,/)                                         / flatten
      0 1                                             / index into 0 / 1 (convert from booleans)
23 21#                                                / reshape

Notes:

  • -2 bytes thanks to ngn!
\$\endgroup\$
2
\$\begingroup\$

PHP, 121 bytes

for($n=5682;$i++<60;)for($b=8;$b;)$p.=(1&ord(~$i&3||($n/=2)&1?uiloveyo[$i%8]:O)>>--$b)." ";echo wordwrap($p."0 1 1",42);

breakdown

$n=2*bindec("000101100011001"); // where to NOT replace o with O
for($i=1;$i<61;$i++)            // loop $i from 1 to 60
{
    $c=
        ~$i&3                       // $i%4!=3
        ||
        ($n/=2)&1                   // or (1. shift $n, 2. test bit 0)
        ? "uiloveyo"[$i%8]          // yes: character from string
        : "O"                       // no: uppercase "O"
    ;
    for($b=8;$b--;)                 // run from bit 7 to bit 0
        $p.=(1 & ord($c)>>$b). " ";     // append 1 or 0 plus space
}
$p.="0 1 1";                    // append the missing three bits
echo wordwrap($p,42);           // wrap at column 42 (actually 41; 42 is space -> gets cut)
\$\endgroup\$
2
\$\begingroup\$

K (oK), 50 48 bytes

Solution:

23 21#,/(8#2)\'@[61#"ilOveyOu";0x020e1222262e;_]

Try it online!

Explanation:

Port of my Q/KDB+ solution.

Notes:

  • -2 bytes thanks to ngn!
\$\endgroup\$
1
1
\$\begingroup\$

Python 3, 199 Bytes:

z='01111011101'
a='011010010110110001'
b=z+'10011001010111100101'
[print(' '.join(''.join([a+i[0]+b+i[1]+z+'01'for i in'10 01 10 00 11 01 00'.split()])+a+'0'+b[:16])[i:i+41])for i in range(0,966,42)]
\$\endgroup\$
1
\$\begingroup\$

Python 3, 170 bytes

from textwrap import*
print('\n'.join(' '.join(list(i))for i in wrap(''.join(bin(ord(i)+256)[3:]for i in (7*"il%svey%su")%(tuple("oOOooOOOooOoOO"))+"ilOv"),21))+" 0 1 1")

makes a string repetition of "Il%svey%su", repeats it the required number of times, then uses a tuple to sub all the o's in. it then converts it to binary, uses the textwrap module, converts each item of the new list to list, joins with space, then appends 0 1 1 because that seems to be a stub or something

\$\endgroup\$
1
\$\begingroup\$

Mathematica, 123 bytes (275 with color)

I'm not sure if using Grid instead of outputting a string is OK (if not then this is a non-competing entry).

B/W

Grid@Partition[ReplacePart[PadLeft[{},483,IntegerDigits[36^^nz4sp78k5qyb,2,64]],
Thread[51+32{0,1,4,5,6,9,11,12,13}->0]],21]

enter image description here

Color

Grid[Partition[ReplacePart[PadLeft[{},483,IntegerDigits[36^^nz4sp78k5qyb,2,64]],
Thread[51+32{0,1,4,5,6,9,11,12,13}->0]],21],ItemStyle->{{},{},Thread[Join@@MapIndexed[
Thread@{Range@@#,2+First@#2}&,Thread[Partition[IntegerDigits[36^^k32b741shmsoiwed4vnakt],
17]+{0,10}]]->Red]}]

enter image description here

\$\endgroup\$
1
  • \$\begingroup\$ Is it possible to copy/paste the result from grid in plain text and paste it into notepad? What does it look like? Space separated (single space) with newlines, as the figure shows? \$\endgroup\$ Oct 10, 2016 at 11:42
1
\$\begingroup\$

Ruby 142 Bytes

(('iloveyOuilOveyouiloveyOuilOveyOuiloveyouilOveyouilOveyOuilOv'.unpack('B*')[0]+'011').split(/(.{21})/)-['']).map{|i|puts(i.chars.join(' '))}

(Slightly more) legibly:

(('iloveyOuilOveyouiloveyOuilOveyOuiloveyouilOveyouilOveyOuilOv'.unpack('B*')[0]+'011') 
  # unpack turns it into a binary string, [0] takes the first element, and then we add on the trailing 011
.split(/(.{21})/) -['']) 
  # split it every group of 21 characters and remove the empty strings that are also included
.map { |i| puts(i.chars.join(' ')) } 
  # take each string of 21 characters, get its chars and join them with an empty string for formatting (puts takes care of the newlines)

I have not yet found a way to condense the original text into a more succinct form in Ruby - it has some great String manipulation functions, but all of the ways I've tried use more characters than the string itself. Any pointers appreciated, this is my first Code Golf on StackOverflow!

\$\endgroup\$
3
  • \$\begingroup\$ Welcome to Programming Puzzles and Code Golf Stack Exchange! Have you tried setting the string to a variable (e.g. a), then doing a+a+a...? Even better, if Ruby supports multiplication of strings, a*count! \$\endgroup\$
    – wizzwizz4
    Oct 8, 2016 at 8:01
  • \$\begingroup\$ @wizzwizz4, the string isn't pure string repetition. :) (There are likely better ways to do this though, but I don't think a+a+a is the way) \$\endgroup\$ Oct 10, 2016 at 11:44
  • \$\begingroup\$ I know! Make an all lower-case short version, repeat it, then replace the nth o with a capital O! \$\endgroup\$
    – wizzwizz4
    Oct 10, 2016 at 17:43
1
\$\begingroup\$

Rust, 195 bytes

||for(c,i)in"iloveyOuilOveyouiloveyOuilOveyOuiloveyouilOveyouilOveyOuilOve".bytes().fold(String::new(),|a,c|format!("{}0{:b}",a,c)).chars().zip(1..484){print!("{}{}",c,if i%21!=0{' '}else{'\n'})}

Ungolfed:

fn main(){
    // convert bytes of the string to binary numerals.
    let s = "iloveyOuilOveyouiloveyOuilOveyOuiloveyouilOveyouilOveyOuilOve"
        .bytes()
        .fold(String::new(),|a,c|format!("{}0{:b}",a,c));

    // print them over the range with newlines/spaces as appropriate
    for(c,i) in s.chars().zip(1..484) {
        print!("{}{}",c,if i%21!=0{' '}else{'\n'})
    }
}
\$\endgroup\$
1
\$\begingroup\$

Pyth, 47 bytes

jPcjdsm+0.BCdtPs.i*8c"uil vey"dmr\o!djC\䱨2 42

Try it online here.

jPcjdsm+0.BCdtPs.i*8c"uil vey"dmr\o!djC\䱨2 42   Implicit: d=" "
                    c"uil vey"d                  Chop "uil vey" on spaces, to yield ["uil" "vey"]
                  *8                             Repeat the above 8 times - {1}
                                      C\䱨       Character code of 䱨, yields 19560
                                     j    2      Convert the above to base 2
                               m                 Map the digits of the above, as d, using:
                                r\o!d            If d is 0, yield "O", otherwise "o" - {2}
                .i                               Interleave {1} with {2}
               s                                 Concatenate into a string
                                                   This yields "uiloveyOuilOveyouiloveyOuilOveyOuiloveyouilOveyouilOveyOuilOvey"
             tP                                  Remove first and last characters of the above
      m                                          Map each character, as d, using:
           Cd                                      Get character code
         .B                                        Convert to binary string
       +0                                          Prepend 0 (all binary strings will be length 7, so this pads to length 8)
     s                                           Flatten the result of the map
   jd                                            Join on spaces
  c                                        42    Chop into strings of length 42
 P                                               Discard the last, partial, string
j                                                Join on newlines, implicit print
\$\endgroup\$
0
\$\begingroup\$

///, 220 bytes

/H/2E//G/CBDCC//F/ABC2C//E/AC//D/2B//C/A2//A/33//B/32//2/0 //3/1 /2G22C3
ABFDB3
ABDBHABB
BG2D2
EFDB
EDCEAB3
DG22A
HFD3
HDBHAB
BBG223
2HFD
BEDBHA3
DBG22
CEF23
DEDCEA
BBBG2
DHF2
BBEDCE3
CBBG
2DHF
DBEDBH
ABBBCBDCA
22DHABC2A

Try it online!

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

C++11, Non-competing, 726 687 636 bytes (*NIX or W10 threshold 2 required)

#include <iostream>
#include <string>
#ifdef  _WIN32
#include <Windows.h>
#endif
using namespace std;int main() {
#ifdef  _WIN32
HANDLE h=GetStdHandle(-11);DWORD m;GetConsoleMode(h,&m);SetConsoleMode(h,m|0x04);
#endif
cout<<"\033[47m\033[30m";string d("4fup8y8hihjyl9g1ifh9wpc4f52l5a8giosim2isj80xff814db9wmf958x4zlbl58x4zlbl6zxgjt9whbcz4mu91r0j5c4kfq48uxw53w1zvpdshv6ylrnl3t38qyiteyw0lphs3kx59vf4ezay145thrt7lkb80w83nz10ih27f77p0820wzr9");for(int s=0;s!=184;s+=8){unsigned long long n=stoull(d.substr(s,8),NULL,36),i=3;for(int p=40;p!=-2;p-=2){int r=(n&(i<<p))>>p;printf(r>1?"\033[31m %d\033[30m":" %d",r>1?r-2:r);}puts("");}return 0;}

I know this can be golfed way better. I want to see a short c++ answer damnit!

I also probably made a few mistakes when I was encoding the heart section.

Output (colors fixed):

enter image description here

\$\endgroup\$
1
  • \$\begingroup\$ I assumed that only the heart section contained the message, so I encoded the whole thing. Needless to say I felt like an idiot when I reread the challenge and tested the first few lines of the output in ascii. \$\endgroup\$
    – user60119
    Oct 7, 2016 at 20:05
0
\$\begingroup\$

Python, 473 bytes

Colored!

r=str.replace;print r(r(r(r(r(r(r(r("""
jh0k1k1k0jk1
ikik1kjk0h1
ik0hjikih
k1h0k1k1k00k0
i1ksi1ejk0s1ke0h
i1sk0kie0si1kiek1
0ks1hje0s1k1k0ej1
j1s1kik1kjkjej
jsik0hjikiek
ksk1h0k1k1k0ej
0jsikik1kjk0ek
k1sik0hjikei1
0k1sjh0k1ke1k00
1kis1kik1k0e1kj
0ki1sk0k1k1eiki
hk1sh0ke1k1k0
0kji1sj1ke1kjk0
hi1ks0ke1ki1k1
1hk1ks1e00k1k1k
00kjikik1kjk
0hi1k0hjik
ihk1h0k1ki
000kjikik1kj1
""",'h','1010'),'i','11'),'j','01'),'k','10'),'1','1 '),'0','0 '),'s','\x1b[0;40;31m'),'e','\x1b[0m')
\$\endgroup\$
1
  • 1
    \$\begingroup\$ str.translate might be a better choice \$\endgroup\$
    – user45941
    Oct 10, 2016 at 20:14
0
\$\begingroup\$

FEU, 360 bytes

m/a/0 1 /b/1 0 /c/1 1 /d/0 0 /e/0 /f/1 /g
__DATA__
afaeaafabeab1
cfacababaae1
cbaaeacfaca0
fafaeaafabeae0
ccacababaa0
cfbaafacfafb1
aafaeaafabea1
acfacababae1
acbaaeacfac0
faafaeaafabd1
eacfacababa0
facbaaeacfaf1
aaafaeaafabe0
cacfacababe1
aacbaafacfa1
faaafaeaafab0
aeacfacabab0
faacbaafacb1
caaafaeaafaf0
eaeacfacabaf0
aaacbaaeacf0
cfaaafaeaafa1
daeacfacaba1

Just stupid compression

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