http://qs321.pair.com?node_id=284291

BrowserUk has asked for the wisdom of the Perl Monks concerning the following question:

I have one of these on my wall somewhere for about 25 years.

0 1 2 3 4 5 6 7 8 9 A B C D E F 00: ☺ ☻ ♥ ♦ ♣ â™  ♫ ☼ 10: â–º â—„ ↕ ‼ ¶ § â–¬ ↨ ↠+‘ ↓ → ← ∟ ↔ â–² â–¼ 20: ! " # $ % & ' ( ) * + , - . / 30: 0 1 2 3 4 5 6 7 8 9 : ; < = > ? 40: @ A B C D E F G H I J K L M N O 50: P Q R S T U V W X Y Z [ \ ] ^ _ 60: ` a b c d e f g h i j k l m n o 70: p q r s t u v w x y z { | } ~  80: Ç ü é â ä à Ã¥ ç ê ë è ï î + ì Ä Ã… 90: É æ Æ ô ö ò û ù ÿ Ö Ãœ ¢  +£ Â¥ ₧ Æ’ A0: á í ó ú ñ Ñ ª º ¿ ⌐ ¬ ½  +¼ ¡ « » B0: â–‘ â–’ â–“ │ ┤ â•¡ â•¢ â• +– â•• â•£ â•‘ â•— ╝ â•œ �› +┐ C0: â”” â”´ ┬ ├ ─ ┼ â•ž â•Ÿ + â•š â•” â•© ╦ â•  ═ ╬ ╧ D0: ╨ ╤ â•¥ â•™ ╘ â•’ â•“ â• + ╪ ┘ ┌ â–ˆ â–„ â–Œ ▐ â–€ E0: α ß Γ Ï€ Σ σ µ Ï„ Φ Θ Ω δ â +ˆž φ ε ∩ F0: ≡ ± ≥ ≤ ⌠ ⌡ ÷ ≈ ° ∠+™ · √ ⁿ ² â–   

The Challenge: A perl one-liner to produce the above.

The rules:

  1. All characters except perl -e'' or perl -e"" count.
  2. pragmas are not required.
  3. Text::ASCIITable and similar not allowed.
  4. Distortions of the first line of chars (as shown) acceptable. -25 for those that avoid it.
  5. Differences in the glyphs are irrelevant, but must be verifably correct for the given system/font/code page etc.
  6. Differences due only to different quoting rules will be judges the same. (eg.  perl -e'"$var..."' equiv. perl -e"qq[$var...]"

My best is 120 so there should be scope for improvement.
perl -e"@(=0..15,@_=(0..9,A..F),print+(' 'x4,map' '.$_[$_],@(),$/,qq[ @{[map{$_[$;=$_].qq[0: @{[map+chr($;<<4|$_),@(]}$/]}@(]}]"


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
If I understand your problem, I can solve it! Of course, the same can be said for you.

Replies are listed 'Best First'.
Re: (Golf) Ascii table
by blokhead (Monsignor) on Aug 16, 2003 at 04:48 UTC
    63, plus one for the -l, gives me 64:
    perl -le'print" ",$,=$",@_=(0..9,A..F);print$_."0:",map chr$a++,@_ for@_'

    Update: Welp, it's pretty trivial to trim a character off that, making it 63:
    perl -le'print$,=$",$,,@_=(0..9,A..F);print$_."0:",map chr$a++,@_ for@_'

    blokhead

      Very nice. :)

      antirice    
      The first rule of Perl club is - use Perl
      The
      ith rule of Perl club is - follow rule i - 1 for i > 1

Re: (Golf) Ascii table
by antirice (Priest) on Aug 16, 2003 at 02:00 UTC

    71:

    perl -e'$,=$";@a=(0..9,A..F);print" "x4,@a,$/,map{$_."0:",map(chr$b++,@a),$/}@a'

    If there's a prob with the leading spaces, 75:

    perl -e'$,=$";@a=(0..9,A..F);print" "x3,@a,$/,map{"\r$_"."0:",map(chr$b++,@a),$/}@a'

    And my first version because I liked it :), 77 including the l:

    perl -le'@a=(0..9,A..F);sub a{print"@_"};a" "x3,@a;for$a(@a){a$a."0:",map chr$b++,@a}'

    If anyone finds that these don't work elsewhere (I'm testing on FreeBSD 4.6 with perl 5.6.1 and 5.8.0), I'd appreciate it if you'd comment :)

    antirice    
    The first rule of Perl club is - use Perl
    The
    ith rule of Perl club is - follow rule i - 1 for i > 1

      I happen to use black theme background. Same color as the code.