Skip to main content
1 of 4
coredump
  • 6.8k
  • 24
  • 47

Common Lisp, 488

(lambda(z)(dotimes(r 3)(map()(lambda(c)(do((i 0 j)j n)((or(and(=(setf j(+ 4 i))220)(setf n 146))(=(char-code c)(ldb(byte 8 9)(setf n(parse-integer"0JCA0JKW0JXU0KHE0KS80L960LP60LYA0MII0MUY0CN4139S15CO0FES187K1AKG0HSG0OZ612M20PYY132W0QFS0QMI13W00R8W142I0RFE14D60RQ2151M0SEI0SQG15PC0T28168W0TLS16TK0U6G17PS0V2O0VL618CA0VP618VU0W8Q193K0WGG19QY0X3U19ZS0XCO0XYG1CDU0ZQQ":start i :end j :radix 36)))))(loop for v from(* 3 r)for d across"!_!"do(format t"~:[ ~;~A~]"(logbitp v n)d)))))z)(terpri)))

Still too long...

Example

With "abcdefg'hijlKnopqrstuz", prints:

 _           _  _  _   !             _        _  _     _        _ 
!_!!_  _  _!!_ !_ !     !_   !  !!   _  _  _ !_!!_! _ !_ !_     _!
! !!_!!_ !_!!_ !  !_!   ! !  !!_!!_  _ ! !!_!!    !!   _!!_ !_!!_ 

Remarks

The following string is a representation in base 36 of numbers, each having 4 digits:

"0JCA0JKW0JXU0KHE0KS80L960LP60LYA0MII0MUY0CN4139S15CO0FES187K1AKG0HSG0OZ612M20PYY132W0QFS0QMI13W00R8W142I0RFE14D60RQ2151M0SEI0SQG15PC0T28168W0TLS16TK0U6G17PS0V2O0VL618CA0VP618VU0W8Q193K0WGG19QY0X3U19ZS0XCO0XYG1CDU0ZQQ"

For example, the first number 0JCA is represented in binary by 110000111101010, which is decomposed here in two parts:

  1. 110000, the char-code of character 0

  2. 111101010, an encoding of the drawing, best represented as follows:

     010 (bits 0-2)         _ 
     101 (bits 3-5)   =>   ! !
     111 (bits 6-8)        !_!
    

    Bits in first and last "column" are for ! characters, the ones in the middle column for the _ character. When necessary, both uppercase and downcase versions of a character are stored.

The function iterates three times over the input string, one for each line of output, searches for a matching character in the table (or defaults to 146, a.k.a. three bars), and prints the representation at current row.

coredump
  • 6.8k
  • 24
  • 47