[Question]
  [
Repost and improvement of [this](https://codegolf.stackexchange.com/questions/125/test-if-a-given-number-is-a-vampire-number) challenge from 2011
A [vampire number](http://en.wikipedia.org/wiki/Vampire_number) is a positive integer \$v\$ with an even number of digits that can be split into 2 smaller integers \$x, y\$ consisting of the digits of \$v\$ such that \$v = xy\$. For example:
$$1260 = 21 \times 60$$
so \$1260\$ is a vampire number. Note that the digits for \$v\$ can be in any order, and must be repeated for repeated digits, when splitting into \$x\$ and \$y\$. \$x\$ and \$y\$ must have the same number of digits, and only one can have trailing zeros (so \$153000\$ is not a vampire number, despite \$153000 = 300 \times 510\$).
You are to take a positive integer \$v\$ which has an even number of digits and output whether it is a vampire number or not. You can either output:
* Two consistent, distinct values
* A (not necessarily consistent) truthy value and a falsey value
	+ For example, "a positive integer for true, 0 for false"
You may input and output in any [convenient method](https://codegolf.meta.stackexchange.com/questions/2447/default-for-code-golf-input-output-methods). This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest code in bytes wins.
The first 15 vampire numbers are \$1260, 1395, 1435, 1530, 1827, 2187, 6880, 102510, 104260, 105210, 105264, 105750, 108135, 110758, 115672\$. This is sequence [A014575](https://oeis.org/A014575) on OEIS. **Be sure to double check that your solution checks for trailing zeros; \$153000\$ should return false.**
  
[Answer]
# [Husk](https://github.com/barbuz/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](https://codegolf.stackexchange.com/a/218803/95126) (3rd edit)*
```
€¹mΠ†dm½f→Pd
```
[Try it online!](https://tio.run/##AS8A0P9odXNr/23igoH/4oKswrltzqDigKBkbcK9ZuKGklBk////WzEyNjAsMTUzMDAwXQ "Husk – 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
```
[Answer]
# [R](https://www.r-project.org/), ~~156~~ ~~146~~ ~~143~~ 135 bytes
*-10 bytes thanks to [Dominic van Essen](https://codegolf.stackexchange.com/users/95126/dominic-van-essen)*
```
function(n,s=strsplit){for(i in 1:n)if(!n%%i&nchar(j<-n/i)==nchar(i)&all(el(s(paste0(j,i),''))%in%el(s(c(n,''),'')))&i%%10)return(T)
F}
```
[Try it online!](https://tio.run/##JYxBCoMwEEX3PYVdRGfA0kSJSmm2PUEvIGLoSBgliavSs6cSV//99@H7ZE2yO0@RVgaugwnRh81RxK9dPVBBXKgHI1m4shBU8vQZPSzPG98JjTkrYTk6B7ODANsY4ixhqQnrqkIUxCIP0/F/iCyxJCGURD/H3TO88fL6JQuq6SRejtStlJn6XOWgWp1JyV4PJ@mubzD9AQ "R – Try It Online")
[Answer]
# [J](http://jsoftware.com/), 43 bytes
```
".e.-@-:@#((0<[:".{:\)*[:*/".\)"1 i.@!@#A.]
```
[Try it online!](https://tio.run/##XY9RT4MwFIXf9yuO8ABMqC1zGzZjQY17MnvY6@YDYskwDAgtukTjX5@lTBNt0ub29Lvn3L6eLOLkiDkc@KDgegcE95vHlX4RJEgCntiuSxdbbpEPvvPGWz6@ssjOsxgKklwk9i15Onmj9R3BwzE9NKWAElIhS6WQyOsWshFZkRcZqu7wLFpJCDH4qm4PKCQ3l36JbF9jIY6aV@IFrZBdqZaIkWNRVE2nlgbdCNW1lYQeIIfan/OaVOpAMhoZF2a6HBbOqDMo9Fdhzl@GTWfz8B81nVCqOwfRCYJA1332un4f4tKyhHgT1c@n0DVQNWZRREe9LmMC1/4CjcNPO7G4RT2wy4IYYLB1@@l8NrmZ@ux6og8d6rMonPshi@Z@T3oIuLHJzxbG@vQN "J – Try It Online")
Takes digits as a string.
For each permutation `i.@!@#A.]`, use half the digit length `-@-:@#` to take non-overlapping infixes -- which slices into 2 halves -- and multiply those halves`([:*/".\)"1`. Then (to handle the trailing zero constraint) multiply *that* by `(0<[:".{:\)*`, which takes the last digits of each half, cats them, evaluates that as a two digit number, and checks if it's greater than 0.
Finally, check if the input number `".` is an element of that list `e.`.
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 88 bytes
```
f=(n,i=1)=>n<i*i*10&&i%10&&[...''+i+n/i].sort()+''==[...''+n].sort()||n*10>++i*i&&f(n,i)
```
[Try it online!](https://tio.run/##XYxBDoIwEEX3nGI2th2qtdWgCygXMS4IWlNDpgaIG/HstRhNjJvJn/fz/rW5N0Pb@9u4onA6x@isoKW3Bm1Nlc99bjRjfjHfg1KKc@klrf1RDaEfBUrOrf0U9IXTREmrpUw@Y24exNgGGkJ3Vl24CCeMKXb7DWL2h4ut1jrhzIVeEFgw6S@BoHqnOUqJ8MgAvINkECL8bhCW2TO@AA "JavaScript (Node.js) – Try It Online")
* `[...''+i+n/i].sort()+''==[...''+n].sort()` two factors use and only use digits in original number
	+ if `n/i` is not an integer, it converted into a string with `.` and not equals to another side which doesn't contain a `.`.
* `n<i*i*10`, `n*10>i*i`: lengths of two numbers are the same.
	+ It equip to `i/10 < n/i < i*10`. And since `n` has even number of digits (as question mentioned), `i` and `n/i` will have same number of digits.
* `i%10`: `i` is not end with "0"
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 14 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
œ2δäÅΔPQy€θĀà*
```
Outputs a non-negative integer as truthy and `-1` as falsey.
[Try it online](https://tio.run/##ASgA1/9vc2FiaWX//8WTMs60w6TDhc6UUFF54oKszrjEgMOgKv//MTUzMDAw) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfaXLoZX/j042Orfl8JLDreemBBxaF1j5qGnNuR1HGg4v0Ppfq/M/2tDIzEDH0NjSVMfQxBhImBoDuRZG5jpGhhbmOmYWFkCugZGpIYgyAas1MDUyhFBmJiDK3BTEszAE6TY0MDe1AFKmZuZGYLMMgHJGxiamZrEA).
**Explanation:**
```
œ            # Get all permutations of the (implicit) input
  δ          # Map over each permutation:
 2 ä         #  And split it into two equal-sized halves
    ÅΔ       # Get the 0-based index of the first truthy result,
             # or -1 if none are found:
      P      #  Take the product of the two halves
       Q     #  And check that it's equal to the (implicit) input
      y      #  Push the halves again
       €θ    #  Only leave the last digit of each halve
         Ā   #  Check that it's not 0 (1 if [1-9]; 0 if 0)
          à  #  Get the maximum of these two
      *      #  Multiply the checks to verify both are truthy
             #  (after which the found index is output implicitly as result)
```
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~286~~ ~~240~~ 218 bloody bytes (o,\_,o)
-55 bloody bytes thanks to [ceilingcat](https://codegolf.stackexchange.com/users/52904/ceilingcat)!
```
#define S(x,y)x^=y^=x^=y
o,a,b,c,r;f(int*_){c=atoi(_);v(o,_,o=strlen(_),r=0);r=r;}v(k,_,o,i)char*_;{--k?({for(v(k,_,o,0);i<k;v(k,_,o,!++i))S(_[k%2*i],_[k]);}):(a=atoi(_)/exp10(o/2))*(b=atoi(_+o/2))==c&&(a+b)%10?r=1:0;}
```
[Try it online!](https://tio.run/##bU5Nb8IwDL3zKwxTJ7sNou1thIgfwZFBVULLIkqD0oBAVf/6uoTxscN8sJ/t9@wnxzsp@/5tW5SqLmCBF3aly1pc18LngWY52zDJDC9R1TbMqJUit1phRvyMmmVMi8aaqqjdhBkREzfC8O6Me79jiuRXbsKMt@Pxfo5tqQ0@do6rZnv@aIdRpIgWmC33QRqqFXNgRbyjKeaPn5Pickxi1JOUKMTNfRzdeiHk@zvm0YaCJJ4bkUxj3vXONRxyVSOctdoCDdoBuPCuwBaNXX6s@G1yS96eV1gQkHBXZpDGPhyOIoL2RfWhSoQhegVVeueM4VafNlVBliCAlIDcidCdivlT8wTN0Thhid4Fg1GwHTGw9A/Rf/ml@YN3leN/1n8U3cuZKezJ1OB@dv23LKt81/Tj6vAD "C (gcc) – Try It Online")
The input is a string and the output is either 1 or 0.
The core of the answer is the function `v()`, which implements [Heap's algorithm](https://en.wikipedia.org/wiki/Heap%27s_algorithm) to generate all the possible permutations of the input digits.
Here's an explanation of the code before some golfing:
```
#define S(x,y)x^=y^=x^=y                 // Macro used to swap digits
o,                                       // length of the input string
a,                                       // first half of one of the possible permutations of digits
b,                                       // second half
r;                                       // result: 1 if the input is a vampire number, 0 otherwise
char c[9];                               // copy of the original input that will be compared with the permutations
f(_)char*_;{                             // That's a simple function taking the input string
    r=!strcpy(c,_);                      // initializing `r` to 0 and `c` to the input
    v(o,_,o=strlen(_));                  // calling v(o,_,o) while initializing `o` to the length of the input
    r=r;                                 // and returning rhe result `r`
}
v(                                       // v() is a recursive function taking three parameters:
k,                                       // the length of a substring of digits being permuted
_,                                       // the whole current permutation
o,                                       // the length of the whole permutation
i)                                       // `i` is here just to avoid declaring `int i` inside the `for` loop
char*_;{
    if(k-1){                             // if `k` is not 1
        v(k-1,_,o);                      // call v() to permute `k-1` digits
        for(i=0;++i<k;                   // until `i` is less than `k`
        v(k-1,_,o))                      // call v() to permute `k-1` digit, but only after having
            S(_[k%2?0:i-1],_[k-1]);      // swapped _[k-1] with either _[0] or _[i-1]
    }
    else                                 // else (i.e. if k == 1)
        (a=atoi(_)/exp10(o/2))           // if `a` (getting the first half of the permutation, converted to integer)
        *(b=atoi(_+o/2))                 // multiplied by `b` (getting the second half)
        ==atoi(c)                        // equals the original input
        &&(a+b)%10?                      // and only one between `a` and `b` has trailing zeros
        r=1                              // then the result is set to 1
        :0;                              // otherwise do nothing, this permutation wasn't the right one
}
```
I tried other algorithms, but couldn't find a shorter one. I leave here [the dumbest](https://tio.run/##fVLBbtswDL37K4gWKSRbXu1cFQ3Ypadip@2UZYAsy5lSRR4UBUgW@NfnUUrdJC0wGqAIiu@RfLIq10qN98Ypu281LHahNf2nX5/H@1Z3xml4Igd2pF3viXEBDqLih8WRH4qCnjLJGqaYZxuedcQxS7Ekd/y089K1JJitJl@/Pz9TyhXinojBEiVUXleFW5oVH1Iqxy812AjLy3LD6cmLxEBnyOyWm9VP4ZY@@SnmUjSJ84XZxzmVQp5ZX1a8Ec1rXOAVdjEdkXkjhHp4ILJo6KyuqNdh7x3UfBiGMW6Wo/vWf/FeHtOmgUE8rHaUZ1kMt9I4QrNTBmgJ4li85ymR3CRTAIHUeCxgXkXDGBWDM/atPBF1BAiyIIJELLX9uq4Iaft9YzUNtKgphRnMIcLfYNFwAmxT8ZskUhXFJTV87BhbXS0b2LTk9UjxPVMeBPbA3r89YjpyN2t/uDsGgfKPzJ3Xmrj3N8NFn1fVceThrOl/VL8RGkfeSmt7RWBn/ui@S1JBHithmn1S32A15kt8AVNEV5Y32sV/D0sCqnqtXoDHi5xDdj0wvvEw/lWdlevdWNrtPw) of the tries, which is a solution that doesn't solve the problem. It only finds most of the vampire numbers (probably).
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 54 bytes
```
⊞υ⟦ωθ⟧ＦυＦＥ§ι¹⟦⁺§ι⁰κΦ§ι¹⁻λν⟧⊞υκ⊙ＥΦυ¬⊟ιＩ⪪⊟ι⊘Ｌθ∧Σ﹪ιχ⁼θＩΠι
```
[Try it online!](https://tio.run/##XY1Pa8MwDMXv/RQ6SuBBS9dTT2F0rNAMQ4@jB5OkjalqJ47dP5/eU0ILYwIheO/p/arWhMobzlmnocWk4OemoD/Qenb0ATARTLc0HRZx6@rmjlbBgiSoOQ1/xbmIZ9lPy7EJ/@OldRJnBY7oQAQv3llQOlgXsXCPifP8F@/bR9S@Q0tS8GGGiPuO7UtT8GX42tS4a9wpttjTOAoKV@M@XbD0dWI/8eejvumT4QH7Z5UO4ldxLJdZ57x4X67y25V/AQ "Charcoal – Try It Online") Link is to verbose version of code. Outputs a Charcoal boolean, i.e. `-` for vampire, nothing if not. Explanation:
```
⊞υ⟦ωθ⟧
```
Start a breadth-first enumeration of permutations of the input string.
```
Ｆυ
```
Loop over each partial permutation so far.
```
ＦＥ§ι¹⟦⁺§ι⁰κΦ§ι¹⁻λν⟧⊞υκ
```
Append each unused character to the permutation so far and push the result plus the remaining characters to the list.
```
⊙ＥΦυ¬⊟ι
```
Find whether any of the entries where all of the characters were used, ...
```
Ｉ⪪⊟ι⊘Ｌθ
```
... after being split into halves and cast to integer, ...
```
∧Σ﹪ιχ
```
... have a non-zero sum of the last digits, ...
```
⁼θＩΠι
```
... and have the product of the halves resulting in the original string.
[Answer]
# [Python 2](https://docs.python.org/2/), ~~113 ... 112~~ 109 bytes
```
def f(n,s=sorted):x=s(`n`);l=10**(len(x)/2);return any(x==s(`i`+`n/i`)for i in range(l/10,l)if i%10and n%i<1)
```
[Try it online!](https://tio.run/##XY3BCoMwEETP7VfsRdi1gkmO2vxLBJN2IaySRNCvT821c3oMb5j9Kt9NTK2rDxBQhmzzlopfaTptRieO5mi16nuMXvCk0dCcfDmSwCIXnrZZ7F5ORnYUtgQMLJAW@XiMo1ZDJA7AnVaLrCAdvzXVP8@oFpqej1ttP7kkZKLOgLWgoC3DXUx7Yik31B8 "Python 2 – Try It Online")
-3 byte thanks Kevin Cruijssen
[Answer]
# [Ruby](https://www.ruby-lang.org/), ~~104~~ 96 bytes
It almost looks like a complete English sentence. Which probably is a bad thing for golfing.
```
->n{n.digits.permutation.any?{|s|a,b=s.each_slice(s.size/2).map{|x|x.join.to_i};a%10>0&&a*b==n}}
```
[Try it online!](https://tio.run/##lVBBboMwELzzilUkIKmoazsx0FYk34iUosgJTuMqMSg2EmngFb32df0ItSGHXnvZ0ax2Z0ZzqXfX/pC99Y9LdVOokO/SaFSJy7k23MhSIa6uq1urWx7tMo0E3x@3@iT3YqqRlp/iic7QmVe3tmkb9FFKhUy5ld0r9wle4iDgD7ssU13Xm0ttjlfIYENojCMyf2YRWcztYHNLU5pElKRJFKeppZgy4mAx3GJGyQjxwkHCHEuJ@yY4YakFFic0B/BGnyEoFCW0qrVLgKo2GiZ@UoCvJ@DDRkVw2KgcVhD@fH@F8ALhOnQCQhXDh3fgJy3GxDYixvnf9b8M1oO8s7kbeF4FU4IQsbJ4hrQ4ib1xHULj@hurtSIUsgwwBIGVavKu/wU "Ruby – Try It Online")
It can be written in 94 bytes with [Ruby 2.7](https://rubyreferences.github.io/rubychanges/2.7.html#numbered-block-parameters):
```
->n{n.digits.permutation.any?{|s|a,b=s.each_slice(s.size/2).map{_1.join.to_i};a%10>0&&a*b==n}}
```
[Answer]
# [Python 2](https://docs.python.org/2/), ~~105~~ ~~95~~ 94 bytes
-10 bytes thanks to [Kevin Cruijssen](https://codegolf.stackexchange.com/users/52210/kevin-cruijssen)! (switch to Python 2)  
-1 byte thanks to [dingledooper](https://codegolf.stackexchange.com/users/88546/dingledooper)!
Very inefficient, segfaults for \$ n \gtrsim 18500\$ on TIO.
```
f=lambda n,k=2,S=sorted:k<n and(k%10>n%k<(len(`k`)==len(`n/k`)<S(`k`+`n/k`)==S(`n`)))|f(n,k+1)
```
[Try it online!](https://tio.run/##JY1BCoMwEEX3nmI2QoLSGjcFMb2EFzCtSTtEJ5KkC6F3t6MdGHhvYP5ft/wO1O64rCFmSFsqeC/J5mifn5gw0IwLZqEaHrk7PZvlMRmg2uu2HnTiNzt1vicwNAlfquZOpe/FbEmMfpRan0RX5n44TtVftGajUUr5dYLjKsXxIQICEkRDLytUDbejtisA0IETeCLAGpEy2/4D "Python 2 – Try It Online")
**Commented**:
```
f=lambda n,k=2,S=sorted   # recursive function
  k<n                     # if k>=n return False
  and                     # otherwise:
  ( ... )                 # long boolean expression which is True if k and n//k make n a valid vampire number
    k%10                  # the last digit of k is 
  > n%k                   # larger than n%k which is
  < ( ... )               # less than another boolean expression
                          # These two comparisons can only be satisfied with k%10>0<1
      len(`k`)            # the number of digits of k
   == len(`n/k`)          # is equal to the number of digits of n//k
    < S(`k`+`n/k`)        # and sorting the digits of k and n//k 
   == S(`n`)              # results in the same list as sorting the digits of n
| f(n,k+1)                # bitwise OR with result of the recursive call
```
[Answer]
# JavaScript (ES6), 93 bytes
Assumes that the input has an even number of digits. Returns a Boolean value.
```
f=(n,[...a]=n,p='')=>a[p.length]?a.some((v,i)=>f(n,a.filter(_=>i--),p+v)):p%10&&p*a.join``==n
```
[Try it online!](https://tio.run/##Xc/RSsMwFAbg@z7FMbAux7YhqWzCZib4GnNsYSZbRjwJbakX4rPXOHah3v0/34HDfzGj6Y@dT0ND8c1Ok9Oc6q0Qwuw01UnP56g3ZptEsHQazrtnI/r4bjkfa5/F5WsjnA@D7fheb3zTYJ2qEXGVZkqWZbo34hI9HQ5a03SM1MdgRYgn7jhTarF8bBli8R8WD1LKH/gj7JVebIgfoNrMcsWwcLHjBBrUGgiebpBzVSF8FgB3PHMFecZtAcygRShLcFdg7Fp@fyFcF1/TNw "JavaScript (Node.js) – Try It Online")
---
# JavaScript (ES6), 97 bytes
Expects the integer as a string. Returns **0** or **1**.
```
f=(n,[...a]=n,p,q,k)=>a.some((v,i)=>f(n,a.filter(_=>i--),k?[p]+v:p,k?q:[q]+v,!k))|p%10*!(p*q^n|k)
```
[Try it online!](https://tio.run/##XY5BbsIwEEX3OcVgqchDHMtuBUihplKvEaCyqI1C0rGToHRRevbUFZuW3fvzvr7mbEc7HPs6XgoK726avOEkKiml3RsSUXSiQbO1cggfjvNR1Cn5VLHS1@3F9fzNbOuiQNG8VHGfj2VM1JVVl1jMGsRrfNBqMeNx0R3o2uB0DDSE1sk2nLjnTOvlav3IELN7sXxSSv2Kf4bt6NW14RN0sqpkmPnQcwIDegMEz7d7wjxH@MoA0reQA2MI8zn8XSLcZN/TDw "JavaScript (Node.js) – Try It Online")
### Commented
```
f = (                     // f is a recursive function taking:
  n,                      //   n = input integer, as a string
  [...a] = n,             //   a[] = list of digits of n
  p, q,                   //   n is split into p and q (both initially undefined)
  k                       //   k is a flag, set on odd iterations
) =>                      //
  a.some((v, i) =>        // for each digit v at position i in a[]:
    f(                    //   do a recursive call:
      n,                  //     pass n unchanged
      a.filter(_ => i--), //     remove the i-th entry from a[]
      k ? [p] + v : p,    //     append v to p if k is set
      k ? q : [q] + v,    //     append v to q if k is not set
      !k                  //     toggle k
    )                     //   end of recursive call
  )                       // end of some()
  |                       // success if:
    p % 10 *              //   the last digit of p is not 0,
    !(p * q ^ n | k)      //   p * q = n and k is not set
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 15 bytes
```
Œ!ŒH€SṪ$ƇḌP€=ḌẸ
```
[Try it online!](https://tio.run/##y0rNyan8///oJMWjkzweNa0Jfrhzlcqx9oc7egKAPFsg/XDXjv///0cb6hjomOoY6ZjpmMQCAA "Jelly – Try It Online")
Takes a list of digits.
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 20 bytes
```
á mó f_dÌÃ®mì ×Ãd¥Uì
```
[Try it online!](https://tio.run/##AS8A0P9qYXB0///DoSBtw7MgZl9kw4zDg8KubcOsIMOXw4NkwqVVw6z//1sxLDIsNiwwXQ "Japt – Try It Online") or [check all test cases](https://tio.run/##JYwxCgJBDEWvkgOMkGQmM/EagjbLIsJiIQxYeINt7a0t7BYbb7A52JjR5j8eyf@X0/XWbGn2hGofOB8nu9u8vqstYA@bp/W19/PgAYexDcQZA8WtBErRQ6KrcglMWkJWdUUW6ki/XxSmP3LqKNJNqbcJi6hDcuEAfQxxhE3dfQE) (specifically the 15 vampire numbers and 153000)
Takes input as an array of digits. Input as an integer is [one byte longer](https://tio.run/##y0osKPn///AahcMLFXIPb1ZIi0853HO4@dC6XJDY9MPNKYeWhv7/b2hkZgAA)
Explanation:
```
á mó f_dÌÃ®mì ×Ãd¥Uì    
á                       # Get all permutations of the input digits
  mó                    # Divide each permutation into two groups of equal length
     f_  Ã              # Only keep ones where:
       dÌ               #  At least one of the groups ends with a non-zero number
          ®    Ã        # For each remaining pair of groups:
           mì           #  Treat each group of digits as an integer
              ×         #  Multiply those integers
                d       # Return true if at least one of the results...
                 ¥Uì    # ... Is equal to the original number
```
]