Skip to main content
Commonmark migration
Source Link

###How?

How?

###How?

How?

added 1640 characters in body
Source Link
Jonathan Allan
  • 110.1k
  • 7
  • 65
  • 282

###How?

Ɠ⁽¿ÇB31_+2¦4ḍ~ƊR;€"J$ḅ³Fċ:³$ - Main Link
Ɠ                            - set the chain's left argument, N, to evaluated STDIN
 ⁽¿Ç                         - base 250 integer = 3765
    B                        - to binary     = [1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1]
     31_                     - 31 minus      = [30,30,30,31,30,31,30,30,31,30,31,30]
              Ɗ              - last three links as a monad - f(N):
           4ḍ                -   four divides (N)?
             ~               -   bitwise NOT (0 becomes -1 and 1 becomes -2)
          ¦                  - sparse application...
         2                   - ...to indices: [2]
        +                    - ...action: add
                               i.e. x=9 or 8: [30,2x,30,31,30,31,30,30,31,30,31,30]
               R             - range (vectorises) = [[1,2,...30],...]
                    $        - last two links as a monad - f(that):
                   J         -   range of length = [1,2,...,12]
                  "          -   zip with:
                ;€           -     concatenate each -> [[[1,1],[2,1],...,[30,1]],...]
                     ḅ       - convert from base (vectroises):
                      ³      -   100               -> [[101,201,...,3001],...]
                       F     - flatten
                        ċ    - count occurrences of:
                           $ -   last two links as a monad - f(N):
                         :   -     (N) integer divide:
                          ³  -       100

###How?

Ɠ⁽¿ÇB31_+2¦4ḍ~ƊR;€"J$ḅ³Fċ:³$ - Main Link
Ɠ                            - set the chain's left argument, N, to evaluated STDIN
 ⁽¿Ç                         - base 250 integer = 3765
    B                        - to binary     = [1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1]
     31_                     - 31 minus      = [30,30,30,31,30,31,30,30,31,30,31,30]
              Ɗ              - last three links as a monad - f(N):
           4ḍ                -   four divides (N)?
             ~               -   bitwise NOT (0 becomes -1 and 1 becomes -2)
          ¦                  - sparse application...
         2                   - ...to indices: [2]
        +                    - ...action: add
                               i.e. x=9 or 8: [30,2x,30,31,30,31,30,30,31,30,31,30]
               R             - range (vectorises) = [[1,2,...30],...]
                    $        - last two links as a monad - f(that):
                   J         -   range of length = [1,2,...,12]
                  "          -   zip with:
                ;€           -     concatenate each -> [[[1,1],[2,1],...,[30,1]],...]
                     ḅ       - convert from base (vectroises):
                      ³      -   100               -> [[101,201,...,3001],...]
                       F     - flatten
                        ċ    - count occurrences of:
                           $ -   last two links as a monad - f(N):
                         :   -     (N) integer divide:
                          ³  -       100
Source Link
Jonathan Allan
  • 110.1k
  • 7
  • 65
  • 282

Jelly, 28 bytes

Ɠ⁽¿ÇB31_+2¦4ḍ~ƊR;€"J$ḅ³Fċ:³$

A full program accepting a single integer from STDIN which prints a 1 or 0 to STDOUT.

Try it online! Or see the test-suite.