Tag: fizzbuzz

  • How to screw up estimates – Neon Rocket

    Adaptation of above image illustrating an Inte...
    (Photo credit: Wikipedia)

    “I need a time and cost estimate to develop a fizzbuzz mobile app on all minor mobile platforms (Windows/Blackberry/Symbian), and I need that estimate in 15 minutes.”

    Enhanced by Zemanta

  • Wicked Cool FizzBuzz in Perl – Neon Rocket

    The FizzBuzz problem is a simple coding demonstration to write an application in any language that counts from 1 to 100:

    Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.

    I found the following on Stackprinter (deleted Stackoverflow questions) by  “ysth”; probably the best example of wicked-cool code obsfucation, ever.

    (                       (
    ''))=~('('.'?'.'{'.("`"|
    '%').('['^'-').('`'|'!').
    ('`'|',').'"'.('['^'+').(
             ((            (
             (             ((
             (             ((
             '['         ))))
              )))))^(')')).(
               '`'|")").(
             (              (
             '`'))|'.').('['^
             '/').'+'.('(').(
             '`'^'&').(('`')|
                         ((
                          ((
                        ')'))
                       ))).+(
                       "["^
    
             (              (
             '!'))).('['^'!')    .')'
             .'['.''.('$').    '_'.
             '%'.('^'^(('`')|     ((
             (              (
             '-')))))).(']').
             '.'.'('.('`'^'"'
             ).('['^'.').('['
                           ^
                           ((
                           ((
             '!'))))).(('[')^
             '!').')'.('[').
             ''.'$'.'_'
                            .
                '%'.('^'^('`'|'+'
             )).']'.'|'.'|'.''.
             '$'.'_'.','.''.'$'
             .+             (
             ((
               (
                      (
                      (
                      (
                      (
                '/')))))))).(
                      (
                      (
                      (
                       '`')))|
                  '&').('`'|"/").(
               '['^')').('{'^'[').('^'
             ^('`'|'/'         )).".".
             ((                      '.'
    
             )                         )
             .                         (
             '^'^('`'|'/')).('^'^(('`')|
             '.')).('^'^('`'|'.')).('!'^
             (              (          (
             (              (          (
                            (          (
                            (          (
                           '+'         )
                          )))))        )
                                       )
                                      ))
                                   ).'"'
    
             .              (
             '}').')');$:='.'    ^'~'
             ;$~='@'|"(";$^=    ')'^
             '[';$/='`'|".";     $,
                         ='('
             ^+           '}'
             ;($)         =(
             ('`'))|        (
             (  "!"));     (
             (    $:))=')'  ^
             (       '}');$~=
             (          '*')|
             ((            ((
             '`')
                         )));
             $^           =((
             '+'))         ^+
             '_';$/=        (
             (  "&"))|     (
             (    '@'));$,  =
             (       '[')&'~'
             ;          ($)=
             ((            ((
             ',')
    
             )))^                   '|';
             $:=('.')^         "~";$~=
               '@'|'(';$^=')'^"[";$/=
                   '`'|'.';$,='('
    
                       ^'}';$
                  ='`'|'!';$:=")"^
               '}';$~='*'|'`';$^="+"^
             ('_');$/=         '&'|'@';
             $,                      =((
    
               (             "[")))&
              ((           ('~')));$=
             ((           ','))^    '|'
             ;           ($:)=        ((
            '.'))^'~';$~='@'|'(';$^=")"^
             (          '[');          (
             (          $/))=          (
            '`')|'.';$,='('^'}';$=('`')|
             ((        '!')            )
             ;$:=    (')')^           (
               ('}'));$~=            (
    
             (
             (
             (
             (
             (
             (
             (
             (
    
             (                     ((
             '*')                ))  ))
                )))             )      )
                   ))|          (      (
                       '`'       ));$^=
               '+'       ^((
             ((   ((        '_'
             )                  )))
             )     )              ;$/
              ='&'|                  '@'
    
              ;$,                    =
             '['                     &+
             ((                       ((
             (                         (
             (                         (
             (             ((          (
             '~'         ))))))      )))
             )));(    ($))  =','^"|";
              $:='.'^"~";    $~="@"|
                "(";$^=
    
             ')'^                   '[';
             $/=('`')|         ".";$,=
               '('^'}';$='`'|"!";$:=
                   ')'^'}';$~='*'
    
              |+
             '`';
             ($^)
    
                       =('+')^
                  '_';$/='&'|'@';$,
               ='['&'~';$=','^'|';$:=
             '.'^"~";         $~="@"|
             ((                      '('
    
             )                         )
             ;                         (
             $^)=')'^'[';$/='`'|".";$,=
             '('^'}';$='`'|'!';$:=")"^
             (              (          (
             (              (          (
             (              (          (
             (              (          (
             (             '}'        ))
             ))           ))))       )))
             ));(       $~)= '*'|'`';$^
              ='+'^"_";$/=   '&'|'@';
                $,='['&'~'      ;$=
                  ","^
                            (
               '|');$:=('.')^
             '~';$~='@'|"(";
             $^=')'^('[');$/=
             ((
             ((
              (
             '`')))))|'.';$,=
             '('^'}';$="`"|
             '!';$:=')'^"}";
                         ($~)
             =(           '*'
             )|'`'         ;(
             $^)='+'        ^
             (  '_');$/     =
             (    '&')|'@'  ;
             (       $,)='['&
             (          '~');
             $            =(
             ',')
                         ^'|'
             ;(           $:)
             ='.'^         ((
             "~"));        (
             (  ($~)))=     (
             (    ('@')))|  (
             (       '('));$^
             =          ")"^
             ((            ((
             '[')
    
             )));                   ($/)
             ='`'|'.';         $,="("^
               '}';$='`'|'!';$:=")"^
                   '}';$~='*'|'`'
    
                       ;$^='+'
                  ^'_';$/='&'|"@";
               $,='['&'~';$=','^"|";
             $:=('.')^         "~";$~=
             ((                      '@'
    
               )             )|'(';$^
              =(           ')')^'[';$/
             =(           "`")|    '.'
             ;           ($,)=        ((
            '('))^'}';$='`'|'!';$:=")"^
             (          '}');          (
             (          $~))=          (
            '*')|'`';$^='+'^'_';$/=('&')|
             ((        '@')            )
             ;$,=    ('[')&           (
               ('~'));$=            (
    
             (
             (
             (
             (
             (
             (
             (
             (
    
             (                     ((
             ',')                ))  ))
                )))             )      )
                   ))^          (      (
                       '|'       ));$:=
               '.'       ^((
             ((   ((        '~'
             )                  )))
             )     )              ;$~
              ='@'|                  '('
    
              ;(           ($^))=
             ((             (  (')'))))^
             (              ((      '[')
             )              );      ($/)
             =              ((      '`')
             )|            '.'      ;$,=
             "("^      '}';$      ='`'
              |'!';$:=')'^'}'       ;$~=
                '*'|'`';$^=         '+'^
    
             '_';                   ($/)
             ='&'|'@';         $,="["&
               '~';$=','^'|';$:="."^
                   '~';$~='@'|'('
    
              ;(               ($^))=
             ')'^   '[';$/='`'|('.');$,=
             '('^      '}';$='`'|"!";
    
              $:               =")"^
             '}';   $~='*'|'`';$^=('+')^
             '_';      $/='&'|('@');$,=
    
               (             '[')&'~'
              ;(           $)=','^'|'
             ;(           ($:))=    '.'
             ^           "~";        $~
            ='@'|'(';$^=')'^'[';$/=('`')|
             (          '.');          (
             (          $,))=          (
            '(')^'}';$='`'|'!';$:=(')')^
             ((        '}')            )
             ;$~=    ('*')|           (
               ('`'));$^=            (
    
             (
             (
             (
             (
             (
             (
             (
             (
    
              ((
             '+')
           ))))))
    
               )             )))^'_';
              $/           ='&'|'@';$,
             =(           "[")&    '~'
             ;           ($)=        ((
            ','))^'|';$:='.'^'~';$~="@"|
             (          '(');          (
             (          $^))=          (
            ')')^'[';$/='`'|'.';$,=('(')^
             ((        '}')            )
             ;$=    ('`')|           (
               ('!'));$:=            (
    
             (
             ')')
                )^+
                   '}'
                       ;$~
                         =((
                            '*'
                                ))|
                                  '`'
                                     ;$^
                            =
             '+'^'_';$/='&'|"@";$,=
             '['&'~';$=','^'|';$:='.'^
             '~';$~='@'|'(';$^=')'^"[";
                            (      $/  )
                            =     ('`')|
                                  ".";
                  ($,)=
               '('^'}';$=
              '`'|'!';$:=')'
             ^+           ((
             (              (
             (              (
             (             ((
             '}')       ))))
               ))));$~='*'|
                 "`";$^=
             (              (
             '+'))^'_';$/='&'
             |'@';$,='['&'~';
             $=','^('|');$:=
                         ((
                          ((
                        '.'))
                       ))^'~'
                       ;($~)
    
             =
             (                    (
             '@'))|'(';$^=')'^'[';$/=
             '`'|'.';$,='('^'}';$='`'
             |
             (
              ((
             '!')
             ));(
    
              $:
             )=((
             ')')
    
             )
             ^                    (
             '}');$~='*'|'`';$^="+"^
             '_';$/='&'|'@';$,='['&'~'
             ;
             (
                      $)=","^
                 '|';$:='.'^'~';$~=
               '@'|'(';$^=')'^'[';$/=
              "`"|               ".";
             $,                       =(
             (                         (
             (                         (
             ((                      '('
              )))))               ))^((
               '}'));$='`'|('!');$:=
                  ')'^'}';$~="*"|
    
                      ('`');$^=
                 '+'^'_';$/='&'|'@'
               ;$,='['&'~';$=','^'|'
              ;($:)               ='.'^
             ((                       ((
             (                         (
             (                         (
             ((                      '~'
              )))))               )))))
               ;$~='@'|'(';$^=')'^'['
                  ;$/='`'|".";#;#

    Save the above Asciiart into a file called, for example, fizz.pl.

    Then run it: perl fizz.pl

    Enhanced by Zemanta