Skip to main content
added 867 characters in body
Source Link
Jonathan Allan
  • 110.1k
  • 7
  • 65
  • 282

Jelly, 19 bytes

>⁵Ḷ÷¤»⁻A$ị“¢€:“&Ɠ’Ọ

A monadic Link that accepts a double precision floating point number and yields a list of characters.

Try it online! Or see the test-suite.

How?

>⁵Ḷ÷¤»⁻A$ị“¢€:“&Ɠ’Ọ - Link: double D
    ¤               - nilad followed by link(s) as a nilad:
 ⁵                  -   ten
  Ḷ                 -   lowered range -> [0, 1, 2, ..., 9]
   ÷                -   divided by (ten) -> [0, 0,1, 0.2, ..., 0.9]
>                   - (D) greater than (that) (vectorised) -> G
        $           - last two links as a monad - f(D):
       A            -   absolute value (D)
      ⁻             -   (D) not equal to (that)? -> K   (K = (x<0 or x is nan)?)
     »              - (G) maximum (K) (vectorised)
                       -> L = list with 1 at blue and 0 at white
          “¢€:“&Ɠ’  - list of base 250 compressed numbers = [128309, 9898]
         ị          - (L) index into (that) (vectorised)
                  Ọ - cast to characters

Jelly, 19 bytes

>⁵Ḷ÷¤»⁻A$ị“¢€:“&Ɠ’Ọ

A monadic Link that accepts a double precision floating point number and yields a list of characters.

Try it online! Or see the test-suite.

Jelly, 19 bytes

>⁵Ḷ÷¤»⁻A$ị“¢€:“&Ɠ’Ọ

A monadic Link that accepts a double precision floating point number and yields a list of characters.

Try it online! Or see the test-suite.

How?

>⁵Ḷ÷¤»⁻A$ị“¢€:“&Ɠ’Ọ - Link: double D
    ¤               - nilad followed by link(s) as a nilad:
 ⁵                  -   ten
  Ḷ                 -   lowered range -> [0, 1, 2, ..., 9]
   ÷                -   divided by (ten) -> [0, 0,1, 0.2, ..., 0.9]
>                   - (D) greater than (that) (vectorised) -> G
        $           - last two links as a monad - f(D):
       A            -   absolute value (D)
      ⁻             -   (D) not equal to (that)? -> K   (K = (x<0 or x is nan)?)
     »              - (G) maximum (K) (vectorised)
                       -> L = list with 1 at blue and 0 at white
          “¢€:“&Ɠ’  - list of base 250 compressed numbers = [128309, 9898]
         ị          - (L) index into (that) (vectorised)
                  Ọ - cast to characters
Source Link
Jonathan Allan
  • 110.1k
  • 7
  • 65
  • 282

Jelly, 19 bytes

>⁵Ḷ÷¤»⁻A$ị“¢€:“&Ɠ’Ọ

A monadic Link that accepts a double precision floating point number and yields a list of characters.

Try it online! Or see the test-suite.