10
\$\begingroup\$

today (24 of September) is birthday of company HONDA. Originally their company name is

本田技研工業株式会社

I want to ask to make a gift for HONDA. The task is to make program print company name. You can do it any way you want, but there is only one rule, Unicode is not allowed. It should be ASCII art.

I want to ask to post code and output. As always to determine winner I'll look at the length of code, however portrait in this case is also important.

EDIT: output have to look similar into this: 本田技研工業株式会社

\$\endgroup\$

closed as off-topic by mbomb007, Martin Ender Nov 6 '15 at 23:19

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions without an objective primary winning criterion are off-topic, as they make it impossible to indisputably decide which entry should win." – mbomb007, Martin Ender
If this question can be reworded to fit the rules in the help center, please edit the question.

  • \$\begingroup\$ Alright, so what's stopping us from using 'HONDA' and claiming it prints the company name in GolfScript? (I'm just trying to point out some loopholes). Also, is this meant to be tagged as code-golf? \$\endgroup\$ – Volatility Sep 24 '13 at 9:27
  • \$\begingroup\$ @Volatility I've made edit after your comment. \$\endgroup\$ – ST3 Sep 24 '13 at 9:29
  • \$\begingroup\$ Unicode is not allowed where? At the output (sounds reasonable)? As script? As internal representation in your script? \$\endgroup\$ – Johannes Kuhn Sep 24 '13 at 10:14
  • \$\begingroup\$ @JohannesKuhn I meant none of printed characters cannot be UNICODE, in script you can use it but output should be on ASCII table chars. \$\endgroup\$ – ST3 Sep 24 '13 at 10:17
  • 2
    \$\begingroup\$ The spec is too vague to allow an objective determination of whether a program meets it or not. \$\endgroup\$ – Peter Taylor Sep 24 '13 at 13:10
19
\$\begingroup\$

Mathematica

Here the characters are individually rasterized. The zero's of the binary image data of a reduced image are then replaced with asterisks and the array itself is then printed.

GraphicsGrid[ImageData@ImageResize[Binarize@Rasterize@Style[#, 136], 30] 
/. {1 -> "", 0 -> "*"}] & /@ Characters["本田技研工業株式会社"]

Honda

Below all characters were rasterized as a single image. The asterisks are a bit more difficult to recognize as asterisks in this case.

GraphicsGrid[ImageData@ImageResize[Binarize@Rasterize@Style[#, 136], 300] 
/. {1 -> "",  0 -> "*"}, ImageSize -> 1500] &["本田技研工業株式会社"]

image2

\$\endgroup\$
  • \$\begingroup\$ Very, very nice \$\endgroup\$ – Dr. belisarius Sep 26 '13 at 1:04
  • \$\begingroup\$ Wow. Looks very good. One of the requirements was visual portrait and your solution has very high quality of that, so that's way I'm accepting your answer. \$\endgroup\$ – ST3 Sep 26 '13 at 12:11
11
\$\begingroup\$

Tcl

Well, a probably crazy approach.

package r Tk
package r Img
pack [label .l -text 本田技研工業株式会社 -fg #000000 -bg #ffffff]
update
puts [join [lmap line [[image create photo -data .l] data] {join [lmap pixel $line {expr {$pixel ne {#ffffff}?"@":" "}}] {}}] \n]
exit

Here a screenshot:

screenshot

\$\endgroup\$
  • \$\begingroup\$ Does output same as 本田技研工業株式会社? \$\endgroup\$ – ST3 Sep 24 '13 at 10:38
  • \$\begingroup\$ Well and do not look very good, but all in all good solution. \$\endgroup\$ – ST3 Sep 24 '13 at 10:43
  • \$\begingroup\$ I don't output any unicode characters. I just take a photo of them and render that as Ascii. Well, b/w. \$\endgroup\$ – Johannes Kuhn Sep 24 '13 at 10:44
  • \$\begingroup\$ I could more different characters to display shades. (At the cost of the progam size) \$\endgroup\$ – Johannes Kuhn Sep 24 '13 at 10:46
6
\$\begingroup\$

JavaScript + HTML, interactive version (275 + 90 = 365 chars)

Many ideas inspired by Austin's answer, but this one is interactive; you can change the font size! (also the character count is actually correct)


Screenshot

Pressing the - and + buttons change the font size. Image is cut off, but you get the idea.

image


Fiddle (try it yourself!)

Here is a JSFiddle where you can run the code yourself.


JS, 275

h=30,(r=function(){for(x=document.createElement('canvas').getContext('2d'),x.font=h+'px sans-serif',x.fillText('本田技研工業株式会社',0,h),d=x.getImageData(0,0,w=h*10,h).data,s='',a=0;a<h;a++){for(b=0;b<w;b++)s+=d[3+w*4*a+4*b]?0:' ';s+='\n'}document.getElementById('p').innerHTML=s})()

HTML, 90

<button onclick='h--;r()'>-</button><button onclick='h++;r()'>+</button><pre id='p'></pre>

Hi-resolution version

http://jsfiddle.net/UjTbK/1/

image


\$\endgroup\$
  • \$\begingroup\$ r=function(h){for(x=document.createElement('canvas').getContext('2d'),x.font=h+'px sans-serif',x.fillText('本田技研工業株式会社',0,h),d=x.getImageData(0,0,w=h*10,h).data,s='',a=0;a<h;a++){for(b=0;b<w;b++)s+=d[3+w*4*a+4*b]?0:' ';s+='\n'}document.getElementById('p').innerHTML=s} (30) is three bytes shorter. \$\endgroup\$ – Conor O'Brien Nov 6 '15 at 23:39
4
\$\begingroup\$

Javascript, 261 characters, 226 minified

special thanks to jsacii for inspiring this solution.

c = document.createElement('canvas').getContext('2d');
c.font="30px sans-serif";c.fillText("本田技研工業株式会社", 0,30);d=c.getImageData(0,0,305,40).data;
s="";
for(var y = 0; y<40;y+=2){
    for(var x=0;x<305;x++)
        s += d[3+4*x+1220*y]? "*" : " ";
    s+="\n";
}

minified

c=document.createElement("canvas").getContext("2d");c.font="30px sans-serif";c.fillText("本田技研工業株式会社",0,30);d=c.getImageData(0,0,305,40).data;s="";for(var y=0;y<40;y+=2){for(var x=0;x<305;x++)s+=d[3+4*x+1220*y]?"*":" ";s+="\n"}

and the output

             ****                                                ****        ****                                                                                ***  ***                ****        ****                           **                       ****                  ****         ****             
             ****               **************************       ****        ****          *****************************                                  ****   ***  ***   ****         ****    ********                          ********                 ******                 ****         ****             
             ****               **************************       ****        ****      *    ** ******* ****** ****** **    *************************       ****  ***  ***  ****          ****   **** ****                          **** *****             **********                ***         ****             
 ****************************   ****       ****       ****   ****************************     ****       ****   ****       ************************    ****************************  ***************************   ****************************        ******    ******        *************    ****             
  ***************************   ****       ****       ****   ***********     ****             ****       ****   ****                 ****                     ****      ****         ***************************   ****************************     *******        *******             ****     ****             
          *********             ****       ****       ****       ****        ****            ****        ****   ****                 ****               **************************      **********   ****                          ****          *****************************       *********************       
         ************           **************************       **** *****************     ****************************             ****               **************************      *************************    ******************          ****  ****************  *****      ****   **** **********       
       ***** **** ****          **************************       ******* ****      ****    ******  ********************              ****                 **********************       **************************    ******************                                           *******       ****             
      *****  ****  *****        ****       ****       ****   ********    *****   *****    *******  ***   ****   ****                 ****                 **********************      *******      ********               ****      ****         ****************************  *************    ****             
   ******    ****    ******     ****       ****       ****   ********      **** ****       * ****  ***   ****   ****                 ****              **************************** *********     ***********             ****      ****           *      ****     *      **   **** *** ****    ****             
 *****************************  ****       ****       ****       ****       *******          ****  ***  ****    ****                 ****              ****************************  **  ****   ********* *****           ****     * ****   ***          ****    *****              ***         ****             
 ****   *    ****        ****   ****       ****       ****       ****      *********         ********* *****    ****     ****************************        ****************            **********  ****  ******         *********** ****  ****        ****       *****            ***         ****             
             ****               **************************       ****  *******  *******      **************     ****     ****************************  **********  ****  ***********     ********    ****    ****  **************      ********    ***********************          ***  *******************     
             ****               ****                  ****   **************        *******   ****    *****      ****                                   ******      ****       *****      ****        ****           ***                 ******    ****************     *****       ****  *******************     
             ***                                                 *                     *              **         **                                                ****                  ****         ***                                                               **          ***                          
\$\endgroup\$
  • \$\begingroup\$ I think first output line should be fixed. \$\endgroup\$ – ST3 Sep 24 '13 at 19:13
  • \$\begingroup\$ That was just from pasting into the editor, fixed in edit \$\endgroup\$ – Professor Allman Sep 24 '13 at 19:14
  • \$\begingroup\$ That's 261 characters, by my count... \$\endgroup\$ – Doorknob Sep 25 '13 at 1:40
  • \$\begingroup\$ @Doorknob i posted the minified count, changed in update \$\endgroup\$ – Professor Allman Sep 26 '13 at 16:47
  • \$\begingroup\$ You can remove the var statements from the for loops and you can replace (if you want) "*" with a number. \$\endgroup\$ – Conor O'Brien Nov 6 '15 at 23:41
1
\$\begingroup\$

Java, 267 260 characters

Alright, I guess my solution is not all that different from Johannes Kuhn's answer, but as it seems this is a problem that can be handled nicely in Java; my solution is not much longer; and the output is slightly different, I'll post it nevertheless:

class A{public static void main(String[]a){java.awt.image.BufferedImage b=new java.awt.image.BufferedImage(130,16,2);b.createGraphics().drawString("本田技研工業株式会社",0,13);for(int y=0;y<2080;System.out.print((b.getRGB(y%130,y/130)<0?"#":" ")+(++y%130<1?"\n":"")));}}

Formatted as:

class A {
    public static void main(String[]a) {
        java.awt.image.BufferedImage b = new java.awt.image.BufferedImage(130, 16, 2);
        b.createGraphics().drawString("本田技研工業株式会社", 0, 13);
        for (int y = 0; y < 2080; System.out
                .print((b.getRGB(y % 130, y / 130) < 0 ? "#" : " ")
                        + (++y % 130 < 1 ? "\n" : "")))
            ;
    }
}

Output:

      #                     #     #                                   # #        #  # #                       #         #    #    
      #       ###########   #     #     #### #######                # # # #      #  # #            # ##      # #        #    #    
 ###########  #    #    #   #  ########   #   #  #    ##########  # # # # # #    #  ######         #       ##   ##    #####  #    
      #       #    #    # ####    #      #    #  #        #       ###########  ### #  #     ############  #       #       #  #    
     ###      #    #    #   #     #      #    #  #        #          #   #       #    #            #     # ######  ##    #  ##### 
    # # #     ###########   #  #######   ### #######      #       ###########   ### #######  ##### #                    #    #    
   #  #  #    #    #    #   ##  #   #   ## #  #  #        #        #########   # #    #        #   #                   ###   #    
  #   #   #   #    #    # ###    #  #    # #  #  #        #            #       # #   ###       #    #    ###########  # # #  #    
 #  #####  #  #    #    #   #    # #     # #  #  #        #       ###########  # #  # # #      #    #        #          #    #    
 #    #     # #    #    #   #    ###     ### #   #        #          # # #       # #  #  #     # ## #  #    #   #       #    #    
      #       ###########   #  ##   ##   # # #   #   ###########   ##  #  ###    # #  #   # #####    # #    #    #      # ####### 
      #       #         # ##  #       #      #   #                #    #     #   #    #               #  ######## ##    #         
\$\endgroup\$
  • \$\begingroup\$ @Bakuriu Use a different font. @ memo: you can save 6 characters by NOT importing. (importing costs 36 chars, using the full qualified name costs 15 chars for each use). \$\endgroup\$ – Johannes Kuhn Sep 24 '13 at 14:19
  • \$\begingroup\$ @Johannes Kuhn: You are absolutely right. I've updated the answer accordingly, and also found another redundant blank in the array declaration. \$\endgroup\$ – memo Sep 24 '13 at 14:40

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