Skip to main content
added 135 characters in body
Source Link
Dominic van Essen
  • 36.4k
  • 2
  • 22
  • 60

Husk, 18 17 14 1313 12 bytes

Edit: -3 bytes, and then another -1 byte, thanks to Leo, and -1 byte thanks to inspiration from pajonk's R answer (3rd edit)

€¹mΠ†dfṁ→m½Pd€¹mΠ†dm½f→Pd

Try it online!Try it online!

Outputs nonzero integer if it's a vampire number, zero otherwise.

Commented penultimate version:

€¹                  # index of input if present, zero otherwise, in
  mΠ                # products of each element-pair
    †d              # combining digits as a number from
         m½         # first & second halves of
           P        # all permutations of
            d       # digits of input;
      f             # and filtering only element-pairs for which
       ṁ→           # sum of last digits is nonzero

Husk, 18 17 14 13 bytes

Edit: -3 bytes, and then another -1 byte, thanks to Leo

€¹mΠ†dfṁ→m½Pd

Try it online!

Outputs nonzero integer if it's a vampire number, zero otherwise.

€¹                  # index of input if present, zero otherwise, in
  mΠ                # products of each element-pair
    †d              # combining digits as a number from
         m½         # first & second halves of
           P        # all permutations of
            d       # digits of input;
      f             # and filtering only element-pairs for which
       ṁ→           # sum of last digits is nonzero

Husk, 18 17 14 13 12 bytes

Edit: -3 bytes, and then another -1 byte, thanks to Leo, and -1 byte thanks to inspiration from pajonk's R answer (3rd edit)

€¹mΠ†dm½f→Pd

Try it online!

Outputs nonzero integer if it's a vampire number, zero otherwise.

Commented penultimate version:

€¹                  # index of input if present, zero otherwise, in
  mΠ                # products of each element-pair
    †d              # combining digits as a number from
         m½         # first & second halves of
           P        # all permutations of
            d       # digits of input;
      f             # and filtering only element-pairs for which
       ṁ→           # sum of last digits is nonzero
added 31 characters in body
Source Link
Dominic van Essen
  • 36.4k
  • 2
  • 22
  • 60

Husk, 18 1717 14 13 bytes

Edit: -3 bytes, and then another -1 byte, thanks to Leo

€¹moΠmdfo→Fz+m½Pd€¹mΠ†dfṁ→m½Pd

Try it online!Try it online!

Outputs nonzero integer if it's a vampire number, zero otherwise.

€¹                  # index of input if present, zero otherwise, in
  moΠ               # products of each element-pair
    †d md             # combining digits as a number from
                  # first & second halves of
           P    P    # all permutations of
            d    d   # digits of input;
       f             # and filtering only element-pairs for which
       ṁ→ o→Fz+       # last element # sum of zippedlast sumsdigits is nonzero

Husk, 18 17 bytes

€¹moΠmdfo→Fz+m½Pd

Try it online!

Outputs nonzero integer if it's a vampire number, zero otherwise.

€¹                  # index of input if present, zero otherwise, in
  moΠ               # products of each element-pair
     md             # combining digits as a number from
                  # first & second halves of
               P    # all permutations of
                d   # digits of input;
       f            # and filtering only element-pairs for which
        o→Fz+       # last element of zipped sums is nonzero

Husk, 18 17 14 13 bytes

Edit: -3 bytes, and then another -1 byte, thanks to Leo

€¹mΠ†dfṁ→m½Pd

Try it online!

Outputs nonzero integer if it's a vampire number, zero otherwise.

€¹                  # index of input if present, zero otherwise, in
                 # products of each element-pair
    †d              # combining digits as a number from
                  # first & second halves of
           P        # all permutations of
            d       # digits of input;
      f             # and filtering only element-pairs for which
       ṁ→           # sum of last digits is nonzero
deleted 66 characters in body
Source Link
Dominic van Essen
  • 36.4k
  • 2
  • 22
  • 60

Husk, 18 17 bytes

€¹moΠmdfo→Fz+m½Pd

Try it online!

Outputs nonzero integer if it's a vampire number, zero otherwise.

€¹                  # index of input if present, zero otherwise, in
  moΠ               # products of each element-pair of
          mom       # results of mapping these functions:
   md          d   # combining digits #as combinea digitsnumber infrom
              ½     # first & second halves
                    # across all elements of:
               P    # all permutations of
                d   # digits of input;
   f    f            # and filtering only element-pairs for which
    F¤|%10    o→Fz+       # onelast orelement otherof iszipped nonzerosums modulois 10nonzero

Husk, 18 17 bytes

€¹moΠmdfo→Fz+m½Pd

Try it online!

Outputs nonzero integer if it's a vampire number, zero otherwise.

€¹                  # index of input if present, zero otherwise, in
                 # products of each element-pair of
          mom       # results of mapping these functions:
             d      # combine digits in
              ½     # first & second halves
                    # across all elements of:
               P    # all permutations of
                d   # digits of input;
   f                # and filtering only element-pairs for which
    F¤|%10          # one or other is nonzero modulo 10

Husk, 18 17 bytes

€¹moΠmdfo→Fz+m½Pd

Try it online!

Outputs nonzero integer if it's a vampire number, zero otherwise.

€¹                  # index of input if present, zero otherwise, in
  moΠ               # products of each element-pair
     md             # combining digits as a number from
                  # first & second halves of
               P    # all permutations of
                d   # digits of input;
       f            # and filtering only element-pairs for which
        o→Fz+       # last element of zipped sums is nonzero
added 9 characters in body
Source Link
Dominic van Essen
  • 36.4k
  • 2
  • 22
  • 60
Loading
added 537 characters in body
Source Link
Dominic van Essen
  • 36.4k
  • 2
  • 22
  • 60
Loading
Source Link
Dominic van Essen
  • 36.4k
  • 2
  • 22
  • 60
Loading