Hostile Divisor Numbers












31












$begingroup$


Some divisors of positive integers really hate each other and they don't like to share one or more common digits.



Those integers are called Hostile Divisor Numbers (HDN)



Examples



Number 9566 has 4 divisors: 1, 2, 4783 and 9566

(as you can see, no two of them share the same digit).

Thus, 9566 is a Hostile Divisor Number



Number 9567 is NOT HDN because its divisors (1, 3, 9, 1063, 3189, 9567) share some common digits.



Here are the first few HDN



1,2,3,4,5,6,7,8,9,23,27,29,37,43,47,49,53,59,67,73,79,83,86,87,89,97,223,227,229,233,239,257,263,267,269,277,283,293,307,337...       





Task



The above list goes on and your task is to find the nth HDN



Input



A positive integer n from 1 to 4000



Output



The nth HDN



Test Cases



here are some 1-indexed test cases.

Please state which indexing system you use in your answer to avoid confusion.



input -> output     
1 1
10 23
101 853
1012 26053
3098 66686
4000 85009


This is code-golf, so the lowest score in bytes wins.



EDIT



Good news!
I submitted my sequence to OEIS and...

Hostile Divisor Numbers are now OEIS A307636










share|improve this question











$endgroup$








  • 1




    $begingroup$
    I think square numbers would be the least hostile of numbers.
    $endgroup$
    – Joe Frambach
    May 3 at 17:59








  • 3




    $begingroup$
    @JoeFrambach That I do not understand. There are perfect-square HDN. For a somewhat large example, 94699599289, the square of 307733, has divisors [1, 307733, 94699599289] which shows it is a HDN. Seems hostile to me.
    $endgroup$
    – Jeppe Stig Nielsen
    May 5 at 17:21










  • $begingroup$
    @JeppeStigNielsen For a much smaller example, why not just 49? Factors [1, 7, 49] qualifies as hostile... Or, well, 4: [1, 2, 4]...
    $endgroup$
    – Darrel Hoffman
    May 6 at 13:27












  • $begingroup$
    @DarrelHoffman Not to mention, the square number 1 with divisor list [1]. (Maybe large HDN are more interesting?)
    $endgroup$
    – Jeppe Stig Nielsen
    May 6 at 18:09










  • $begingroup$
    I interpreted 49 as having divisors [7, 7], which not only share digits but are the same digits. 49 has factors [1, 7, 49]
    $endgroup$
    – Joe Frambach
    May 6 at 19:59
















31












$begingroup$


Some divisors of positive integers really hate each other and they don't like to share one or more common digits.



Those integers are called Hostile Divisor Numbers (HDN)



Examples



Number 9566 has 4 divisors: 1, 2, 4783 and 9566

(as you can see, no two of them share the same digit).

Thus, 9566 is a Hostile Divisor Number



Number 9567 is NOT HDN because its divisors (1, 3, 9, 1063, 3189, 9567) share some common digits.



Here are the first few HDN



1,2,3,4,5,6,7,8,9,23,27,29,37,43,47,49,53,59,67,73,79,83,86,87,89,97,223,227,229,233,239,257,263,267,269,277,283,293,307,337...       





Task



The above list goes on and your task is to find the nth HDN



Input



A positive integer n from 1 to 4000



Output



The nth HDN



Test Cases



here are some 1-indexed test cases.

Please state which indexing system you use in your answer to avoid confusion.



input -> output     
1 1
10 23
101 853
1012 26053
3098 66686
4000 85009


This is code-golf, so the lowest score in bytes wins.



EDIT



Good news!
I submitted my sequence to OEIS and...

Hostile Divisor Numbers are now OEIS A307636










share|improve this question











$endgroup$








  • 1




    $begingroup$
    I think square numbers would be the least hostile of numbers.
    $endgroup$
    – Joe Frambach
    May 3 at 17:59








  • 3




    $begingroup$
    @JoeFrambach That I do not understand. There are perfect-square HDN. For a somewhat large example, 94699599289, the square of 307733, has divisors [1, 307733, 94699599289] which shows it is a HDN. Seems hostile to me.
    $endgroup$
    – Jeppe Stig Nielsen
    May 5 at 17:21










  • $begingroup$
    @JeppeStigNielsen For a much smaller example, why not just 49? Factors [1, 7, 49] qualifies as hostile... Or, well, 4: [1, 2, 4]...
    $endgroup$
    – Darrel Hoffman
    May 6 at 13:27












  • $begingroup$
    @DarrelHoffman Not to mention, the square number 1 with divisor list [1]. (Maybe large HDN are more interesting?)
    $endgroup$
    – Jeppe Stig Nielsen
    May 6 at 18:09










  • $begingroup$
    I interpreted 49 as having divisors [7, 7], which not only share digits but are the same digits. 49 has factors [1, 7, 49]
    $endgroup$
    – Joe Frambach
    May 6 at 19:59














31












31








31


1



$begingroup$


Some divisors of positive integers really hate each other and they don't like to share one or more common digits.



Those integers are called Hostile Divisor Numbers (HDN)



Examples



Number 9566 has 4 divisors: 1, 2, 4783 and 9566

(as you can see, no two of them share the same digit).

Thus, 9566 is a Hostile Divisor Number



Number 9567 is NOT HDN because its divisors (1, 3, 9, 1063, 3189, 9567) share some common digits.



Here are the first few HDN



1,2,3,4,5,6,7,8,9,23,27,29,37,43,47,49,53,59,67,73,79,83,86,87,89,97,223,227,229,233,239,257,263,267,269,277,283,293,307,337...       





Task



The above list goes on and your task is to find the nth HDN



Input



A positive integer n from 1 to 4000



Output



The nth HDN



Test Cases



here are some 1-indexed test cases.

Please state which indexing system you use in your answer to avoid confusion.



input -> output     
1 1
10 23
101 853
1012 26053
3098 66686
4000 85009


This is code-golf, so the lowest score in bytes wins.



EDIT



Good news!
I submitted my sequence to OEIS and...

Hostile Divisor Numbers are now OEIS A307636










share|improve this question











$endgroup$




Some divisors of positive integers really hate each other and they don't like to share one or more common digits.



Those integers are called Hostile Divisor Numbers (HDN)



Examples



Number 9566 has 4 divisors: 1, 2, 4783 and 9566

(as you can see, no two of them share the same digit).

Thus, 9566 is a Hostile Divisor Number



Number 9567 is NOT HDN because its divisors (1, 3, 9, 1063, 3189, 9567) share some common digits.



Here are the first few HDN



1,2,3,4,5,6,7,8,9,23,27,29,37,43,47,49,53,59,67,73,79,83,86,87,89,97,223,227,229,233,239,257,263,267,269,277,283,293,307,337...       





Task



The above list goes on and your task is to find the nth HDN



Input



A positive integer n from 1 to 4000



Output



The nth HDN



Test Cases



here are some 1-indexed test cases.

Please state which indexing system you use in your answer to avoid confusion.



input -> output     
1 1
10 23
101 853
1012 26053
3098 66686
4000 85009


This is code-golf, so the lowest score in bytes wins.



EDIT



Good news!
I submitted my sequence to OEIS and...

Hostile Divisor Numbers are now OEIS A307636







code-golf sequence






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 4 at 8:14







J42161217

















asked May 3 at 13:42









J42161217J42161217

15.1k21457




15.1k21457








  • 1




    $begingroup$
    I think square numbers would be the least hostile of numbers.
    $endgroup$
    – Joe Frambach
    May 3 at 17:59








  • 3




    $begingroup$
    @JoeFrambach That I do not understand. There are perfect-square HDN. For a somewhat large example, 94699599289, the square of 307733, has divisors [1, 307733, 94699599289] which shows it is a HDN. Seems hostile to me.
    $endgroup$
    – Jeppe Stig Nielsen
    May 5 at 17:21










  • $begingroup$
    @JeppeStigNielsen For a much smaller example, why not just 49? Factors [1, 7, 49] qualifies as hostile... Or, well, 4: [1, 2, 4]...
    $endgroup$
    – Darrel Hoffman
    May 6 at 13:27












  • $begingroup$
    @DarrelHoffman Not to mention, the square number 1 with divisor list [1]. (Maybe large HDN are more interesting?)
    $endgroup$
    – Jeppe Stig Nielsen
    May 6 at 18:09










  • $begingroup$
    I interpreted 49 as having divisors [7, 7], which not only share digits but are the same digits. 49 has factors [1, 7, 49]
    $endgroup$
    – Joe Frambach
    May 6 at 19:59














  • 1




    $begingroup$
    I think square numbers would be the least hostile of numbers.
    $endgroup$
    – Joe Frambach
    May 3 at 17:59








  • 3




    $begingroup$
    @JoeFrambach That I do not understand. There are perfect-square HDN. For a somewhat large example, 94699599289, the square of 307733, has divisors [1, 307733, 94699599289] which shows it is a HDN. Seems hostile to me.
    $endgroup$
    – Jeppe Stig Nielsen
    May 5 at 17:21










  • $begingroup$
    @JeppeStigNielsen For a much smaller example, why not just 49? Factors [1, 7, 49] qualifies as hostile... Or, well, 4: [1, 2, 4]...
    $endgroup$
    – Darrel Hoffman
    May 6 at 13:27












  • $begingroup$
    @DarrelHoffman Not to mention, the square number 1 with divisor list [1]. (Maybe large HDN are more interesting?)
    $endgroup$
    – Jeppe Stig Nielsen
    May 6 at 18:09










  • $begingroup$
    I interpreted 49 as having divisors [7, 7], which not only share digits but are the same digits. 49 has factors [1, 7, 49]
    $endgroup$
    – Joe Frambach
    May 6 at 19:59








1




1




$begingroup$
I think square numbers would be the least hostile of numbers.
$endgroup$
– Joe Frambach
May 3 at 17:59






$begingroup$
I think square numbers would be the least hostile of numbers.
$endgroup$
– Joe Frambach
May 3 at 17:59






3




3




$begingroup$
@JoeFrambach That I do not understand. There are perfect-square HDN. For a somewhat large example, 94699599289, the square of 307733, has divisors [1, 307733, 94699599289] which shows it is a HDN. Seems hostile to me.
$endgroup$
– Jeppe Stig Nielsen
May 5 at 17:21




$begingroup$
@JoeFrambach That I do not understand. There are perfect-square HDN. For a somewhat large example, 94699599289, the square of 307733, has divisors [1, 307733, 94699599289] which shows it is a HDN. Seems hostile to me.
$endgroup$
– Jeppe Stig Nielsen
May 5 at 17:21












$begingroup$
@JeppeStigNielsen For a much smaller example, why not just 49? Factors [1, 7, 49] qualifies as hostile... Or, well, 4: [1, 2, 4]...
$endgroup$
– Darrel Hoffman
May 6 at 13:27






$begingroup$
@JeppeStigNielsen For a much smaller example, why not just 49? Factors [1, 7, 49] qualifies as hostile... Or, well, 4: [1, 2, 4]...
$endgroup$
– Darrel Hoffman
May 6 at 13:27














$begingroup$
@DarrelHoffman Not to mention, the square number 1 with divisor list [1]. (Maybe large HDN are more interesting?)
$endgroup$
– Jeppe Stig Nielsen
May 6 at 18:09




$begingroup$
@DarrelHoffman Not to mention, the square number 1 with divisor list [1]. (Maybe large HDN are more interesting?)
$endgroup$
– Jeppe Stig Nielsen
May 6 at 18:09












$begingroup$
I interpreted 49 as having divisors [7, 7], which not only share digits but are the same digits. 49 has factors [1, 7, 49]
$endgroup$
– Joe Frambach
May 6 at 19:59




$begingroup$
I interpreted 49 as having divisors [7, 7], which not only share digits but are the same digits. 49 has factors [1, 7, 49]
$endgroup$
– Joe Frambach
May 6 at 19:59










19 Answers
19






active

oldest

votes


















9












$begingroup$


05AB1E, 12 10 bytes



µNNÑ€ÙSDÙQ


-2 bytes thanks to @Emigna.



1-indexed



Try it online or verify most test cases (last two test cases are omitted, since they time out).



Explanation:





µ           # Loop while the counter_variable is not equal to the (implicit) input yet:
N # Push the 0-based index of the loop to the stack
NÑ # Get the divisors of the 0-based index as well
# i.e. N=9566 → [1,2,4783,9566]
# i.e. N=9567 → [1,3,9,1063,3189,9567]
€Ù # Uniquify the digits of each divisor
# → ["1","2","4783","956"]
# → ["1","3","9","1063","3189","9567"]
S # Convert it to a flattened list of digits
# → ["1","2","4","7","8","3","9","5","6"]
# → ["1","3","9","1","0","6","3","3","1","8","9","9","5","6","7"]
D # Duplicate this list
Ù # Unique the digits
# → ["1","2","4","7","8","3","9","5","6"]
# → ["1","3","9","0","6","8","5","7"]
Q # And check if it is still equal to the duplicated list
# → 1 (truthy)
# → 0 (falsey)
# And if it's truthy: implicitly increase the counter_variable by 1
# (After the loop: implicitly output the top of the stack,
# which is the pushed index)





share|improve this answer











$endgroup$









  • 2




    $begingroup$
    You beat me to it this time. I had µNNÑ€ÙSDÙQ for 10.
    $endgroup$
    – Emigna
    May 3 at 14:05






  • 2




    $begingroup$
    @Emigna Ah, I was just working on an alternative with µ, so you save me the trouble. ;)
    $endgroup$
    – Kevin Cruijssen
    May 3 at 14:06










  • $begingroup$
    this is poetically eloquent
    $endgroup$
    – don bright
    May 8 at 23:45



















7












$begingroup$


Python 2, 104 bytes





n=input()
x=1
while n:
x=i=x+1;d={0};c=1
while i:m=set(`i`*(x%i<1));c*=d-m==d;d|=m;i-=1
n-=c
print x


Try it online!



0-indexed.






share|improve this answer









$endgroup$





















    6












    $begingroup$


    Jelly, 10 bytes



    ÆDQ€FQƑµ#Ṫ


    Try it online!



    -1 byte thanks to ErikTheOutgolfer



    Takes input from STDIN, which is unusual for Jelly but normal where nfind is used.



    ÆDQ€FQƑµ#Ṫ  Main link
    Ṫ Get the last element of
    # The first <input> elements that pass the filter:
    ÆD Get the divisors
    Q€ Uniquify each (implicitly converts a number to its digits)
    F Flatten the list
    QƑ Does that list equal itself when deduplicated?


    2-indexed






    share|improve this answer











    $endgroup$













    • $begingroup$
      is this 2-indexed? It's ok with me but please state it for others
      $endgroup$
      – J42161217
      May 3 at 14:20










    • $begingroup$
      It's whatever your test cases were, so 1
      $endgroup$
      – HyperNeutrino
      May 3 at 14:21






    • 3




      $begingroup$
      No it isn't. 101 returns 839. and 102 -> 853. It works fine but it is 2-indexed
      $endgroup$
      – J42161217
      May 3 at 14:23






    • 1




      $begingroup$
      @J42161217 wait what? i guess when i moved the nfind it changed the indexing lol
      $endgroup$
      – HyperNeutrino
      May 3 at 14:33






    • 1




      $begingroup$
      ⁼Q$ is the same as .
      $endgroup$
      – Erik the Outgolfer
      May 3 at 14:35



















    5












    $begingroup$

    JavaScript (ES6), 78 bytes



    1-indexed.





    n=>eval("for(k=0;n;n-=!d)for(s=d=++k+'';k%--d||d*!s.match(`[${s+=d,d}]`););k")


    Try it online!



    Faster version, 79 bytes





    n=>{for(k=0;n;n-=!d)for(s=d=++k+'';k%--d||d*!s.match(`[${s+=d,d}]`););return k}


    Try it online!



    How?



    Given an integer $k>0$, we build the string $s$ as the concatenation of all divisors of $k$.



    Because $k$ is always a divisor of itself, $s$ is initialized to $k$ (coerced to a string) and the first divisor that we try is $d=k-1$.



    For each divisor $d$ of $k$, we test whether any digit of $d$ can be found in $s$ by turning $d$ into a character set in a regular expression.



    Examples





    • $s=text{"}956647832text{"}$, $d=1$"956647832".match(/[1]/) is falsy


    • $s=text{"}9567text{"}$, $d=3189$"9567".match(/[3189]/) is truthy


    Commented



    This is the version without eval(), for readability



    n => {                   // n = input
    for( // for() loop:
    k = 0; // start with k = 0
    n; // go on until n = 0
    n -= !d // decrement n if the last iteration resulted in d = 0
    ) //
    for( // for() loop:
    s = // start by incrementing k and
    d = ++k + ''; // setting both s and d to k, coerced to a string
    k % --d || // decrement d; always go on if d is not a divisor of k
    d * // stop if d = 0
    !s.match( // stop if any digit of d can be found in s
    `[${s += d, d}]` // append d to s
    ); //
    ); // implicit end of inner for() loop
    // implicit end of outer for() loop
    return k // return k
    } //





    share|improve this answer











    $endgroup$





















      4












      $begingroup$


      Perl 6, 53 bytes



      {(grep {/(.).*$0/R!~~[~] grep $_%%*,1..$_},^∞)[$_]}


      Try it online!



      1-indexed.



      /(.).*$0/ matches any number with a repeated digit.



      grep $_ %% *, 1 .. $_ returns a list of all divisors of the number $_ currently being checked for membership in the list.



      [~] concatenates all of those digits together, and then R!~~ matches the string on the right against the pattern on the left. (~~ is the usual match operator, !~~ is the negation of that operator, and R is a metaoperator that swaps the arguments of !~~.)






      share|improve this answer









      $endgroup$













      • $begingroup$
        50 bytes
        $endgroup$
        – Jo King
        May 8 at 21:43



















      4












      $begingroup$


      Python 2 (PyPy), 117 114 bytes



      Uses 1-indexing





      k=input();n=0;r=range
      while k:n+=1;k-=1-any(set(`a`)&set(`b`)for a in r(1,n+1)for b in r(1,a)if n%a<1>n%b)
      print n


      Try it online!






      share|improve this answer











      $endgroup$





















        3












        $begingroup$

        Wolfram Language 103 bytes



        Uses 1-indexing.
        I'm surprised it required so much code.



        (k=1;u=Union;n=2;l=Length;While[k<#,If[l[a=Join@@u/@IntegerDigits@Divisors@#]==l@u@a&@n,k++];n++];n-1)&





        share|improve this answer









        $endgroup$













        • $begingroup$
          Can you please add a TIO link so that everybody can check your answer?
          $endgroup$
          – J42161217
          May 3 at 16:40










        • $begingroup$
          95 bytes: (n=t=1;While[t<=#,If[!Or@@IntersectingQ@@@Subsets[IntegerDigits@Divisors@n,{2}],t++];n++];n-1)& I am not planning to post an answer so I will leave this here
          $endgroup$
          – J42161217
          May 3 at 16:45










        • $begingroup$
          @J42161217, I've been trying to get the code to work in TIO without success. There must be some trick I'm missing.
          $endgroup$
          – DavidC
          May 3 at 20:55










        • $begingroup$
          @J42161217, Your code seems to work but takes 3 times the runtime. You can submit it as your own. (Maybe I'll learn how to implement TIO from your example.)
          $endgroup$
          – DavidC
          May 3 at 20:57










        • $begingroup$
          Very fast indeed! here is your link Try it online!
          $endgroup$
          – J42161217
          May 3 at 21:20



















        3












        $begingroup$


        PowerShell, 112 bytes





        for($a=$args[0];$a-gt0){$z=,0*10;1..++$n|?{!($n%$_)}|%{"$_"|% t*y|sort -u|%{$z[+"$_"]++}};$a-=!($z|?{$_-ge2})}$n


        Try it online!



        Takes 1-indexed input $args[0], stores that into $a, loops until that hits 0. Each iteration, we zero-out a ten-element array $z (used to hold our digit counts). Then we construct our list of divisors with 1..++$n|?{!($n%$_)}. For each divisor, we cast it to a string "$_", cast it toCharArray, and sort those digits with the -unique flag (because we don't care if a divisor itself has duplicate digits). We then increment the appropriate digit count in $z. Then, we decrement $a only if $z contains 0s and 1s (i.e., we've found an HDN). If we've finished our for loop, that means we found the appropriate number of HDNs, so we leave $n on the pipeline and output is implicit.






        share|improve this answer









        $endgroup$













        • $begingroup$
          you could save some bytes: $a-=!($z-ge2) instead $a-=!($z|?{$_-ge2})
          $endgroup$
          – mazzy
          May 4 at 6:40










        • $begingroup$
          a bit golfed
          $endgroup$
          – mazzy
          May 4 at 8:13



















        3












        $begingroup$


        Python 3, 115 bytes



        1-indexed





        f=lambda n,x=1,s="",l="",d=1:n and(d>x+1and f(n-1,x+1)or{*s}&{*l}and f(n,x+1)or f(n,x,s+l,(1-x%d)*str(d),d+1))or~-x


        Try it online!



        This uses a lot of recursion; even with increased recursion limit, it can't do f(30). I think it might be golfable further, and I tried finding something to replace the (1-x%d) with, but couldn't come up with anything (-~-x%d has the wrong precedence). Any bytes that can be shaved off are greatly appreciated.



        How it works





        # n: HDNs to go
        # x: Currently tested number
        # s: String of currently seen divisor digits
        # l: String of digits of last tried divisor if it was a divisor, empty string otherwise
        # d: Currently tested divisor

        f=lambda n,x=1,s="",l="",d=1:n and( # If there are still numbers to go
        d>x+1and f(n-1,x+1)or # If the divisors have been
        # exhausted, a HDN has been found
        {*s}&{*l}and f(n,x+1)or # If there were illegal digits in
        # the last divisor, x isn't a HDN
        f(n,x,s+l,(1-x%d)*str(d),d+1)
        # Else, try the next divisor, and
        # check this divisor's digits (if
        # if is one) in the next call
        )or~-x # Else, return the answer





        share|improve this answer











        $endgroup$





















          2












          $begingroup$


          Brachylog (v2), 14 bytes



          ;A{ℕfdᵐc≠&}ᶠ⁽t


          Try it online!



          Function submission; input from the left, output to the right. (The TIO link contains a command-line argument to run a function as though it were a full program.)



          Explanation



          "Is this a hostile divisor number?" decision-problem code:



          ℕfdᵐc≠
          ℕ number is ≥0 (required to match the question's definition of "nth solution")
          f list of all factors of the number
          ᵐ for each factor
          d deduplicate its digits
          c concatenate all the deduplications with each other
          ≠ the resulting number has no repeated digits


          This turned out basically the same as @UnrelatedString's, although I wrote it independently.



          "nth solution to a decision-problem" wrapper:



          ;A{…&}ᶠ⁽t
          & output the successful input to
          { }ᶠ the first n solutions of the problem
          ⁽ taking <n, input> as a pair
          ;A form a pair of user input and a "no constraints" value
          t take the last solution (of those first n)


          This is one of those cases where the wrapper required to produce the nth output is significantly longer than the code required to test each output in turn :-)



          I came up with this wrapper independently of @UnrelatedString's. It's the same length and works on the same principle, but somehow ends up being written rather differently. It does have more potential scope for improvement, as we could add constraints on what values we were looking at for free via replacing the A with some constraint variable, but none of the possible constraint variables save bytes. (If there were a "nonnegative integer" constraint variable, you could replace the A with it, and then save a byte via making the the unnecessary.)






          share|improve this answer











          $endgroup$













          • $begingroup$
            It’s 2-indexed?
            $endgroup$
            – FrownyFrog
            May 9 at 10:03



















          2












          $begingroup$

          Java 10, 149 139 138 126 125 120 bytes





          n->{int r=0,i,d;for(;n>0;n-=d){var s="1";for(r++,d=i=1;i++<r;)if(r%i<1){d=s.matches(".*["+i+"].*")?0:d;s+=i;}}return r;}


          -10 bytes by using .matches instead of .contains per digit, inspired by @Arnauld's JavaScript answer.

          -5 bytes thanks to @ValueInk



          1-indexed



          Try it online.



          Explanation:



          n->{                 // Method with integer as both parameter and return-type
          int r=0, // Result-integer, starting at 0
          i, // Index integer
          d; // Decrement integer
          for(;n>0; // Loop until the input `n` is 0:
          n-=d){ // After every iteration: decrease `n` by the decrement integer `d`
          var s="1"; // Create a String `s`, starting at "1"
          for(r++, // Increase the result by 1
          d=i=1; // (Re)set the decrement integer to 1
          i++<r;) // Inner loop `i` in the range [2, r]:
          if(r%i<1){ // If `r` is divisible by `i`:
          d=s.matches(".*["+i+"].*")?
          // If string `s` contains any digits also found in integer `i`:
          0 // Set the decrement integer `d` to 0
          :d; // Else: leave `d` unchanged
          s+=i;}} // And then append `i` to the String `s`
          return r;} // After the loops, return the result `r`





          share|improve this answer











          $endgroup$









          • 1




            $begingroup$
            If you switch the i and s in your regex search, you don't need the extra string conversion, and the result is the same.
            $endgroup$
            – Value Ink
            May 8 at 2:03










          • $begingroup$
            @ValueInk Thanks! :)
            $endgroup$
            – Kevin Cruijssen
            May 8 at 6:22



















          1












          $begingroup$


          Brachylog, 16 bytes



          g{∧0<.fdᵐc≠∧}ᵘ⁾t


          Try it online!



          Very slow, and twice as long as it would be if this was a decision-problem. 1-indexed.



                              The output
          t is the last
          ᵘ⁾ of a number of unique outputs,
          g where that number is the input,
          { } from the predicate declaring that:
          . the output
          < which is greater than
          0 zero
          ∧ (which is not the empty list)
          f factorized
          ᵐ with each factor individually
          d having duplicate digits removed
          ≠ has no duplicate digits in
          c the concatenation of the factors
          ∧ (which is not the output).





          share|improve this answer









          $endgroup$









          • 1




            $begingroup$
            If you just read that explanation as a sentence though...
            $endgroup$
            – FireCubez
            May 4 at 11:24










          • $begingroup$
            I try to write my explanations like plain English, which typically ends up just making them harder to read
            $endgroup$
            – Unrelated String
            May 4 at 20:25



















          1












          $begingroup$


          Wolfram Language (Mathematica), 74 bytes



          Nest[1+#//.a_/;!Unequal@@Join@@Union/@IntegerDigits@Divisors@a:>a+1&,0,#]&


          Try it online!






          share|improve this answer









          $endgroup$





















            1












            $begingroup$


            Japt v2.0a0, 17 bytes



            _=â ®sâìUµZ¶â}f1


            Try it



            Port of this Brachylog answer.



            Credit: 4 bytes savings total thanks to Shaggy who also suggested there was a better solution leading to many more bytes :)





            Original answer 28 byte approach:



            Èâ¬rÈ«è"[{Y}]" ©X+Y}Xs)«U´Ãa


            Try it



            Port of this JavaScript answer.






            share|improve this answer











            $endgroup$













            • $begingroup$
              28 bytes
              $endgroup$
              – Shaggy
              May 7 at 17:04










            • $begingroup$
              Nice - I hadn't used the « shortcut before :) I figure if Shaggy is only improving on my score by a handful of bytes, I must be getting (somewhat) decent at this?
              $endgroup$
              – dana
              May 7 at 17:42












            • $begingroup$
              It can be done in 20 (maybe less) b7 employing a slightly different method.
              $endgroup$
              – Shaggy
              May 7 at 18:43










            • $begingroup$
              Hah - I guess I spoke too soon :) yeah, some of the other golfing lang's have much shorter solutions.
              $endgroup$
              – dana
              May 7 at 19:29






            • 1




              $begingroup$
              17 bytes
              $endgroup$
              – Shaggy
              May 8 at 17:56



















            0












            $begingroup$


            Icon, 123 bytes



            procedure f(n)
            k:=m:=0
            while m<n do{
            k+:=1
            r:=0
            s:=""
            every k%(i:=1 to k)=0&(upto(i,s)&r:=1)|s++:=i
            r=0&m+:=1}
            return k
            end


            Try it online!



            1-indexed. Really slow for big inputs.






            share|improve this answer









            $endgroup$





















              0












              $begingroup$


              Perl 6, 74 bytes





              {(grep {!grep *>1,values [(+)] map *.comb.Set,grep $_%%*,1..$_},1..*)[$_]}


              0-indexed. Only the first three cases are listed on TIO since it's too slow to test the rest.



              Try it online!






              share|improve this answer









              $endgroup$









              • 1




                $begingroup$
                57 bytes
                $endgroup$
                – Jo King
                May 8 at 6:07



















              0












              $begingroup$


              Ruby, 110 97 92 84 bytes



              -13 bytes by leveraging @Arnauld's JavaScript regex check.



              -5 bytes for swapping out the times loop for a decrementer and a while.



              -8 bytes by ditching combination for something more like the other answers.





              ->n{x=0;n-=1if(s='';1..x+=1).all?{|a|x%a>0||(e=/[#{a}]/!~s;s+=a.to_s;e)}while n>0;x}


              Try it online!






              share|improve this answer











              $endgroup$





















                0












                $begingroup$


                Perl 5 -p, 66 bytes





                map{1while(join$",map{$%$_==0&&$_}1..++$)=~/(d).* .*1/}1..$_}{


                Try it online!



                1 indexed






                share|improve this answer









                $endgroup$





















                  0












                  $begingroup$


                  J, 87 59 bytes



                  -28 bytes thanks to FrownFrog



                  0{(+1,1(-:~.)@;@(~.@":&.>@,i.#~0=i.|])@+{.)@]^:(>{:)^:_&0 0


                  Try it online!



                  original




                  J, 87 bytes



                  [:{:({.@](>:@[,],([:(-:~.)[:-.&' '@,/~.@":"0)@((]#~0=|~)1+i.)@[#[)}.@])^:(#@]<1+[)^:_&1


                  Try it online!



                  Yikes.



                  This is atrociously long for J, but I'm not seeing great ways to bring it down.



                  explanation



                  It helps to introduce a couple helper verbs to see what's happening:



                  d=.(]#~0=|~)1+i.
                  h=. [: (-:~.) [: -.&' '@,/ ~.@":"0




                  • d returns a list of all divisors of its argument


                  • h tells you such a list is hostile. It stringifies and deduplicates each number ~.@":"0, which returns a square matrix where shorter numbers are padded with spaces. -.&' '@,/ flattens the matrix and removes spaces, and finally (-:~.) tells you if that number has repeats or not.


                  With those two helpers our overall, ungolfed verb becomes:



                  [: {: ({.@] (>:@[ , ] , h@d@[ # [) }.@])^:(#@] < 1 + [)^:_&1


                  Here we maintain a list whose head is our "current candidate" (which starts at 1), and whose tail is all hostile numbers found so far.



                  We increment the head of the list >:@[ on each iteration, and only append the "current candidate" if it is hostile h@d@[ # [. We keep doing this until our list length reaches 1 + n: ^:(#@] < 1 + [)^:_.



                  Finally, when we're done, we return the last number of this list [: {: which is the nth hostile number.






                  share|improve this answer











                  $endgroup$













                  • $begingroup$
                    66
                    $endgroup$
                    – FrownyFrog
                    May 9 at 9:21












                  • $begingroup$
                    62
                    $endgroup$
                    – FrownyFrog
                    May 9 at 9:41










                  • $begingroup$
                    This is great, many thanks. Will go over it and update tonight
                    $endgroup$
                    – Jonah
                    May 9 at 12:39










                  • $begingroup$
                    59
                    $endgroup$
                    – FrownyFrog
                    May 9 at 23:54












                  Your Answer






                  StackExchange.ifUsing("editor", function () {
                  StackExchange.using("externalEditor", function () {
                  StackExchange.using("snippets", function () {
                  StackExchange.snippets.init();
                  });
                  });
                  }, "code-snippets");

                  StackExchange.ready(function() {
                  var channelOptions = {
                  tags: "".split(" "),
                  id: "200"
                  };
                  initTagRenderer("".split(" "), "".split(" "), channelOptions);

                  StackExchange.using("externalEditor", function() {
                  // Have to fire editor after snippets, if snippets enabled
                  if (StackExchange.settings.snippets.snippetsEnabled) {
                  StackExchange.using("snippets", function() {
                  createEditor();
                  });
                  }
                  else {
                  createEditor();
                  }
                  });

                  function createEditor() {
                  StackExchange.prepareEditor({
                  heartbeatType: 'answer',
                  autoActivateHeartbeat: false,
                  convertImagesToLinks: false,
                  noModals: true,
                  showLowRepImageUploadWarning: true,
                  reputationToPostImages: null,
                  bindNavPrevention: true,
                  postfix: "",
                  imageUploader: {
                  brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                  contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                  allowUrls: true
                  },
                  onDemand: true,
                  discardSelector: ".discard-answer"
                  ,immediatelyShowMarkdownHelp:true
                  });


                  }
                  });














                  draft saved

                  draft discarded


















                  StackExchange.ready(
                  function () {
                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f185102%2fhostile-divisor-numbers%23new-answer', 'question_page');
                  }
                  );

                  Post as a guest















                  Required, but never shown

























                  19 Answers
                  19






                  active

                  oldest

                  votes








                  19 Answers
                  19






                  active

                  oldest

                  votes









                  active

                  oldest

                  votes






                  active

                  oldest

                  votes









                  9












                  $begingroup$


                  05AB1E, 12 10 bytes



                  µNNÑ€ÙSDÙQ


                  -2 bytes thanks to @Emigna.



                  1-indexed



                  Try it online or verify most test cases (last two test cases are omitted, since they time out).



                  Explanation:





                  µ           # Loop while the counter_variable is not equal to the (implicit) input yet:
                  N # Push the 0-based index of the loop to the stack
                  NÑ # Get the divisors of the 0-based index as well
                  # i.e. N=9566 → [1,2,4783,9566]
                  # i.e. N=9567 → [1,3,9,1063,3189,9567]
                  €Ù # Uniquify the digits of each divisor
                  # → ["1","2","4783","956"]
                  # → ["1","3","9","1063","3189","9567"]
                  S # Convert it to a flattened list of digits
                  # → ["1","2","4","7","8","3","9","5","6"]
                  # → ["1","3","9","1","0","6","3","3","1","8","9","9","5","6","7"]
                  D # Duplicate this list
                  Ù # Unique the digits
                  # → ["1","2","4","7","8","3","9","5","6"]
                  # → ["1","3","9","0","6","8","5","7"]
                  Q # And check if it is still equal to the duplicated list
                  # → 1 (truthy)
                  # → 0 (falsey)
                  # And if it's truthy: implicitly increase the counter_variable by 1
                  # (After the loop: implicitly output the top of the stack,
                  # which is the pushed index)





                  share|improve this answer











                  $endgroup$









                  • 2




                    $begingroup$
                    You beat me to it this time. I had µNNÑ€ÙSDÙQ for 10.
                    $endgroup$
                    – Emigna
                    May 3 at 14:05






                  • 2




                    $begingroup$
                    @Emigna Ah, I was just working on an alternative with µ, so you save me the trouble. ;)
                    $endgroup$
                    – Kevin Cruijssen
                    May 3 at 14:06










                  • $begingroup$
                    this is poetically eloquent
                    $endgroup$
                    – don bright
                    May 8 at 23:45
















                  9












                  $begingroup$


                  05AB1E, 12 10 bytes



                  µNNÑ€ÙSDÙQ


                  -2 bytes thanks to @Emigna.



                  1-indexed



                  Try it online or verify most test cases (last two test cases are omitted, since they time out).



                  Explanation:





                  µ           # Loop while the counter_variable is not equal to the (implicit) input yet:
                  N # Push the 0-based index of the loop to the stack
                  NÑ # Get the divisors of the 0-based index as well
                  # i.e. N=9566 → [1,2,4783,9566]
                  # i.e. N=9567 → [1,3,9,1063,3189,9567]
                  €Ù # Uniquify the digits of each divisor
                  # → ["1","2","4783","956"]
                  # → ["1","3","9","1063","3189","9567"]
                  S # Convert it to a flattened list of digits
                  # → ["1","2","4","7","8","3","9","5","6"]
                  # → ["1","3","9","1","0","6","3","3","1","8","9","9","5","6","7"]
                  D # Duplicate this list
                  Ù # Unique the digits
                  # → ["1","2","4","7","8","3","9","5","6"]
                  # → ["1","3","9","0","6","8","5","7"]
                  Q # And check if it is still equal to the duplicated list
                  # → 1 (truthy)
                  # → 0 (falsey)
                  # And if it's truthy: implicitly increase the counter_variable by 1
                  # (After the loop: implicitly output the top of the stack,
                  # which is the pushed index)





                  share|improve this answer











                  $endgroup$









                  • 2




                    $begingroup$
                    You beat me to it this time. I had µNNÑ€ÙSDÙQ for 10.
                    $endgroup$
                    – Emigna
                    May 3 at 14:05






                  • 2




                    $begingroup$
                    @Emigna Ah, I was just working on an alternative with µ, so you save me the trouble. ;)
                    $endgroup$
                    – Kevin Cruijssen
                    May 3 at 14:06










                  • $begingroup$
                    this is poetically eloquent
                    $endgroup$
                    – don bright
                    May 8 at 23:45














                  9












                  9








                  9





                  $begingroup$


                  05AB1E, 12 10 bytes



                  µNNÑ€ÙSDÙQ


                  -2 bytes thanks to @Emigna.



                  1-indexed



                  Try it online or verify most test cases (last two test cases are omitted, since they time out).



                  Explanation:





                  µ           # Loop while the counter_variable is not equal to the (implicit) input yet:
                  N # Push the 0-based index of the loop to the stack
                  NÑ # Get the divisors of the 0-based index as well
                  # i.e. N=9566 → [1,2,4783,9566]
                  # i.e. N=9567 → [1,3,9,1063,3189,9567]
                  €Ù # Uniquify the digits of each divisor
                  # → ["1","2","4783","956"]
                  # → ["1","3","9","1063","3189","9567"]
                  S # Convert it to a flattened list of digits
                  # → ["1","2","4","7","8","3","9","5","6"]
                  # → ["1","3","9","1","0","6","3","3","1","8","9","9","5","6","7"]
                  D # Duplicate this list
                  Ù # Unique the digits
                  # → ["1","2","4","7","8","3","9","5","6"]
                  # → ["1","3","9","0","6","8","5","7"]
                  Q # And check if it is still equal to the duplicated list
                  # → 1 (truthy)
                  # → 0 (falsey)
                  # And if it's truthy: implicitly increase the counter_variable by 1
                  # (After the loop: implicitly output the top of the stack,
                  # which is the pushed index)





                  share|improve this answer











                  $endgroup$




                  05AB1E, 12 10 bytes



                  µNNÑ€ÙSDÙQ


                  -2 bytes thanks to @Emigna.



                  1-indexed



                  Try it online or verify most test cases (last two test cases are omitted, since they time out).



                  Explanation:





                  µ           # Loop while the counter_variable is not equal to the (implicit) input yet:
                  N # Push the 0-based index of the loop to the stack
                  NÑ # Get the divisors of the 0-based index as well
                  # i.e. N=9566 → [1,2,4783,9566]
                  # i.e. N=9567 → [1,3,9,1063,3189,9567]
                  €Ù # Uniquify the digits of each divisor
                  # → ["1","2","4783","956"]
                  # → ["1","3","9","1063","3189","9567"]
                  S # Convert it to a flattened list of digits
                  # → ["1","2","4","7","8","3","9","5","6"]
                  # → ["1","3","9","1","0","6","3","3","1","8","9","9","5","6","7"]
                  D # Duplicate this list
                  Ù # Unique the digits
                  # → ["1","2","4","7","8","3","9","5","6"]
                  # → ["1","3","9","0","6","8","5","7"]
                  Q # And check if it is still equal to the duplicated list
                  # → 1 (truthy)
                  # → 0 (falsey)
                  # And if it's truthy: implicitly increase the counter_variable by 1
                  # (After the loop: implicitly output the top of the stack,
                  # which is the pushed index)






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited May 3 at 14:31

























                  answered May 3 at 14:01









                  Kevin CruijssenKevin Cruijssen

                  45.1k576227




                  45.1k576227








                  • 2




                    $begingroup$
                    You beat me to it this time. I had µNNÑ€ÙSDÙQ for 10.
                    $endgroup$
                    – Emigna
                    May 3 at 14:05






                  • 2




                    $begingroup$
                    @Emigna Ah, I was just working on an alternative with µ, so you save me the trouble. ;)
                    $endgroup$
                    – Kevin Cruijssen
                    May 3 at 14:06










                  • $begingroup$
                    this is poetically eloquent
                    $endgroup$
                    – don bright
                    May 8 at 23:45














                  • 2




                    $begingroup$
                    You beat me to it this time. I had µNNÑ€ÙSDÙQ for 10.
                    $endgroup$
                    – Emigna
                    May 3 at 14:05






                  • 2




                    $begingroup$
                    @Emigna Ah, I was just working on an alternative with µ, so you save me the trouble. ;)
                    $endgroup$
                    – Kevin Cruijssen
                    May 3 at 14:06










                  • $begingroup$
                    this is poetically eloquent
                    $endgroup$
                    – don bright
                    May 8 at 23:45








                  2




                  2




                  $begingroup$
                  You beat me to it this time. I had µNNÑ€ÙSDÙQ for 10.
                  $endgroup$
                  – Emigna
                  May 3 at 14:05




                  $begingroup$
                  You beat me to it this time. I had µNNÑ€ÙSDÙQ for 10.
                  $endgroup$
                  – Emigna
                  May 3 at 14:05




                  2




                  2




                  $begingroup$
                  @Emigna Ah, I was just working on an alternative with µ, so you save me the trouble. ;)
                  $endgroup$
                  – Kevin Cruijssen
                  May 3 at 14:06




                  $begingroup$
                  @Emigna Ah, I was just working on an alternative with µ, so you save me the trouble. ;)
                  $endgroup$
                  – Kevin Cruijssen
                  May 3 at 14:06












                  $begingroup$
                  this is poetically eloquent
                  $endgroup$
                  – don bright
                  May 8 at 23:45




                  $begingroup$
                  this is poetically eloquent
                  $endgroup$
                  – don bright
                  May 8 at 23:45











                  7












                  $begingroup$


                  Python 2, 104 bytes





                  n=input()
                  x=1
                  while n:
                  x=i=x+1;d={0};c=1
                  while i:m=set(`i`*(x%i<1));c*=d-m==d;d|=m;i-=1
                  n-=c
                  print x


                  Try it online!



                  0-indexed.






                  share|improve this answer









                  $endgroup$


















                    7












                    $begingroup$


                    Python 2, 104 bytes





                    n=input()
                    x=1
                    while n:
                    x=i=x+1;d={0};c=1
                    while i:m=set(`i`*(x%i<1));c*=d-m==d;d|=m;i-=1
                    n-=c
                    print x


                    Try it online!



                    0-indexed.






                    share|improve this answer









                    $endgroup$
















                      7












                      7








                      7





                      $begingroup$


                      Python 2, 104 bytes





                      n=input()
                      x=1
                      while n:
                      x=i=x+1;d={0};c=1
                      while i:m=set(`i`*(x%i<1));c*=d-m==d;d|=m;i-=1
                      n-=c
                      print x


                      Try it online!



                      0-indexed.






                      share|improve this answer









                      $endgroup$




                      Python 2, 104 bytes





                      n=input()
                      x=1
                      while n:
                      x=i=x+1;d={0};c=1
                      while i:m=set(`i`*(x%i<1));c*=d-m==d;d|=m;i-=1
                      n-=c
                      print x


                      Try it online!



                      0-indexed.







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered May 3 at 17:48









                      Erik the OutgolferErik the Outgolfer

                      33.5k430106




                      33.5k430106























                          6












                          $begingroup$


                          Jelly, 10 bytes



                          ÆDQ€FQƑµ#Ṫ


                          Try it online!



                          -1 byte thanks to ErikTheOutgolfer



                          Takes input from STDIN, which is unusual for Jelly but normal where nfind is used.



                          ÆDQ€FQƑµ#Ṫ  Main link
                          Ṫ Get the last element of
                          # The first <input> elements that pass the filter:
                          ÆD Get the divisors
                          Q€ Uniquify each (implicitly converts a number to its digits)
                          F Flatten the list
                          QƑ Does that list equal itself when deduplicated?


                          2-indexed






                          share|improve this answer











                          $endgroup$













                          • $begingroup$
                            is this 2-indexed? It's ok with me but please state it for others
                            $endgroup$
                            – J42161217
                            May 3 at 14:20










                          • $begingroup$
                            It's whatever your test cases were, so 1
                            $endgroup$
                            – HyperNeutrino
                            May 3 at 14:21






                          • 3




                            $begingroup$
                            No it isn't. 101 returns 839. and 102 -> 853. It works fine but it is 2-indexed
                            $endgroup$
                            – J42161217
                            May 3 at 14:23






                          • 1




                            $begingroup$
                            @J42161217 wait what? i guess when i moved the nfind it changed the indexing lol
                            $endgroup$
                            – HyperNeutrino
                            May 3 at 14:33






                          • 1




                            $begingroup$
                            ⁼Q$ is the same as .
                            $endgroup$
                            – Erik the Outgolfer
                            May 3 at 14:35
















                          6












                          $begingroup$


                          Jelly, 10 bytes



                          ÆDQ€FQƑµ#Ṫ


                          Try it online!



                          -1 byte thanks to ErikTheOutgolfer



                          Takes input from STDIN, which is unusual for Jelly but normal where nfind is used.



                          ÆDQ€FQƑµ#Ṫ  Main link
                          Ṫ Get the last element of
                          # The first <input> elements that pass the filter:
                          ÆD Get the divisors
                          Q€ Uniquify each (implicitly converts a number to its digits)
                          F Flatten the list
                          QƑ Does that list equal itself when deduplicated?


                          2-indexed






                          share|improve this answer











                          $endgroup$













                          • $begingroup$
                            is this 2-indexed? It's ok with me but please state it for others
                            $endgroup$
                            – J42161217
                            May 3 at 14:20










                          • $begingroup$
                            It's whatever your test cases were, so 1
                            $endgroup$
                            – HyperNeutrino
                            May 3 at 14:21






                          • 3




                            $begingroup$
                            No it isn't. 101 returns 839. and 102 -> 853. It works fine but it is 2-indexed
                            $endgroup$
                            – J42161217
                            May 3 at 14:23






                          • 1




                            $begingroup$
                            @J42161217 wait what? i guess when i moved the nfind it changed the indexing lol
                            $endgroup$
                            – HyperNeutrino
                            May 3 at 14:33






                          • 1




                            $begingroup$
                            ⁼Q$ is the same as .
                            $endgroup$
                            – Erik the Outgolfer
                            May 3 at 14:35














                          6












                          6








                          6





                          $begingroup$


                          Jelly, 10 bytes



                          ÆDQ€FQƑµ#Ṫ


                          Try it online!



                          -1 byte thanks to ErikTheOutgolfer



                          Takes input from STDIN, which is unusual for Jelly but normal where nfind is used.



                          ÆDQ€FQƑµ#Ṫ  Main link
                          Ṫ Get the last element of
                          # The first <input> elements that pass the filter:
                          ÆD Get the divisors
                          Q€ Uniquify each (implicitly converts a number to its digits)
                          F Flatten the list
                          QƑ Does that list equal itself when deduplicated?


                          2-indexed






                          share|improve this answer











                          $endgroup$




                          Jelly, 10 bytes



                          ÆDQ€FQƑµ#Ṫ


                          Try it online!



                          -1 byte thanks to ErikTheOutgolfer



                          Takes input from STDIN, which is unusual for Jelly but normal where nfind is used.



                          ÆDQ€FQƑµ#Ṫ  Main link
                          Ṫ Get the last element of
                          # The first <input> elements that pass the filter:
                          ÆD Get the divisors
                          Q€ Uniquify each (implicitly converts a number to its digits)
                          F Flatten the list
                          QƑ Does that list equal itself when deduplicated?


                          2-indexed







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited May 3 at 21:34

























                          answered May 3 at 14:14









                          HyperNeutrinoHyperNeutrino

                          19.2k438148




                          19.2k438148












                          • $begingroup$
                            is this 2-indexed? It's ok with me but please state it for others
                            $endgroup$
                            – J42161217
                            May 3 at 14:20










                          • $begingroup$
                            It's whatever your test cases were, so 1
                            $endgroup$
                            – HyperNeutrino
                            May 3 at 14:21






                          • 3




                            $begingroup$
                            No it isn't. 101 returns 839. and 102 -> 853. It works fine but it is 2-indexed
                            $endgroup$
                            – J42161217
                            May 3 at 14:23






                          • 1




                            $begingroup$
                            @J42161217 wait what? i guess when i moved the nfind it changed the indexing lol
                            $endgroup$
                            – HyperNeutrino
                            May 3 at 14:33






                          • 1




                            $begingroup$
                            ⁼Q$ is the same as .
                            $endgroup$
                            – Erik the Outgolfer
                            May 3 at 14:35


















                          • $begingroup$
                            is this 2-indexed? It's ok with me but please state it for others
                            $endgroup$
                            – J42161217
                            May 3 at 14:20










                          • $begingroup$
                            It's whatever your test cases were, so 1
                            $endgroup$
                            – HyperNeutrino
                            May 3 at 14:21






                          • 3




                            $begingroup$
                            No it isn't. 101 returns 839. and 102 -> 853. It works fine but it is 2-indexed
                            $endgroup$
                            – J42161217
                            May 3 at 14:23






                          • 1




                            $begingroup$
                            @J42161217 wait what? i guess when i moved the nfind it changed the indexing lol
                            $endgroup$
                            – HyperNeutrino
                            May 3 at 14:33






                          • 1




                            $begingroup$
                            ⁼Q$ is the same as .
                            $endgroup$
                            – Erik the Outgolfer
                            May 3 at 14:35
















                          $begingroup$
                          is this 2-indexed? It's ok with me but please state it for others
                          $endgroup$
                          – J42161217
                          May 3 at 14:20




                          $begingroup$
                          is this 2-indexed? It's ok with me but please state it for others
                          $endgroup$
                          – J42161217
                          May 3 at 14:20












                          $begingroup$
                          It's whatever your test cases were, so 1
                          $endgroup$
                          – HyperNeutrino
                          May 3 at 14:21




                          $begingroup$
                          It's whatever your test cases were, so 1
                          $endgroup$
                          – HyperNeutrino
                          May 3 at 14:21




                          3




                          3




                          $begingroup$
                          No it isn't. 101 returns 839. and 102 -> 853. It works fine but it is 2-indexed
                          $endgroup$
                          – J42161217
                          May 3 at 14:23




                          $begingroup$
                          No it isn't. 101 returns 839. and 102 -> 853. It works fine but it is 2-indexed
                          $endgroup$
                          – J42161217
                          May 3 at 14:23




                          1




                          1




                          $begingroup$
                          @J42161217 wait what? i guess when i moved the nfind it changed the indexing lol
                          $endgroup$
                          – HyperNeutrino
                          May 3 at 14:33




                          $begingroup$
                          @J42161217 wait what? i guess when i moved the nfind it changed the indexing lol
                          $endgroup$
                          – HyperNeutrino
                          May 3 at 14:33




                          1




                          1




                          $begingroup$
                          ⁼Q$ is the same as .
                          $endgroup$
                          – Erik the Outgolfer
                          May 3 at 14:35




                          $begingroup$
                          ⁼Q$ is the same as .
                          $endgroup$
                          – Erik the Outgolfer
                          May 3 at 14:35











                          5












                          $begingroup$

                          JavaScript (ES6), 78 bytes



                          1-indexed.





                          n=>eval("for(k=0;n;n-=!d)for(s=d=++k+'';k%--d||d*!s.match(`[${s+=d,d}]`););k")


                          Try it online!



                          Faster version, 79 bytes





                          n=>{for(k=0;n;n-=!d)for(s=d=++k+'';k%--d||d*!s.match(`[${s+=d,d}]`););return k}


                          Try it online!



                          How?



                          Given an integer $k>0$, we build the string $s$ as the concatenation of all divisors of $k$.



                          Because $k$ is always a divisor of itself, $s$ is initialized to $k$ (coerced to a string) and the first divisor that we try is $d=k-1$.



                          For each divisor $d$ of $k$, we test whether any digit of $d$ can be found in $s$ by turning $d$ into a character set in a regular expression.



                          Examples





                          • $s=text{"}956647832text{"}$, $d=1$"956647832".match(/[1]/) is falsy


                          • $s=text{"}9567text{"}$, $d=3189$"9567".match(/[3189]/) is truthy


                          Commented



                          This is the version without eval(), for readability



                          n => {                   // n = input
                          for( // for() loop:
                          k = 0; // start with k = 0
                          n; // go on until n = 0
                          n -= !d // decrement n if the last iteration resulted in d = 0
                          ) //
                          for( // for() loop:
                          s = // start by incrementing k and
                          d = ++k + ''; // setting both s and d to k, coerced to a string
                          k % --d || // decrement d; always go on if d is not a divisor of k
                          d * // stop if d = 0
                          !s.match( // stop if any digit of d can be found in s
                          `[${s += d, d}]` // append d to s
                          ); //
                          ); // implicit end of inner for() loop
                          // implicit end of outer for() loop
                          return k // return k
                          } //





                          share|improve this answer











                          $endgroup$


















                            5












                            $begingroup$

                            JavaScript (ES6), 78 bytes



                            1-indexed.





                            n=>eval("for(k=0;n;n-=!d)for(s=d=++k+'';k%--d||d*!s.match(`[${s+=d,d}]`););k")


                            Try it online!



                            Faster version, 79 bytes





                            n=>{for(k=0;n;n-=!d)for(s=d=++k+'';k%--d||d*!s.match(`[${s+=d,d}]`););return k}


                            Try it online!



                            How?



                            Given an integer $k>0$, we build the string $s$ as the concatenation of all divisors of $k$.



                            Because $k$ is always a divisor of itself, $s$ is initialized to $k$ (coerced to a string) and the first divisor that we try is $d=k-1$.



                            For each divisor $d$ of $k$, we test whether any digit of $d$ can be found in $s$ by turning $d$ into a character set in a regular expression.



                            Examples





                            • $s=text{"}956647832text{"}$, $d=1$"956647832".match(/[1]/) is falsy


                            • $s=text{"}9567text{"}$, $d=3189$"9567".match(/[3189]/) is truthy


                            Commented



                            This is the version without eval(), for readability



                            n => {                   // n = input
                            for( // for() loop:
                            k = 0; // start with k = 0
                            n; // go on until n = 0
                            n -= !d // decrement n if the last iteration resulted in d = 0
                            ) //
                            for( // for() loop:
                            s = // start by incrementing k and
                            d = ++k + ''; // setting both s and d to k, coerced to a string
                            k % --d || // decrement d; always go on if d is not a divisor of k
                            d * // stop if d = 0
                            !s.match( // stop if any digit of d can be found in s
                            `[${s += d, d}]` // append d to s
                            ); //
                            ); // implicit end of inner for() loop
                            // implicit end of outer for() loop
                            return k // return k
                            } //





                            share|improve this answer











                            $endgroup$
















                              5












                              5








                              5





                              $begingroup$

                              JavaScript (ES6), 78 bytes



                              1-indexed.





                              n=>eval("for(k=0;n;n-=!d)for(s=d=++k+'';k%--d||d*!s.match(`[${s+=d,d}]`););k")


                              Try it online!



                              Faster version, 79 bytes





                              n=>{for(k=0;n;n-=!d)for(s=d=++k+'';k%--d||d*!s.match(`[${s+=d,d}]`););return k}


                              Try it online!



                              How?



                              Given an integer $k>0$, we build the string $s$ as the concatenation of all divisors of $k$.



                              Because $k$ is always a divisor of itself, $s$ is initialized to $k$ (coerced to a string) and the first divisor that we try is $d=k-1$.



                              For each divisor $d$ of $k$, we test whether any digit of $d$ can be found in $s$ by turning $d$ into a character set in a regular expression.



                              Examples





                              • $s=text{"}956647832text{"}$, $d=1$"956647832".match(/[1]/) is falsy


                              • $s=text{"}9567text{"}$, $d=3189$"9567".match(/[3189]/) is truthy


                              Commented



                              This is the version without eval(), for readability



                              n => {                   // n = input
                              for( // for() loop:
                              k = 0; // start with k = 0
                              n; // go on until n = 0
                              n -= !d // decrement n if the last iteration resulted in d = 0
                              ) //
                              for( // for() loop:
                              s = // start by incrementing k and
                              d = ++k + ''; // setting both s and d to k, coerced to a string
                              k % --d || // decrement d; always go on if d is not a divisor of k
                              d * // stop if d = 0
                              !s.match( // stop if any digit of d can be found in s
                              `[${s += d, d}]` // append d to s
                              ); //
                              ); // implicit end of inner for() loop
                              // implicit end of outer for() loop
                              return k // return k
                              } //





                              share|improve this answer











                              $endgroup$



                              JavaScript (ES6), 78 bytes



                              1-indexed.





                              n=>eval("for(k=0;n;n-=!d)for(s=d=++k+'';k%--d||d*!s.match(`[${s+=d,d}]`););k")


                              Try it online!



                              Faster version, 79 bytes





                              n=>{for(k=0;n;n-=!d)for(s=d=++k+'';k%--d||d*!s.match(`[${s+=d,d}]`););return k}


                              Try it online!



                              How?



                              Given an integer $k>0$, we build the string $s$ as the concatenation of all divisors of $k$.



                              Because $k$ is always a divisor of itself, $s$ is initialized to $k$ (coerced to a string) and the first divisor that we try is $d=k-1$.



                              For each divisor $d$ of $k$, we test whether any digit of $d$ can be found in $s$ by turning $d$ into a character set in a regular expression.



                              Examples





                              • $s=text{"}956647832text{"}$, $d=1$"956647832".match(/[1]/) is falsy


                              • $s=text{"}9567text{"}$, $d=3189$"9567".match(/[3189]/) is truthy


                              Commented



                              This is the version without eval(), for readability



                              n => {                   // n = input
                              for( // for() loop:
                              k = 0; // start with k = 0
                              n; // go on until n = 0
                              n -= !d // decrement n if the last iteration resulted in d = 0
                              ) //
                              for( // for() loop:
                              s = // start by incrementing k and
                              d = ++k + ''; // setting both s and d to k, coerced to a string
                              k % --d || // decrement d; always go on if d is not a divisor of k
                              d * // stop if d = 0
                              !s.match( // stop if any digit of d can be found in s
                              `[${s += d, d}]` // append d to s
                              ); //
                              ); // implicit end of inner for() loop
                              // implicit end of outer for() loop
                              return k // return k
                              } //






                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited May 3 at 15:51

























                              answered May 3 at 14:40









                              ArnauldArnauld

                              85.1k7100349




                              85.1k7100349























                                  4












                                  $begingroup$


                                  Perl 6, 53 bytes



                                  {(grep {/(.).*$0/R!~~[~] grep $_%%*,1..$_},^∞)[$_]}


                                  Try it online!



                                  1-indexed.



                                  /(.).*$0/ matches any number with a repeated digit.



                                  grep $_ %% *, 1 .. $_ returns a list of all divisors of the number $_ currently being checked for membership in the list.



                                  [~] concatenates all of those digits together, and then R!~~ matches the string on the right against the pattern on the left. (~~ is the usual match operator, !~~ is the negation of that operator, and R is a metaoperator that swaps the arguments of !~~.)






                                  share|improve this answer









                                  $endgroup$













                                  • $begingroup$
                                    50 bytes
                                    $endgroup$
                                    – Jo King
                                    May 8 at 21:43
















                                  4












                                  $begingroup$


                                  Perl 6, 53 bytes



                                  {(grep {/(.).*$0/R!~~[~] grep $_%%*,1..$_},^∞)[$_]}


                                  Try it online!



                                  1-indexed.



                                  /(.).*$0/ matches any number with a repeated digit.



                                  grep $_ %% *, 1 .. $_ returns a list of all divisors of the number $_ currently being checked for membership in the list.



                                  [~] concatenates all of those digits together, and then R!~~ matches the string on the right against the pattern on the left. (~~ is the usual match operator, !~~ is the negation of that operator, and R is a metaoperator that swaps the arguments of !~~.)






                                  share|improve this answer









                                  $endgroup$













                                  • $begingroup$
                                    50 bytes
                                    $endgroup$
                                    – Jo King
                                    May 8 at 21:43














                                  4












                                  4








                                  4





                                  $begingroup$


                                  Perl 6, 53 bytes



                                  {(grep {/(.).*$0/R!~~[~] grep $_%%*,1..$_},^∞)[$_]}


                                  Try it online!



                                  1-indexed.



                                  /(.).*$0/ matches any number with a repeated digit.



                                  grep $_ %% *, 1 .. $_ returns a list of all divisors of the number $_ currently being checked for membership in the list.



                                  [~] concatenates all of those digits together, and then R!~~ matches the string on the right against the pattern on the left. (~~ is the usual match operator, !~~ is the negation of that operator, and R is a metaoperator that swaps the arguments of !~~.)






                                  share|improve this answer









                                  $endgroup$




                                  Perl 6, 53 bytes



                                  {(grep {/(.).*$0/R!~~[~] grep $_%%*,1..$_},^∞)[$_]}


                                  Try it online!



                                  1-indexed.



                                  /(.).*$0/ matches any number with a repeated digit.



                                  grep $_ %% *, 1 .. $_ returns a list of all divisors of the number $_ currently being checked for membership in the list.



                                  [~] concatenates all of those digits together, and then R!~~ matches the string on the right against the pattern on the left. (~~ is the usual match operator, !~~ is the negation of that operator, and R is a metaoperator that swaps the arguments of !~~.)







                                  share|improve this answer












                                  share|improve this answer



                                  share|improve this answer










                                  answered May 3 at 21:43









                                  SeanSean

                                  3,75639




                                  3,75639












                                  • $begingroup$
                                    50 bytes
                                    $endgroup$
                                    – Jo King
                                    May 8 at 21:43


















                                  • $begingroup$
                                    50 bytes
                                    $endgroup$
                                    – Jo King
                                    May 8 at 21:43
















                                  $begingroup$
                                  50 bytes
                                  $endgroup$
                                  – Jo King
                                  May 8 at 21:43




                                  $begingroup$
                                  50 bytes
                                  $endgroup$
                                  – Jo King
                                  May 8 at 21:43











                                  4












                                  $begingroup$


                                  Python 2 (PyPy), 117 114 bytes



                                  Uses 1-indexing





                                  k=input();n=0;r=range
                                  while k:n+=1;k-=1-any(set(`a`)&set(`b`)for a in r(1,n+1)for b in r(1,a)if n%a<1>n%b)
                                  print n


                                  Try it online!






                                  share|improve this answer











                                  $endgroup$


















                                    4












                                    $begingroup$


                                    Python 2 (PyPy), 117 114 bytes



                                    Uses 1-indexing





                                    k=input();n=0;r=range
                                    while k:n+=1;k-=1-any(set(`a`)&set(`b`)for a in r(1,n+1)for b in r(1,a)if n%a<1>n%b)
                                    print n


                                    Try it online!






                                    share|improve this answer











                                    $endgroup$
















                                      4












                                      4








                                      4





                                      $begingroup$


                                      Python 2 (PyPy), 117 114 bytes



                                      Uses 1-indexing





                                      k=input();n=0;r=range
                                      while k:n+=1;k-=1-any(set(`a`)&set(`b`)for a in r(1,n+1)for b in r(1,a)if n%a<1>n%b)
                                      print n


                                      Try it online!






                                      share|improve this answer











                                      $endgroup$




                                      Python 2 (PyPy), 117 114 bytes



                                      Uses 1-indexing





                                      k=input();n=0;r=range
                                      while k:n+=1;k-=1-any(set(`a`)&set(`b`)for a in r(1,n+1)for b in r(1,a)if n%a<1>n%b)
                                      print n


                                      Try it online!







                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited May 4 at 8:19

























                                      answered May 3 at 14:09









                                      ovsovs

                                      19.7k21161




                                      19.7k21161























                                          3












                                          $begingroup$

                                          Wolfram Language 103 bytes



                                          Uses 1-indexing.
                                          I'm surprised it required so much code.



                                          (k=1;u=Union;n=2;l=Length;While[k<#,If[l[a=Join@@u/@IntegerDigits@Divisors@#]==l@u@a&@n,k++];n++];n-1)&





                                          share|improve this answer









                                          $endgroup$













                                          • $begingroup$
                                            Can you please add a TIO link so that everybody can check your answer?
                                            $endgroup$
                                            – J42161217
                                            May 3 at 16:40










                                          • $begingroup$
                                            95 bytes: (n=t=1;While[t<=#,If[!Or@@IntersectingQ@@@Subsets[IntegerDigits@Divisors@n,{2}],t++];n++];n-1)& I am not planning to post an answer so I will leave this here
                                            $endgroup$
                                            – J42161217
                                            May 3 at 16:45










                                          • $begingroup$
                                            @J42161217, I've been trying to get the code to work in TIO without success. There must be some trick I'm missing.
                                            $endgroup$
                                            – DavidC
                                            May 3 at 20:55










                                          • $begingroup$
                                            @J42161217, Your code seems to work but takes 3 times the runtime. You can submit it as your own. (Maybe I'll learn how to implement TIO from your example.)
                                            $endgroup$
                                            – DavidC
                                            May 3 at 20:57










                                          • $begingroup$
                                            Very fast indeed! here is your link Try it online!
                                            $endgroup$
                                            – J42161217
                                            May 3 at 21:20
















                                          3












                                          $begingroup$

                                          Wolfram Language 103 bytes



                                          Uses 1-indexing.
                                          I'm surprised it required so much code.



                                          (k=1;u=Union;n=2;l=Length;While[k<#,If[l[a=Join@@u/@IntegerDigits@Divisors@#]==l@u@a&@n,k++];n++];n-1)&





                                          share|improve this answer









                                          $endgroup$













                                          • $begingroup$
                                            Can you please add a TIO link so that everybody can check your answer?
                                            $endgroup$
                                            – J42161217
                                            May 3 at 16:40










                                          • $begingroup$
                                            95 bytes: (n=t=1;While[t<=#,If[!Or@@IntersectingQ@@@Subsets[IntegerDigits@Divisors@n,{2}],t++];n++];n-1)& I am not planning to post an answer so I will leave this here
                                            $endgroup$
                                            – J42161217
                                            May 3 at 16:45










                                          • $begingroup$
                                            @J42161217, I've been trying to get the code to work in TIO without success. There must be some trick I'm missing.
                                            $endgroup$
                                            – DavidC
                                            May 3 at 20:55










                                          • $begingroup$
                                            @J42161217, Your code seems to work but takes 3 times the runtime. You can submit it as your own. (Maybe I'll learn how to implement TIO from your example.)
                                            $endgroup$
                                            – DavidC
                                            May 3 at 20:57










                                          • $begingroup$
                                            Very fast indeed! here is your link Try it online!
                                            $endgroup$
                                            – J42161217
                                            May 3 at 21:20














                                          3












                                          3








                                          3





                                          $begingroup$

                                          Wolfram Language 103 bytes



                                          Uses 1-indexing.
                                          I'm surprised it required so much code.



                                          (k=1;u=Union;n=2;l=Length;While[k<#,If[l[a=Join@@u/@IntegerDigits@Divisors@#]==l@u@a&@n,k++];n++];n-1)&





                                          share|improve this answer









                                          $endgroup$



                                          Wolfram Language 103 bytes



                                          Uses 1-indexing.
                                          I'm surprised it required so much code.



                                          (k=1;u=Union;n=2;l=Length;While[k<#,If[l[a=Join@@u/@IntegerDigits@Divisors@#]==l@u@a&@n,k++];n++];n-1)&






                                          share|improve this answer












                                          share|improve this answer



                                          share|improve this answer










                                          answered May 3 at 14:44









                                          DavidCDavidC

                                          24.2k246102




                                          24.2k246102












                                          • $begingroup$
                                            Can you please add a TIO link so that everybody can check your answer?
                                            $endgroup$
                                            – J42161217
                                            May 3 at 16:40










                                          • $begingroup$
                                            95 bytes: (n=t=1;While[t<=#,If[!Or@@IntersectingQ@@@Subsets[IntegerDigits@Divisors@n,{2}],t++];n++];n-1)& I am not planning to post an answer so I will leave this here
                                            $endgroup$
                                            – J42161217
                                            May 3 at 16:45










                                          • $begingroup$
                                            @J42161217, I've been trying to get the code to work in TIO without success. There must be some trick I'm missing.
                                            $endgroup$
                                            – DavidC
                                            May 3 at 20:55










                                          • $begingroup$
                                            @J42161217, Your code seems to work but takes 3 times the runtime. You can submit it as your own. (Maybe I'll learn how to implement TIO from your example.)
                                            $endgroup$
                                            – DavidC
                                            May 3 at 20:57










                                          • $begingroup$
                                            Very fast indeed! here is your link Try it online!
                                            $endgroup$
                                            – J42161217
                                            May 3 at 21:20


















                                          • $begingroup$
                                            Can you please add a TIO link so that everybody can check your answer?
                                            $endgroup$
                                            – J42161217
                                            May 3 at 16:40










                                          • $begingroup$
                                            95 bytes: (n=t=1;While[t<=#,If[!Or@@IntersectingQ@@@Subsets[IntegerDigits@Divisors@n,{2}],t++];n++];n-1)& I am not planning to post an answer so I will leave this here
                                            $endgroup$
                                            – J42161217
                                            May 3 at 16:45










                                          • $begingroup$
                                            @J42161217, I've been trying to get the code to work in TIO without success. There must be some trick I'm missing.
                                            $endgroup$
                                            – DavidC
                                            May 3 at 20:55










                                          • $begingroup$
                                            @J42161217, Your code seems to work but takes 3 times the runtime. You can submit it as your own. (Maybe I'll learn how to implement TIO from your example.)
                                            $endgroup$
                                            – DavidC
                                            May 3 at 20:57










                                          • $begingroup$
                                            Very fast indeed! here is your link Try it online!
                                            $endgroup$
                                            – J42161217
                                            May 3 at 21:20
















                                          $begingroup$
                                          Can you please add a TIO link so that everybody can check your answer?
                                          $endgroup$
                                          – J42161217
                                          May 3 at 16:40




                                          $begingroup$
                                          Can you please add a TIO link so that everybody can check your answer?
                                          $endgroup$
                                          – J42161217
                                          May 3 at 16:40












                                          $begingroup$
                                          95 bytes: (n=t=1;While[t<=#,If[!Or@@IntersectingQ@@@Subsets[IntegerDigits@Divisors@n,{2}],t++];n++];n-1)& I am not planning to post an answer so I will leave this here
                                          $endgroup$
                                          – J42161217
                                          May 3 at 16:45




                                          $begingroup$
                                          95 bytes: (n=t=1;While[t<=#,If[!Or@@IntersectingQ@@@Subsets[IntegerDigits@Divisors@n,{2}],t++];n++];n-1)& I am not planning to post an answer so I will leave this here
                                          $endgroup$
                                          – J42161217
                                          May 3 at 16:45












                                          $begingroup$
                                          @J42161217, I've been trying to get the code to work in TIO without success. There must be some trick I'm missing.
                                          $endgroup$
                                          – DavidC
                                          May 3 at 20:55




                                          $begingroup$
                                          @J42161217, I've been trying to get the code to work in TIO without success. There must be some trick I'm missing.
                                          $endgroup$
                                          – DavidC
                                          May 3 at 20:55












                                          $begingroup$
                                          @J42161217, Your code seems to work but takes 3 times the runtime. You can submit it as your own. (Maybe I'll learn how to implement TIO from your example.)
                                          $endgroup$
                                          – DavidC
                                          May 3 at 20:57




                                          $begingroup$
                                          @J42161217, Your code seems to work but takes 3 times the runtime. You can submit it as your own. (Maybe I'll learn how to implement TIO from your example.)
                                          $endgroup$
                                          – DavidC
                                          May 3 at 20:57












                                          $begingroup$
                                          Very fast indeed! here is your link Try it online!
                                          $endgroup$
                                          – J42161217
                                          May 3 at 21:20




                                          $begingroup$
                                          Very fast indeed! here is your link Try it online!
                                          $endgroup$
                                          – J42161217
                                          May 3 at 21:20











                                          3












                                          $begingroup$


                                          PowerShell, 112 bytes





                                          for($a=$args[0];$a-gt0){$z=,0*10;1..++$n|?{!($n%$_)}|%{"$_"|% t*y|sort -u|%{$z[+"$_"]++}};$a-=!($z|?{$_-ge2})}$n


                                          Try it online!



                                          Takes 1-indexed input $args[0], stores that into $a, loops until that hits 0. Each iteration, we zero-out a ten-element array $z (used to hold our digit counts). Then we construct our list of divisors with 1..++$n|?{!($n%$_)}. For each divisor, we cast it to a string "$_", cast it toCharArray, and sort those digits with the -unique flag (because we don't care if a divisor itself has duplicate digits). We then increment the appropriate digit count in $z. Then, we decrement $a only if $z contains 0s and 1s (i.e., we've found an HDN). If we've finished our for loop, that means we found the appropriate number of HDNs, so we leave $n on the pipeline and output is implicit.






                                          share|improve this answer









                                          $endgroup$













                                          • $begingroup$
                                            you could save some bytes: $a-=!($z-ge2) instead $a-=!($z|?{$_-ge2})
                                            $endgroup$
                                            – mazzy
                                            May 4 at 6:40










                                          • $begingroup$
                                            a bit golfed
                                            $endgroup$
                                            – mazzy
                                            May 4 at 8:13
















                                          3












                                          $begingroup$


                                          PowerShell, 112 bytes





                                          for($a=$args[0];$a-gt0){$z=,0*10;1..++$n|?{!($n%$_)}|%{"$_"|% t*y|sort -u|%{$z[+"$_"]++}};$a-=!($z|?{$_-ge2})}$n


                                          Try it online!



                                          Takes 1-indexed input $args[0], stores that into $a, loops until that hits 0. Each iteration, we zero-out a ten-element array $z (used to hold our digit counts). Then we construct our list of divisors with 1..++$n|?{!($n%$_)}. For each divisor, we cast it to a string "$_", cast it toCharArray, and sort those digits with the -unique flag (because we don't care if a divisor itself has duplicate digits). We then increment the appropriate digit count in $z. Then, we decrement $a only if $z contains 0s and 1s (i.e., we've found an HDN). If we've finished our for loop, that means we found the appropriate number of HDNs, so we leave $n on the pipeline and output is implicit.






                                          share|improve this answer









                                          $endgroup$













                                          • $begingroup$
                                            you could save some bytes: $a-=!($z-ge2) instead $a-=!($z|?{$_-ge2})
                                            $endgroup$
                                            – mazzy
                                            May 4 at 6:40










                                          • $begingroup$
                                            a bit golfed
                                            $endgroup$
                                            – mazzy
                                            May 4 at 8:13














                                          3












                                          3








                                          3





                                          $begingroup$


                                          PowerShell, 112 bytes





                                          for($a=$args[0];$a-gt0){$z=,0*10;1..++$n|?{!($n%$_)}|%{"$_"|% t*y|sort -u|%{$z[+"$_"]++}};$a-=!($z|?{$_-ge2})}$n


                                          Try it online!



                                          Takes 1-indexed input $args[0], stores that into $a, loops until that hits 0. Each iteration, we zero-out a ten-element array $z (used to hold our digit counts). Then we construct our list of divisors with 1..++$n|?{!($n%$_)}. For each divisor, we cast it to a string "$_", cast it toCharArray, and sort those digits with the -unique flag (because we don't care if a divisor itself has duplicate digits). We then increment the appropriate digit count in $z. Then, we decrement $a only if $z contains 0s and 1s (i.e., we've found an HDN). If we've finished our for loop, that means we found the appropriate number of HDNs, so we leave $n on the pipeline and output is implicit.






                                          share|improve this answer









                                          $endgroup$




                                          PowerShell, 112 bytes





                                          for($a=$args[0];$a-gt0){$z=,0*10;1..++$n|?{!($n%$_)}|%{"$_"|% t*y|sort -u|%{$z[+"$_"]++}};$a-=!($z|?{$_-ge2})}$n


                                          Try it online!



                                          Takes 1-indexed input $args[0], stores that into $a, loops until that hits 0. Each iteration, we zero-out a ten-element array $z (used to hold our digit counts). Then we construct our list of divisors with 1..++$n|?{!($n%$_)}. For each divisor, we cast it to a string "$_", cast it toCharArray, and sort those digits with the -unique flag (because we don't care if a divisor itself has duplicate digits). We then increment the appropriate digit count in $z. Then, we decrement $a only if $z contains 0s and 1s (i.e., we've found an HDN). If we've finished our for loop, that means we found the appropriate number of HDNs, so we leave $n on the pipeline and output is implicit.







                                          share|improve this answer












                                          share|improve this answer



                                          share|improve this answer










                                          answered May 3 at 15:05









                                          AdmBorkBorkAdmBorkBork

                                          28.3k469245




                                          28.3k469245












                                          • $begingroup$
                                            you could save some bytes: $a-=!($z-ge2) instead $a-=!($z|?{$_-ge2})
                                            $endgroup$
                                            – mazzy
                                            May 4 at 6:40










                                          • $begingroup$
                                            a bit golfed
                                            $endgroup$
                                            – mazzy
                                            May 4 at 8:13


















                                          • $begingroup$
                                            you could save some bytes: $a-=!($z-ge2) instead $a-=!($z|?{$_-ge2})
                                            $endgroup$
                                            – mazzy
                                            May 4 at 6:40










                                          • $begingroup$
                                            a bit golfed
                                            $endgroup$
                                            – mazzy
                                            May 4 at 8:13
















                                          $begingroup$
                                          you could save some bytes: $a-=!($z-ge2) instead $a-=!($z|?{$_-ge2})
                                          $endgroup$
                                          – mazzy
                                          May 4 at 6:40




                                          $begingroup$
                                          you could save some bytes: $a-=!($z-ge2) instead $a-=!($z|?{$_-ge2})
                                          $endgroup$
                                          – mazzy
                                          May 4 at 6:40












                                          $begingroup$
                                          a bit golfed
                                          $endgroup$
                                          – mazzy
                                          May 4 at 8:13




                                          $begingroup$
                                          a bit golfed
                                          $endgroup$
                                          – mazzy
                                          May 4 at 8:13











                                          3












                                          $begingroup$


                                          Python 3, 115 bytes



                                          1-indexed





                                          f=lambda n,x=1,s="",l="",d=1:n and(d>x+1and f(n-1,x+1)or{*s}&{*l}and f(n,x+1)or f(n,x,s+l,(1-x%d)*str(d),d+1))or~-x


                                          Try it online!



                                          This uses a lot of recursion; even with increased recursion limit, it can't do f(30). I think it might be golfable further, and I tried finding something to replace the (1-x%d) with, but couldn't come up with anything (-~-x%d has the wrong precedence). Any bytes that can be shaved off are greatly appreciated.



                                          How it works





                                          # n: HDNs to go
                                          # x: Currently tested number
                                          # s: String of currently seen divisor digits
                                          # l: String of digits of last tried divisor if it was a divisor, empty string otherwise
                                          # d: Currently tested divisor

                                          f=lambda n,x=1,s="",l="",d=1:n and( # If there are still numbers to go
                                          d>x+1and f(n-1,x+1)or # If the divisors have been
                                          # exhausted, a HDN has been found
                                          {*s}&{*l}and f(n,x+1)or # If there were illegal digits in
                                          # the last divisor, x isn't a HDN
                                          f(n,x,s+l,(1-x%d)*str(d),d+1)
                                          # Else, try the next divisor, and
                                          # check this divisor's digits (if
                                          # if is one) in the next call
                                          )or~-x # Else, return the answer





                                          share|improve this answer











                                          $endgroup$


















                                            3












                                            $begingroup$


                                            Python 3, 115 bytes



                                            1-indexed





                                            f=lambda n,x=1,s="",l="",d=1:n and(d>x+1and f(n-1,x+1)or{*s}&{*l}and f(n,x+1)or f(n,x,s+l,(1-x%d)*str(d),d+1))or~-x


                                            Try it online!



                                            This uses a lot of recursion; even with increased recursion limit, it can't do f(30). I think it might be golfable further, and I tried finding something to replace the (1-x%d) with, but couldn't come up with anything (-~-x%d has the wrong precedence). Any bytes that can be shaved off are greatly appreciated.



                                            How it works





                                            # n: HDNs to go
                                            # x: Currently tested number
                                            # s: String of currently seen divisor digits
                                            # l: String of digits of last tried divisor if it was a divisor, empty string otherwise
                                            # d: Currently tested divisor

                                            f=lambda n,x=1,s="",l="",d=1:n and( # If there are still numbers to go
                                            d>x+1and f(n-1,x+1)or # If the divisors have been
                                            # exhausted, a HDN has been found
                                            {*s}&{*l}and f(n,x+1)or # If there were illegal digits in
                                            # the last divisor, x isn't a HDN
                                            f(n,x,s+l,(1-x%d)*str(d),d+1)
                                            # Else, try the next divisor, and
                                            # check this divisor's digits (if
                                            # if is one) in the next call
                                            )or~-x # Else, return the answer





                                            share|improve this answer











                                            $endgroup$
















                                              3












                                              3








                                              3





                                              $begingroup$


                                              Python 3, 115 bytes



                                              1-indexed





                                              f=lambda n,x=1,s="",l="",d=1:n and(d>x+1and f(n-1,x+1)or{*s}&{*l}and f(n,x+1)or f(n,x,s+l,(1-x%d)*str(d),d+1))or~-x


                                              Try it online!



                                              This uses a lot of recursion; even with increased recursion limit, it can't do f(30). I think it might be golfable further, and I tried finding something to replace the (1-x%d) with, but couldn't come up with anything (-~-x%d has the wrong precedence). Any bytes that can be shaved off are greatly appreciated.



                                              How it works





                                              # n: HDNs to go
                                              # x: Currently tested number
                                              # s: String of currently seen divisor digits
                                              # l: String of digits of last tried divisor if it was a divisor, empty string otherwise
                                              # d: Currently tested divisor

                                              f=lambda n,x=1,s="",l="",d=1:n and( # If there are still numbers to go
                                              d>x+1and f(n-1,x+1)or # If the divisors have been
                                              # exhausted, a HDN has been found
                                              {*s}&{*l}and f(n,x+1)or # If there were illegal digits in
                                              # the last divisor, x isn't a HDN
                                              f(n,x,s+l,(1-x%d)*str(d),d+1)
                                              # Else, try the next divisor, and
                                              # check this divisor's digits (if
                                              # if is one) in the next call
                                              )or~-x # Else, return the answer





                                              share|improve this answer











                                              $endgroup$




                                              Python 3, 115 bytes



                                              1-indexed





                                              f=lambda n,x=1,s="",l="",d=1:n and(d>x+1and f(n-1,x+1)or{*s}&{*l}and f(n,x+1)or f(n,x,s+l,(1-x%d)*str(d),d+1))or~-x


                                              Try it online!



                                              This uses a lot of recursion; even with increased recursion limit, it can't do f(30). I think it might be golfable further, and I tried finding something to replace the (1-x%d) with, but couldn't come up with anything (-~-x%d has the wrong precedence). Any bytes that can be shaved off are greatly appreciated.



                                              How it works





                                              # n: HDNs to go
                                              # x: Currently tested number
                                              # s: String of currently seen divisor digits
                                              # l: String of digits of last tried divisor if it was a divisor, empty string otherwise
                                              # d: Currently tested divisor

                                              f=lambda n,x=1,s="",l="",d=1:n and( # If there are still numbers to go
                                              d>x+1and f(n-1,x+1)or # If the divisors have been
                                              # exhausted, a HDN has been found
                                              {*s}&{*l}and f(n,x+1)or # If there were illegal digits in
                                              # the last divisor, x isn't a HDN
                                              f(n,x,s+l,(1-x%d)*str(d),d+1)
                                              # Else, try the next divisor, and
                                              # check this divisor's digits (if
                                              # if is one) in the next call
                                              )or~-x # Else, return the answer






                                              share|improve this answer














                                              share|improve this answer



                                              share|improve this answer








                                              edited May 3 at 15:09

























                                              answered May 3 at 15:04









                                              ArBoArBo

                                              56818




                                              56818























                                                  2












                                                  $begingroup$


                                                  Brachylog (v2), 14 bytes



                                                  ;A{ℕfdᵐc≠&}ᶠ⁽t


                                                  Try it online!



                                                  Function submission; input from the left, output to the right. (The TIO link contains a command-line argument to run a function as though it were a full program.)



                                                  Explanation



                                                  "Is this a hostile divisor number?" decision-problem code:



                                                  ℕfdᵐc≠
                                                  ℕ number is ≥0 (required to match the question's definition of "nth solution")
                                                  f list of all factors of the number
                                                  ᵐ for each factor
                                                  d deduplicate its digits
                                                  c concatenate all the deduplications with each other
                                                  ≠ the resulting number has no repeated digits


                                                  This turned out basically the same as @UnrelatedString's, although I wrote it independently.



                                                  "nth solution to a decision-problem" wrapper:



                                                  ;A{…&}ᶠ⁽t
                                                  & output the successful input to
                                                  { }ᶠ the first n solutions of the problem
                                                  ⁽ taking <n, input> as a pair
                                                  ;A form a pair of user input and a "no constraints" value
                                                  t take the last solution (of those first n)


                                                  This is one of those cases where the wrapper required to produce the nth output is significantly longer than the code required to test each output in turn :-)



                                                  I came up with this wrapper independently of @UnrelatedString's. It's the same length and works on the same principle, but somehow ends up being written rather differently. It does have more potential scope for improvement, as we could add constraints on what values we were looking at for free via replacing the A with some constraint variable, but none of the possible constraint variables save bytes. (If there were a "nonnegative integer" constraint variable, you could replace the A with it, and then save a byte via making the the unnecessary.)






                                                  share|improve this answer











                                                  $endgroup$













                                                  • $begingroup$
                                                    It’s 2-indexed?
                                                    $endgroup$
                                                    – FrownyFrog
                                                    May 9 at 10:03
















                                                  2












                                                  $begingroup$


                                                  Brachylog (v2), 14 bytes



                                                  ;A{ℕfdᵐc≠&}ᶠ⁽t


                                                  Try it online!



                                                  Function submission; input from the left, output to the right. (The TIO link contains a command-line argument to run a function as though it were a full program.)



                                                  Explanation



                                                  "Is this a hostile divisor number?" decision-problem code:



                                                  ℕfdᵐc≠
                                                  ℕ number is ≥0 (required to match the question's definition of "nth solution")
                                                  f list of all factors of the number
                                                  ᵐ for each factor
                                                  d deduplicate its digits
                                                  c concatenate all the deduplications with each other
                                                  ≠ the resulting number has no repeated digits


                                                  This turned out basically the same as @UnrelatedString's, although I wrote it independently.



                                                  "nth solution to a decision-problem" wrapper:



                                                  ;A{…&}ᶠ⁽t
                                                  & output the successful input to
                                                  { }ᶠ the first n solutions of the problem
                                                  ⁽ taking <n, input> as a pair
                                                  ;A form a pair of user input and a "no constraints" value
                                                  t take the last solution (of those first n)


                                                  This is one of those cases where the wrapper required to produce the nth output is significantly longer than the code required to test each output in turn :-)



                                                  I came up with this wrapper independently of @UnrelatedString's. It's the same length and works on the same principle, but somehow ends up being written rather differently. It does have more potential scope for improvement, as we could add constraints on what values we were looking at for free via replacing the A with some constraint variable, but none of the possible constraint variables save bytes. (If there were a "nonnegative integer" constraint variable, you could replace the A with it, and then save a byte via making the the unnecessary.)






                                                  share|improve this answer











                                                  $endgroup$













                                                  • $begingroup$
                                                    It’s 2-indexed?
                                                    $endgroup$
                                                    – FrownyFrog
                                                    May 9 at 10:03














                                                  2












                                                  2








                                                  2





                                                  $begingroup$


                                                  Brachylog (v2), 14 bytes



                                                  ;A{ℕfdᵐc≠&}ᶠ⁽t


                                                  Try it online!



                                                  Function submission; input from the left, output to the right. (The TIO link contains a command-line argument to run a function as though it were a full program.)



                                                  Explanation



                                                  "Is this a hostile divisor number?" decision-problem code:



                                                  ℕfdᵐc≠
                                                  ℕ number is ≥0 (required to match the question's definition of "nth solution")
                                                  f list of all factors of the number
                                                  ᵐ for each factor
                                                  d deduplicate its digits
                                                  c concatenate all the deduplications with each other
                                                  ≠ the resulting number has no repeated digits


                                                  This turned out basically the same as @UnrelatedString's, although I wrote it independently.



                                                  "nth solution to a decision-problem" wrapper:



                                                  ;A{…&}ᶠ⁽t
                                                  & output the successful input to
                                                  { }ᶠ the first n solutions of the problem
                                                  ⁽ taking <n, input> as a pair
                                                  ;A form a pair of user input and a "no constraints" value
                                                  t take the last solution (of those first n)


                                                  This is one of those cases where the wrapper required to produce the nth output is significantly longer than the code required to test each output in turn :-)



                                                  I came up with this wrapper independently of @UnrelatedString's. It's the same length and works on the same principle, but somehow ends up being written rather differently. It does have more potential scope for improvement, as we could add constraints on what values we were looking at for free via replacing the A with some constraint variable, but none of the possible constraint variables save bytes. (If there were a "nonnegative integer" constraint variable, you could replace the A with it, and then save a byte via making the the unnecessary.)






                                                  share|improve this answer











                                                  $endgroup$




                                                  Brachylog (v2), 14 bytes



                                                  ;A{ℕfdᵐc≠&}ᶠ⁽t


                                                  Try it online!



                                                  Function submission; input from the left, output to the right. (The TIO link contains a command-line argument to run a function as though it were a full program.)



                                                  Explanation



                                                  "Is this a hostile divisor number?" decision-problem code:



                                                  ℕfdᵐc≠
                                                  ℕ number is ≥0 (required to match the question's definition of "nth solution")
                                                  f list of all factors of the number
                                                  ᵐ for each factor
                                                  d deduplicate its digits
                                                  c concatenate all the deduplications with each other
                                                  ≠ the resulting number has no repeated digits


                                                  This turned out basically the same as @UnrelatedString's, although I wrote it independently.



                                                  "nth solution to a decision-problem" wrapper:



                                                  ;A{…&}ᶠ⁽t
                                                  & output the successful input to
                                                  { }ᶠ the first n solutions of the problem
                                                  ⁽ taking <n, input> as a pair
                                                  ;A form a pair of user input and a "no constraints" value
                                                  t take the last solution (of those first n)


                                                  This is one of those cases where the wrapper required to produce the nth output is significantly longer than the code required to test each output in turn :-)



                                                  I came up with this wrapper independently of @UnrelatedString's. It's the same length and works on the same principle, but somehow ends up being written rather differently. It does have more potential scope for improvement, as we could add constraints on what values we were looking at for free via replacing the A with some constraint variable, but none of the possible constraint variables save bytes. (If there were a "nonnegative integer" constraint variable, you could replace the A with it, and then save a byte via making the the unnecessary.)







                                                  share|improve this answer














                                                  share|improve this answer



                                                  share|improve this answer








                                                  answered May 4 at 9:58


























                                                  community wiki





                                                  ais523













                                                  • $begingroup$
                                                    It’s 2-indexed?
                                                    $endgroup$
                                                    – FrownyFrog
                                                    May 9 at 10:03


















                                                  • $begingroup$
                                                    It’s 2-indexed?
                                                    $endgroup$
                                                    – FrownyFrog
                                                    May 9 at 10:03
















                                                  $begingroup$
                                                  It’s 2-indexed?
                                                  $endgroup$
                                                  – FrownyFrog
                                                  May 9 at 10:03




                                                  $begingroup$
                                                  It’s 2-indexed?
                                                  $endgroup$
                                                  – FrownyFrog
                                                  May 9 at 10:03











                                                  2












                                                  $begingroup$

                                                  Java 10, 149 139 138 126 125 120 bytes





                                                  n->{int r=0,i,d;for(;n>0;n-=d){var s="1";for(r++,d=i=1;i++<r;)if(r%i<1){d=s.matches(".*["+i+"].*")?0:d;s+=i;}}return r;}


                                                  -10 bytes by using .matches instead of .contains per digit, inspired by @Arnauld's JavaScript answer.

                                                  -5 bytes thanks to @ValueInk



                                                  1-indexed



                                                  Try it online.



                                                  Explanation:



                                                  n->{                 // Method with integer as both parameter and return-type
                                                  int r=0, // Result-integer, starting at 0
                                                  i, // Index integer
                                                  d; // Decrement integer
                                                  for(;n>0; // Loop until the input `n` is 0:
                                                  n-=d){ // After every iteration: decrease `n` by the decrement integer `d`
                                                  var s="1"; // Create a String `s`, starting at "1"
                                                  for(r++, // Increase the result by 1
                                                  d=i=1; // (Re)set the decrement integer to 1
                                                  i++<r;) // Inner loop `i` in the range [2, r]:
                                                  if(r%i<1){ // If `r` is divisible by `i`:
                                                  d=s.matches(".*["+i+"].*")?
                                                  // If string `s` contains any digits also found in integer `i`:
                                                  0 // Set the decrement integer `d` to 0
                                                  :d; // Else: leave `d` unchanged
                                                  s+=i;}} // And then append `i` to the String `s`
                                                  return r;} // After the loops, return the result `r`





                                                  share|improve this answer











                                                  $endgroup$









                                                  • 1




                                                    $begingroup$
                                                    If you switch the i and s in your regex search, you don't need the extra string conversion, and the result is the same.
                                                    $endgroup$
                                                    – Value Ink
                                                    May 8 at 2:03










                                                  • $begingroup$
                                                    @ValueInk Thanks! :)
                                                    $endgroup$
                                                    – Kevin Cruijssen
                                                    May 8 at 6:22
















                                                  2












                                                  $begingroup$

                                                  Java 10, 149 139 138 126 125 120 bytes





                                                  n->{int r=0,i,d;for(;n>0;n-=d){var s="1";for(r++,d=i=1;i++<r;)if(r%i<1){d=s.matches(".*["+i+"].*")?0:d;s+=i;}}return r;}


                                                  -10 bytes by using .matches instead of .contains per digit, inspired by @Arnauld's JavaScript answer.

                                                  -5 bytes thanks to @ValueInk



                                                  1-indexed



                                                  Try it online.



                                                  Explanation:



                                                  n->{                 // Method with integer as both parameter and return-type
                                                  int r=0, // Result-integer, starting at 0
                                                  i, // Index integer
                                                  d; // Decrement integer
                                                  for(;n>0; // Loop until the input `n` is 0:
                                                  n-=d){ // After every iteration: decrease `n` by the decrement integer `d`
                                                  var s="1"; // Create a String `s`, starting at "1"
                                                  for(r++, // Increase the result by 1
                                                  d=i=1; // (Re)set the decrement integer to 1
                                                  i++<r;) // Inner loop `i` in the range [2, r]:
                                                  if(r%i<1){ // If `r` is divisible by `i`:
                                                  d=s.matches(".*["+i+"].*")?
                                                  // If string `s` contains any digits also found in integer `i`:
                                                  0 // Set the decrement integer `d` to 0
                                                  :d; // Else: leave `d` unchanged
                                                  s+=i;}} // And then append `i` to the String `s`
                                                  return r;} // After the loops, return the result `r`





                                                  share|improve this answer











                                                  $endgroup$









                                                  • 1




                                                    $begingroup$
                                                    If you switch the i and s in your regex search, you don't need the extra string conversion, and the result is the same.
                                                    $endgroup$
                                                    – Value Ink
                                                    May 8 at 2:03










                                                  • $begingroup$
                                                    @ValueInk Thanks! :)
                                                    $endgroup$
                                                    – Kevin Cruijssen
                                                    May 8 at 6:22














                                                  2












                                                  2








                                                  2





                                                  $begingroup$

                                                  Java 10, 149 139 138 126 125 120 bytes





                                                  n->{int r=0,i,d;for(;n>0;n-=d){var s="1";for(r++,d=i=1;i++<r;)if(r%i<1){d=s.matches(".*["+i+"].*")?0:d;s+=i;}}return r;}


                                                  -10 bytes by using .matches instead of .contains per digit, inspired by @Arnauld's JavaScript answer.

                                                  -5 bytes thanks to @ValueInk



                                                  1-indexed



                                                  Try it online.



                                                  Explanation:



                                                  n->{                 // Method with integer as both parameter and return-type
                                                  int r=0, // Result-integer, starting at 0
                                                  i, // Index integer
                                                  d; // Decrement integer
                                                  for(;n>0; // Loop until the input `n` is 0:
                                                  n-=d){ // After every iteration: decrease `n` by the decrement integer `d`
                                                  var s="1"; // Create a String `s`, starting at "1"
                                                  for(r++, // Increase the result by 1
                                                  d=i=1; // (Re)set the decrement integer to 1
                                                  i++<r;) // Inner loop `i` in the range [2, r]:
                                                  if(r%i<1){ // If `r` is divisible by `i`:
                                                  d=s.matches(".*["+i+"].*")?
                                                  // If string `s` contains any digits also found in integer `i`:
                                                  0 // Set the decrement integer `d` to 0
                                                  :d; // Else: leave `d` unchanged
                                                  s+=i;}} // And then append `i` to the String `s`
                                                  return r;} // After the loops, return the result `r`





                                                  share|improve this answer











                                                  $endgroup$



                                                  Java 10, 149 139 138 126 125 120 bytes





                                                  n->{int r=0,i,d;for(;n>0;n-=d){var s="1";for(r++,d=i=1;i++<r;)if(r%i<1){d=s.matches(".*["+i+"].*")?0:d;s+=i;}}return r;}


                                                  -10 bytes by using .matches instead of .contains per digit, inspired by @Arnauld's JavaScript answer.

                                                  -5 bytes thanks to @ValueInk



                                                  1-indexed



                                                  Try it online.



                                                  Explanation:



                                                  n->{                 // Method with integer as both parameter and return-type
                                                  int r=0, // Result-integer, starting at 0
                                                  i, // Index integer
                                                  d; // Decrement integer
                                                  for(;n>0; // Loop until the input `n` is 0:
                                                  n-=d){ // After every iteration: decrease `n` by the decrement integer `d`
                                                  var s="1"; // Create a String `s`, starting at "1"
                                                  for(r++, // Increase the result by 1
                                                  d=i=1; // (Re)set the decrement integer to 1
                                                  i++<r;) // Inner loop `i` in the range [2, r]:
                                                  if(r%i<1){ // If `r` is divisible by `i`:
                                                  d=s.matches(".*["+i+"].*")?
                                                  // If string `s` contains any digits also found in integer `i`:
                                                  0 // Set the decrement integer `d` to 0
                                                  :d; // Else: leave `d` unchanged
                                                  s+=i;}} // And then append `i` to the String `s`
                                                  return r;} // After the loops, return the result `r`






                                                  share|improve this answer














                                                  share|improve this answer



                                                  share|improve this answer








                                                  edited May 8 at 6:22

























                                                  answered May 3 at 16:02









                                                  Kevin CruijssenKevin Cruijssen

                                                  45.1k576227




                                                  45.1k576227








                                                  • 1




                                                    $begingroup$
                                                    If you switch the i and s in your regex search, you don't need the extra string conversion, and the result is the same.
                                                    $endgroup$
                                                    – Value Ink
                                                    May 8 at 2:03










                                                  • $begingroup$
                                                    @ValueInk Thanks! :)
                                                    $endgroup$
                                                    – Kevin Cruijssen
                                                    May 8 at 6:22














                                                  • 1




                                                    $begingroup$
                                                    If you switch the i and s in your regex search, you don't need the extra string conversion, and the result is the same.
                                                    $endgroup$
                                                    – Value Ink
                                                    May 8 at 2:03










                                                  • $begingroup$
                                                    @ValueInk Thanks! :)
                                                    $endgroup$
                                                    – Kevin Cruijssen
                                                    May 8 at 6:22








                                                  1




                                                  1




                                                  $begingroup$
                                                  If you switch the i and s in your regex search, you don't need the extra string conversion, and the result is the same.
                                                  $endgroup$
                                                  – Value Ink
                                                  May 8 at 2:03




                                                  $begingroup$
                                                  If you switch the i and s in your regex search, you don't need the extra string conversion, and the result is the same.
                                                  $endgroup$
                                                  – Value Ink
                                                  May 8 at 2:03












                                                  $begingroup$
                                                  @ValueInk Thanks! :)
                                                  $endgroup$
                                                  – Kevin Cruijssen
                                                  May 8 at 6:22




                                                  $begingroup$
                                                  @ValueInk Thanks! :)
                                                  $endgroup$
                                                  – Kevin Cruijssen
                                                  May 8 at 6:22











                                                  1












                                                  $begingroup$


                                                  Brachylog, 16 bytes



                                                  g{∧0<.fdᵐc≠∧}ᵘ⁾t


                                                  Try it online!



                                                  Very slow, and twice as long as it would be if this was a decision-problem. 1-indexed.



                                                                      The output
                                                  t is the last
                                                  ᵘ⁾ of a number of unique outputs,
                                                  g where that number is the input,
                                                  { } from the predicate declaring that:
                                                  . the output
                                                  < which is greater than
                                                  0 zero
                                                  ∧ (which is not the empty list)
                                                  f factorized
                                                  ᵐ with each factor individually
                                                  d having duplicate digits removed
                                                  ≠ has no duplicate digits in
                                                  c the concatenation of the factors
                                                  ∧ (which is not the output).





                                                  share|improve this answer









                                                  $endgroup$









                                                  • 1




                                                    $begingroup$
                                                    If you just read that explanation as a sentence though...
                                                    $endgroup$
                                                    – FireCubez
                                                    May 4 at 11:24










                                                  • $begingroup$
                                                    I try to write my explanations like plain English, which typically ends up just making them harder to read
                                                    $endgroup$
                                                    – Unrelated String
                                                    May 4 at 20:25
















                                                  1












                                                  $begingroup$


                                                  Brachylog, 16 bytes



                                                  g{∧0<.fdᵐc≠∧}ᵘ⁾t


                                                  Try it online!



                                                  Very slow, and twice as long as it would be if this was a decision-problem. 1-indexed.



                                                                      The output
                                                  t is the last
                                                  ᵘ⁾ of a number of unique outputs,
                                                  g where that number is the input,
                                                  { } from the predicate declaring that:
                                                  . the output
                                                  < which is greater than
                                                  0 zero
                                                  ∧ (which is not the empty list)
                                                  f factorized
                                                  ᵐ with each factor individually
                                                  d having duplicate digits removed
                                                  ≠ has no duplicate digits in
                                                  c the concatenation of the factors
                                                  ∧ (which is not the output).





                                                  share|improve this answer









                                                  $endgroup$









                                                  • 1




                                                    $begingroup$
                                                    If you just read that explanation as a sentence though...
                                                    $endgroup$
                                                    – FireCubez
                                                    May 4 at 11:24










                                                  • $begingroup$
                                                    I try to write my explanations like plain English, which typically ends up just making them harder to read
                                                    $endgroup$
                                                    – Unrelated String
                                                    May 4 at 20:25














                                                  1












                                                  1








                                                  1





                                                  $begingroup$


                                                  Brachylog, 16 bytes



                                                  g{∧0<.fdᵐc≠∧}ᵘ⁾t


                                                  Try it online!



                                                  Very slow, and twice as long as it would be if this was a decision-problem. 1-indexed.



                                                                      The output
                                                  t is the last
                                                  ᵘ⁾ of a number of unique outputs,
                                                  g where that number is the input,
                                                  { } from the predicate declaring that:
                                                  . the output
                                                  < which is greater than
                                                  0 zero
                                                  ∧ (which is not the empty list)
                                                  f factorized
                                                  ᵐ with each factor individually
                                                  d having duplicate digits removed
                                                  ≠ has no duplicate digits in
                                                  c the concatenation of the factors
                                                  ∧ (which is not the output).





                                                  share|improve this answer









                                                  $endgroup$




                                                  Brachylog, 16 bytes



                                                  g{∧0<.fdᵐc≠∧}ᵘ⁾t


                                                  Try it online!



                                                  Very slow, and twice as long as it would be if this was a decision-problem. 1-indexed.



                                                                      The output
                                                  t is the last
                                                  ᵘ⁾ of a number of unique outputs,
                                                  g where that number is the input,
                                                  { } from the predicate declaring that:
                                                  . the output
                                                  < which is greater than
                                                  0 zero
                                                  ∧ (which is not the empty list)
                                                  f factorized
                                                  ᵐ with each factor individually
                                                  d having duplicate digits removed
                                                  ≠ has no duplicate digits in
                                                  c the concatenation of the factors
                                                  ∧ (which is not the output).






                                                  share|improve this answer












                                                  share|improve this answer



                                                  share|improve this answer










                                                  answered May 3 at 22:00









                                                  Unrelated StringUnrelated String

                                                  2,200313




                                                  2,200313








                                                  • 1




                                                    $begingroup$
                                                    If you just read that explanation as a sentence though...
                                                    $endgroup$
                                                    – FireCubez
                                                    May 4 at 11:24










                                                  • $begingroup$
                                                    I try to write my explanations like plain English, which typically ends up just making them harder to read
                                                    $endgroup$
                                                    – Unrelated String
                                                    May 4 at 20:25














                                                  • 1




                                                    $begingroup$
                                                    If you just read that explanation as a sentence though...
                                                    $endgroup$
                                                    – FireCubez
                                                    May 4 at 11:24










                                                  • $begingroup$
                                                    I try to write my explanations like plain English, which typically ends up just making them harder to read
                                                    $endgroup$
                                                    – Unrelated String
                                                    May 4 at 20:25








                                                  1




                                                  1




                                                  $begingroup$
                                                  If you just read that explanation as a sentence though...
                                                  $endgroup$
                                                  – FireCubez
                                                  May 4 at 11:24




                                                  $begingroup$
                                                  If you just read that explanation as a sentence though...
                                                  $endgroup$
                                                  – FireCubez
                                                  May 4 at 11:24












                                                  $begingroup$
                                                  I try to write my explanations like plain English, which typically ends up just making them harder to read
                                                  $endgroup$
                                                  – Unrelated String
                                                  May 4 at 20:25




                                                  $begingroup$
                                                  I try to write my explanations like plain English, which typically ends up just making them harder to read
                                                  $endgroup$
                                                  – Unrelated String
                                                  May 4 at 20:25











                                                  1












                                                  $begingroup$


                                                  Wolfram Language (Mathematica), 74 bytes



                                                  Nest[1+#//.a_/;!Unequal@@Join@@Union/@IntegerDigits@Divisors@a:>a+1&,0,#]&


                                                  Try it online!






                                                  share|improve this answer









                                                  $endgroup$


















                                                    1












                                                    $begingroup$


                                                    Wolfram Language (Mathematica), 74 bytes



                                                    Nest[1+#//.a_/;!Unequal@@Join@@Union/@IntegerDigits@Divisors@a:>a+1&,0,#]&


                                                    Try it online!






                                                    share|improve this answer









                                                    $endgroup$
















                                                      1












                                                      1








                                                      1





                                                      $begingroup$


                                                      Wolfram Language (Mathematica), 74 bytes



                                                      Nest[1+#//.a_/;!Unequal@@Join@@Union/@IntegerDigits@Divisors@a:>a+1&,0,#]&


                                                      Try it online!






                                                      share|improve this answer









                                                      $endgroup$




                                                      Wolfram Language (Mathematica), 74 bytes



                                                      Nest[1+#//.a_/;!Unequal@@Join@@Union/@IntegerDigits@Divisors@a:>a+1&,0,#]&


                                                      Try it online!







                                                      share|improve this answer












                                                      share|improve this answer



                                                      share|improve this answer










                                                      answered May 3 at 22:21









                                                      attinatattinat

                                                      1,05717




                                                      1,05717























                                                          1












                                                          $begingroup$


                                                          Japt v2.0a0, 17 bytes



                                                          _=â ®sâìUµZ¶â}f1


                                                          Try it



                                                          Port of this Brachylog answer.



                                                          Credit: 4 bytes savings total thanks to Shaggy who also suggested there was a better solution leading to many more bytes :)





                                                          Original answer 28 byte approach:



                                                          Èâ¬rÈ«è"[{Y}]" ©X+Y}Xs)«U´Ãa


                                                          Try it



                                                          Port of this JavaScript answer.






                                                          share|improve this answer











                                                          $endgroup$













                                                          • $begingroup$
                                                            28 bytes
                                                            $endgroup$
                                                            – Shaggy
                                                            May 7 at 17:04










                                                          • $begingroup$
                                                            Nice - I hadn't used the « shortcut before :) I figure if Shaggy is only improving on my score by a handful of bytes, I must be getting (somewhat) decent at this?
                                                            $endgroup$
                                                            – dana
                                                            May 7 at 17:42












                                                          • $begingroup$
                                                            It can be done in 20 (maybe less) b7 employing a slightly different method.
                                                            $endgroup$
                                                            – Shaggy
                                                            May 7 at 18:43










                                                          • $begingroup$
                                                            Hah - I guess I spoke too soon :) yeah, some of the other golfing lang's have much shorter solutions.
                                                            $endgroup$
                                                            – dana
                                                            May 7 at 19:29






                                                          • 1




                                                            $begingroup$
                                                            17 bytes
                                                            $endgroup$
                                                            – Shaggy
                                                            May 8 at 17:56
















                                                          1












                                                          $begingroup$


                                                          Japt v2.0a0, 17 bytes



                                                          _=â ®sâìUµZ¶â}f1


                                                          Try it



                                                          Port of this Brachylog answer.



                                                          Credit: 4 bytes savings total thanks to Shaggy who also suggested there was a better solution leading to many more bytes :)





                                                          Original answer 28 byte approach:



                                                          Èâ¬rÈ«è"[{Y}]" ©X+Y}Xs)«U´Ãa


                                                          Try it



                                                          Port of this JavaScript answer.






                                                          share|improve this answer











                                                          $endgroup$













                                                          • $begingroup$
                                                            28 bytes
                                                            $endgroup$
                                                            – Shaggy
                                                            May 7 at 17:04










                                                          • $begingroup$
                                                            Nice - I hadn't used the « shortcut before :) I figure if Shaggy is only improving on my score by a handful of bytes, I must be getting (somewhat) decent at this?
                                                            $endgroup$
                                                            – dana
                                                            May 7 at 17:42












                                                          • $begingroup$
                                                            It can be done in 20 (maybe less) b7 employing a slightly different method.
                                                            $endgroup$
                                                            – Shaggy
                                                            May 7 at 18:43










                                                          • $begingroup$
                                                            Hah - I guess I spoke too soon :) yeah, some of the other golfing lang's have much shorter solutions.
                                                            $endgroup$
                                                            – dana
                                                            May 7 at 19:29






                                                          • 1




                                                            $begingroup$
                                                            17 bytes
                                                            $endgroup$
                                                            – Shaggy
                                                            May 8 at 17:56














                                                          1












                                                          1








                                                          1





                                                          $begingroup$


                                                          Japt v2.0a0, 17 bytes



                                                          _=â ®sâìUµZ¶â}f1


                                                          Try it



                                                          Port of this Brachylog answer.



                                                          Credit: 4 bytes savings total thanks to Shaggy who also suggested there was a better solution leading to many more bytes :)





                                                          Original answer 28 byte approach:



                                                          Èâ¬rÈ«è"[{Y}]" ©X+Y}Xs)«U´Ãa


                                                          Try it



                                                          Port of this JavaScript answer.






                                                          share|improve this answer











                                                          $endgroup$




                                                          Japt v2.0a0, 17 bytes



                                                          _=â ®sâìUµZ¶â}f1


                                                          Try it



                                                          Port of this Brachylog answer.



                                                          Credit: 4 bytes savings total thanks to Shaggy who also suggested there was a better solution leading to many more bytes :)





                                                          Original answer 28 byte approach:



                                                          Èâ¬rÈ«è"[{Y}]" ©X+Y}Xs)«U´Ãa


                                                          Try it



                                                          Port of this JavaScript answer.







                                                          share|improve this answer














                                                          share|improve this answer



                                                          share|improve this answer








                                                          edited May 8 at 19:44

























                                                          answered May 7 at 14:18









                                                          danadana

                                                          2,261168




                                                          2,261168












                                                          • $begingroup$
                                                            28 bytes
                                                            $endgroup$
                                                            – Shaggy
                                                            May 7 at 17:04










                                                          • $begingroup$
                                                            Nice - I hadn't used the « shortcut before :) I figure if Shaggy is only improving on my score by a handful of bytes, I must be getting (somewhat) decent at this?
                                                            $endgroup$
                                                            – dana
                                                            May 7 at 17:42












                                                          • $begingroup$
                                                            It can be done in 20 (maybe less) b7 employing a slightly different method.
                                                            $endgroup$
                                                            – Shaggy
                                                            May 7 at 18:43










                                                          • $begingroup$
                                                            Hah - I guess I spoke too soon :) yeah, some of the other golfing lang's have much shorter solutions.
                                                            $endgroup$
                                                            – dana
                                                            May 7 at 19:29






                                                          • 1




                                                            $begingroup$
                                                            17 bytes
                                                            $endgroup$
                                                            – Shaggy
                                                            May 8 at 17:56


















                                                          • $begingroup$
                                                            28 bytes
                                                            $endgroup$
                                                            – Shaggy
                                                            May 7 at 17:04










                                                          • $begingroup$
                                                            Nice - I hadn't used the « shortcut before :) I figure if Shaggy is only improving on my score by a handful of bytes, I must be getting (somewhat) decent at this?
                                                            $endgroup$
                                                            – dana
                                                            May 7 at 17:42












                                                          • $begingroup$
                                                            It can be done in 20 (maybe less) b7 employing a slightly different method.
                                                            $endgroup$
                                                            – Shaggy
                                                            May 7 at 18:43










                                                          • $begingroup$
                                                            Hah - I guess I spoke too soon :) yeah, some of the other golfing lang's have much shorter solutions.
                                                            $endgroup$
                                                            – dana
                                                            May 7 at 19:29






                                                          • 1




                                                            $begingroup$
                                                            17 bytes
                                                            $endgroup$
                                                            – Shaggy
                                                            May 8 at 17:56
















                                                          $begingroup$
                                                          28 bytes
                                                          $endgroup$
                                                          – Shaggy
                                                          May 7 at 17:04




                                                          $begingroup$
                                                          28 bytes
                                                          $endgroup$
                                                          – Shaggy
                                                          May 7 at 17:04












                                                          $begingroup$
                                                          Nice - I hadn't used the « shortcut before :) I figure if Shaggy is only improving on my score by a handful of bytes, I must be getting (somewhat) decent at this?
                                                          $endgroup$
                                                          – dana
                                                          May 7 at 17:42






                                                          $begingroup$
                                                          Nice - I hadn't used the « shortcut before :) I figure if Shaggy is only improving on my score by a handful of bytes, I must be getting (somewhat) decent at this?
                                                          $endgroup$
                                                          – dana
                                                          May 7 at 17:42














                                                          $begingroup$
                                                          It can be done in 20 (maybe less) b7 employing a slightly different method.
                                                          $endgroup$
                                                          – Shaggy
                                                          May 7 at 18:43




                                                          $begingroup$
                                                          It can be done in 20 (maybe less) b7 employing a slightly different method.
                                                          $endgroup$
                                                          – Shaggy
                                                          May 7 at 18:43












                                                          $begingroup$
                                                          Hah - I guess I spoke too soon :) yeah, some of the other golfing lang's have much shorter solutions.
                                                          $endgroup$
                                                          – dana
                                                          May 7 at 19:29




                                                          $begingroup$
                                                          Hah - I guess I spoke too soon :) yeah, some of the other golfing lang's have much shorter solutions.
                                                          $endgroup$
                                                          – dana
                                                          May 7 at 19:29




                                                          1




                                                          1




                                                          $begingroup$
                                                          17 bytes
                                                          $endgroup$
                                                          – Shaggy
                                                          May 8 at 17:56




                                                          $begingroup$
                                                          17 bytes
                                                          $endgroup$
                                                          – Shaggy
                                                          May 8 at 17:56











                                                          0












                                                          $begingroup$


                                                          Icon, 123 bytes



                                                          procedure f(n)
                                                          k:=m:=0
                                                          while m<n do{
                                                          k+:=1
                                                          r:=0
                                                          s:=""
                                                          every k%(i:=1 to k)=0&(upto(i,s)&r:=1)|s++:=i
                                                          r=0&m+:=1}
                                                          return k
                                                          end


                                                          Try it online!



                                                          1-indexed. Really slow for big inputs.






                                                          share|improve this answer









                                                          $endgroup$


















                                                            0












                                                            $begingroup$


                                                            Icon, 123 bytes



                                                            procedure f(n)
                                                            k:=m:=0
                                                            while m<n do{
                                                            k+:=1
                                                            r:=0
                                                            s:=""
                                                            every k%(i:=1 to k)=0&(upto(i,s)&r:=1)|s++:=i
                                                            r=0&m+:=1}
                                                            return k
                                                            end


                                                            Try it online!



                                                            1-indexed. Really slow for big inputs.






                                                            share|improve this answer









                                                            $endgroup$
















                                                              0












                                                              0








                                                              0





                                                              $begingroup$


                                                              Icon, 123 bytes



                                                              procedure f(n)
                                                              k:=m:=0
                                                              while m<n do{
                                                              k+:=1
                                                              r:=0
                                                              s:=""
                                                              every k%(i:=1 to k)=0&(upto(i,s)&r:=1)|s++:=i
                                                              r=0&m+:=1}
                                                              return k
                                                              end


                                                              Try it online!



                                                              1-indexed. Really slow for big inputs.






                                                              share|improve this answer









                                                              $endgroup$




                                                              Icon, 123 bytes



                                                              procedure f(n)
                                                              k:=m:=0
                                                              while m<n do{
                                                              k+:=1
                                                              r:=0
                                                              s:=""
                                                              every k%(i:=1 to k)=0&(upto(i,s)&r:=1)|s++:=i
                                                              r=0&m+:=1}
                                                              return k
                                                              end


                                                              Try it online!



                                                              1-indexed. Really slow for big inputs.







                                                              share|improve this answer












                                                              share|improve this answer



                                                              share|improve this answer










                                                              answered May 4 at 9:37









                                                              Galen IvanovGalen Ivanov

                                                              8,34711237




                                                              8,34711237























                                                                  0












                                                                  $begingroup$


                                                                  Perl 6, 74 bytes





                                                                  {(grep {!grep *>1,values [(+)] map *.comb.Set,grep $_%%*,1..$_},1..*)[$_]}


                                                                  0-indexed. Only the first three cases are listed on TIO since it's too slow to test the rest.



                                                                  Try it online!






                                                                  share|improve this answer









                                                                  $endgroup$









                                                                  • 1




                                                                    $begingroup$
                                                                    57 bytes
                                                                    $endgroup$
                                                                    – Jo King
                                                                    May 8 at 6:07
















                                                                  0












                                                                  $begingroup$


                                                                  Perl 6, 74 bytes





                                                                  {(grep {!grep *>1,values [(+)] map *.comb.Set,grep $_%%*,1..$_},1..*)[$_]}


                                                                  0-indexed. Only the first three cases are listed on TIO since it's too slow to test the rest.



                                                                  Try it online!






                                                                  share|improve this answer









                                                                  $endgroup$









                                                                  • 1




                                                                    $begingroup$
                                                                    57 bytes
                                                                    $endgroup$
                                                                    – Jo King
                                                                    May 8 at 6:07














                                                                  0












                                                                  0








                                                                  0





                                                                  $begingroup$


                                                                  Perl 6, 74 bytes





                                                                  {(grep {!grep *>1,values [(+)] map *.comb.Set,grep $_%%*,1..$_},1..*)[$_]}


                                                                  0-indexed. Only the first three cases are listed on TIO since it's too slow to test the rest.



                                                                  Try it online!






                                                                  share|improve this answer









                                                                  $endgroup$




                                                                  Perl 6, 74 bytes





                                                                  {(grep {!grep *>1,values [(+)] map *.comb.Set,grep $_%%*,1..$_},1..*)[$_]}


                                                                  0-indexed. Only the first three cases are listed on TIO since it's too slow to test the rest.



                                                                  Try it online!







                                                                  share|improve this answer












                                                                  share|improve this answer



                                                                  share|improve this answer










                                                                  answered May 6 at 21:28









                                                                  bb94bb94

                                                                  1,431715




                                                                  1,431715








                                                                  • 1




                                                                    $begingroup$
                                                                    57 bytes
                                                                    $endgroup$
                                                                    – Jo King
                                                                    May 8 at 6:07














                                                                  • 1




                                                                    $begingroup$
                                                                    57 bytes
                                                                    $endgroup$
                                                                    – Jo King
                                                                    May 8 at 6:07








                                                                  1




                                                                  1




                                                                  $begingroup$
                                                                  57 bytes
                                                                  $endgroup$
                                                                  – Jo King
                                                                  May 8 at 6:07




                                                                  $begingroup$
                                                                  57 bytes
                                                                  $endgroup$
                                                                  – Jo King
                                                                  May 8 at 6:07











                                                                  0












                                                                  $begingroup$


                                                                  Ruby, 110 97 92 84 bytes



                                                                  -13 bytes by leveraging @Arnauld's JavaScript regex check.



                                                                  -5 bytes for swapping out the times loop for a decrementer and a while.



                                                                  -8 bytes by ditching combination for something more like the other answers.





                                                                  ->n{x=0;n-=1if(s='';1..x+=1).all?{|a|x%a>0||(e=/[#{a}]/!~s;s+=a.to_s;e)}while n>0;x}


                                                                  Try it online!






                                                                  share|improve this answer











                                                                  $endgroup$


















                                                                    0












                                                                    $begingroup$


                                                                    Ruby, 110 97 92 84 bytes



                                                                    -13 bytes by leveraging @Arnauld's JavaScript regex check.



                                                                    -5 bytes for swapping out the times loop for a decrementer and a while.



                                                                    -8 bytes by ditching combination for something more like the other answers.





                                                                    ->n{x=0;n-=1if(s='';1..x+=1).all?{|a|x%a>0||(e=/[#{a}]/!~s;s+=a.to_s;e)}while n>0;x}


                                                                    Try it online!






                                                                    share|improve this answer











                                                                    $endgroup$
















                                                                      0












                                                                      0








                                                                      0





                                                                      $begingroup$


                                                                      Ruby, 110 97 92 84 bytes



                                                                      -13 bytes by leveraging @Arnauld's JavaScript regex check.



                                                                      -5 bytes for swapping out the times loop for a decrementer and a while.



                                                                      -8 bytes by ditching combination for something more like the other answers.





                                                                      ->n{x=0;n-=1if(s='';1..x+=1).all?{|a|x%a>0||(e=/[#{a}]/!~s;s+=a.to_s;e)}while n>0;x}


                                                                      Try it online!






                                                                      share|improve this answer











                                                                      $endgroup$




                                                                      Ruby, 110 97 92 84 bytes



                                                                      -13 bytes by leveraging @Arnauld's JavaScript regex check.



                                                                      -5 bytes for swapping out the times loop for a decrementer and a while.



                                                                      -8 bytes by ditching combination for something more like the other answers.





                                                                      ->n{x=0;n-=1if(s='';1..x+=1).all?{|a|x%a>0||(e=/[#{a}]/!~s;s+=a.to_s;e)}while n>0;x}


                                                                      Try it online!







                                                                      share|improve this answer














                                                                      share|improve this answer



                                                                      share|improve this answer








                                                                      edited May 8 at 21:14

























                                                                      answered May 7 at 22:55









                                                                      Value InkValue Ink

                                                                      8,205731




                                                                      8,205731























                                                                          0












                                                                          $begingroup$


                                                                          Perl 5 -p, 66 bytes





                                                                          map{1while(join$",map{$%$_==0&&$_}1..++$)=~/(d).* .*1/}1..$_}{


                                                                          Try it online!



                                                                          1 indexed






                                                                          share|improve this answer









                                                                          $endgroup$


















                                                                            0












                                                                            $begingroup$


                                                                            Perl 5 -p, 66 bytes





                                                                            map{1while(join$",map{$%$_==0&&$_}1..++$)=~/(d).* .*1/}1..$_}{


                                                                            Try it online!



                                                                            1 indexed






                                                                            share|improve this answer









                                                                            $endgroup$
















                                                                              0












                                                                              0








                                                                              0





                                                                              $begingroup$


                                                                              Perl 5 -p, 66 bytes





                                                                              map{1while(join$",map{$%$_==0&&$_}1..++$)=~/(d).* .*1/}1..$_}{


                                                                              Try it online!



                                                                              1 indexed






                                                                              share|improve this answer









                                                                              $endgroup$




                                                                              Perl 5 -p, 66 bytes





                                                                              map{1while(join$",map{$%$_==0&&$_}1..++$)=~/(d).* .*1/}1..$_}{


                                                                              Try it online!



                                                                              1 indexed







                                                                              share|improve this answer












                                                                              share|improve this answer



                                                                              share|improve this answer










                                                                              answered May 9 at 2:26









                                                                              XcaliXcali

                                                                              5,910523




                                                                              5,910523























                                                                                  0












                                                                                  $begingroup$


                                                                                  J, 87 59 bytes



                                                                                  -28 bytes thanks to FrownFrog



                                                                                  0{(+1,1(-:~.)@;@(~.@":&.>@,i.#~0=i.|])@+{.)@]^:(>{:)^:_&0 0


                                                                                  Try it online!



                                                                                  original




                                                                                  J, 87 bytes



                                                                                  [:{:({.@](>:@[,],([:(-:~.)[:-.&' '@,/~.@":"0)@((]#~0=|~)1+i.)@[#[)}.@])^:(#@]<1+[)^:_&1


                                                                                  Try it online!



                                                                                  Yikes.



                                                                                  This is atrociously long for J, but I'm not seeing great ways to bring it down.



                                                                                  explanation



                                                                                  It helps to introduce a couple helper verbs to see what's happening:



                                                                                  d=.(]#~0=|~)1+i.
                                                                                  h=. [: (-:~.) [: -.&' '@,/ ~.@":"0




                                                                                  • d returns a list of all divisors of its argument


                                                                                  • h tells you such a list is hostile. It stringifies and deduplicates each number ~.@":"0, which returns a square matrix where shorter numbers are padded with spaces. -.&' '@,/ flattens the matrix and removes spaces, and finally (-:~.) tells you if that number has repeats or not.


                                                                                  With those two helpers our overall, ungolfed verb becomes:



                                                                                  [: {: ({.@] (>:@[ , ] , h@d@[ # [) }.@])^:(#@] < 1 + [)^:_&1


                                                                                  Here we maintain a list whose head is our "current candidate" (which starts at 1), and whose tail is all hostile numbers found so far.



                                                                                  We increment the head of the list >:@[ on each iteration, and only append the "current candidate" if it is hostile h@d@[ # [. We keep doing this until our list length reaches 1 + n: ^:(#@] < 1 + [)^:_.



                                                                                  Finally, when we're done, we return the last number of this list [: {: which is the nth hostile number.






                                                                                  share|improve this answer











                                                                                  $endgroup$













                                                                                  • $begingroup$
                                                                                    66
                                                                                    $endgroup$
                                                                                    – FrownyFrog
                                                                                    May 9 at 9:21












                                                                                  • $begingroup$
                                                                                    62
                                                                                    $endgroup$
                                                                                    – FrownyFrog
                                                                                    May 9 at 9:41










                                                                                  • $begingroup$
                                                                                    This is great, many thanks. Will go over it and update tonight
                                                                                    $endgroup$
                                                                                    – Jonah
                                                                                    May 9 at 12:39










                                                                                  • $begingroup$
                                                                                    59
                                                                                    $endgroup$
                                                                                    – FrownyFrog
                                                                                    May 9 at 23:54
















                                                                                  0












                                                                                  $begingroup$


                                                                                  J, 87 59 bytes



                                                                                  -28 bytes thanks to FrownFrog



                                                                                  0{(+1,1(-:~.)@;@(~.@":&.>@,i.#~0=i.|])@+{.)@]^:(>{:)^:_&0 0


                                                                                  Try it online!



                                                                                  original




                                                                                  J, 87 bytes



                                                                                  [:{:({.@](>:@[,],([:(-:~.)[:-.&' '@,/~.@":"0)@((]#~0=|~)1+i.)@[#[)}.@])^:(#@]<1+[)^:_&1


                                                                                  Try it online!



                                                                                  Yikes.



                                                                                  This is atrociously long for J, but I'm not seeing great ways to bring it down.



                                                                                  explanation



                                                                                  It helps to introduce a couple helper verbs to see what's happening:



                                                                                  d=.(]#~0=|~)1+i.
                                                                                  h=. [: (-:~.) [: -.&' '@,/ ~.@":"0




                                                                                  • d returns a list of all divisors of its argument


                                                                                  • h tells you such a list is hostile. It stringifies and deduplicates each number ~.@":"0, which returns a square matrix where shorter numbers are padded with spaces. -.&' '@,/ flattens the matrix and removes spaces, and finally (-:~.) tells you if that number has repeats or not.


                                                                                  With those two helpers our overall, ungolfed verb becomes:



                                                                                  [: {: ({.@] (>:@[ , ] , h@d@[ # [) }.@])^:(#@] < 1 + [)^:_&1


                                                                                  Here we maintain a list whose head is our "current candidate" (which starts at 1), and whose tail is all hostile numbers found so far.



                                                                                  We increment the head of the list >:@[ on each iteration, and only append the "current candidate" if it is hostile h@d@[ # [. We keep doing this until our list length reaches 1 + n: ^:(#@] < 1 + [)^:_.



                                                                                  Finally, when we're done, we return the last number of this list [: {: which is the nth hostile number.






                                                                                  share|improve this answer











                                                                                  $endgroup$













                                                                                  • $begingroup$
                                                                                    66
                                                                                    $endgroup$
                                                                                    – FrownyFrog
                                                                                    May 9 at 9:21












                                                                                  • $begingroup$
                                                                                    62
                                                                                    $endgroup$
                                                                                    – FrownyFrog
                                                                                    May 9 at 9:41










                                                                                  • $begingroup$
                                                                                    This is great, many thanks. Will go over it and update tonight
                                                                                    $endgroup$
                                                                                    – Jonah
                                                                                    May 9 at 12:39










                                                                                  • $begingroup$
                                                                                    59
                                                                                    $endgroup$
                                                                                    – FrownyFrog
                                                                                    May 9 at 23:54














                                                                                  0












                                                                                  0








                                                                                  0





                                                                                  $begingroup$


                                                                                  J, 87 59 bytes



                                                                                  -28 bytes thanks to FrownFrog



                                                                                  0{(+1,1(-:~.)@;@(~.@":&.>@,i.#~0=i.|])@+{.)@]^:(>{:)^:_&0 0


                                                                                  Try it online!



                                                                                  original




                                                                                  J, 87 bytes



                                                                                  [:{:({.@](>:@[,],([:(-:~.)[:-.&' '@,/~.@":"0)@((]#~0=|~)1+i.)@[#[)}.@])^:(#@]<1+[)^:_&1


                                                                                  Try it online!



                                                                                  Yikes.



                                                                                  This is atrociously long for J, but I'm not seeing great ways to bring it down.



                                                                                  explanation



                                                                                  It helps to introduce a couple helper verbs to see what's happening:



                                                                                  d=.(]#~0=|~)1+i.
                                                                                  h=. [: (-:~.) [: -.&' '@,/ ~.@":"0




                                                                                  • d returns a list of all divisors of its argument


                                                                                  • h tells you such a list is hostile. It stringifies and deduplicates each number ~.@":"0, which returns a square matrix where shorter numbers are padded with spaces. -.&' '@,/ flattens the matrix and removes spaces, and finally (-:~.) tells you if that number has repeats or not.


                                                                                  With those two helpers our overall, ungolfed verb becomes:



                                                                                  [: {: ({.@] (>:@[ , ] , h@d@[ # [) }.@])^:(#@] < 1 + [)^:_&1


                                                                                  Here we maintain a list whose head is our "current candidate" (which starts at 1), and whose tail is all hostile numbers found so far.



                                                                                  We increment the head of the list >:@[ on each iteration, and only append the "current candidate" if it is hostile h@d@[ # [. We keep doing this until our list length reaches 1 + n: ^:(#@] < 1 + [)^:_.



                                                                                  Finally, when we're done, we return the last number of this list [: {: which is the nth hostile number.






                                                                                  share|improve this answer











                                                                                  $endgroup$




                                                                                  J, 87 59 bytes



                                                                                  -28 bytes thanks to FrownFrog



                                                                                  0{(+1,1(-:~.)@;@(~.@":&.>@,i.#~0=i.|])@+{.)@]^:(>{:)^:_&0 0


                                                                                  Try it online!



                                                                                  original




                                                                                  J, 87 bytes



                                                                                  [:{:({.@](>:@[,],([:(-:~.)[:-.&' '@,/~.@":"0)@((]#~0=|~)1+i.)@[#[)}.@])^:(#@]<1+[)^:_&1


                                                                                  Try it online!



                                                                                  Yikes.



                                                                                  This is atrociously long for J, but I'm not seeing great ways to bring it down.



                                                                                  explanation



                                                                                  It helps to introduce a couple helper verbs to see what's happening:



                                                                                  d=.(]#~0=|~)1+i.
                                                                                  h=. [: (-:~.) [: -.&' '@,/ ~.@":"0




                                                                                  • d returns a list of all divisors of its argument


                                                                                  • h tells you such a list is hostile. It stringifies and deduplicates each number ~.@":"0, which returns a square matrix where shorter numbers are padded with spaces. -.&' '@,/ flattens the matrix and removes spaces, and finally (-:~.) tells you if that number has repeats or not.


                                                                                  With those two helpers our overall, ungolfed verb becomes:



                                                                                  [: {: ({.@] (>:@[ , ] , h@d@[ # [) }.@])^:(#@] < 1 + [)^:_&1


                                                                                  Here we maintain a list whose head is our "current candidate" (which starts at 1), and whose tail is all hostile numbers found so far.



                                                                                  We increment the head of the list >:@[ on each iteration, and only append the "current candidate" if it is hostile h@d@[ # [. We keep doing this until our list length reaches 1 + n: ^:(#@] < 1 + [)^:_.



                                                                                  Finally, when we're done, we return the last number of this list [: {: which is the nth hostile number.







                                                                                  share|improve this answer














                                                                                  share|improve this answer



                                                                                  share|improve this answer








                                                                                  edited May 10 at 0:24

























                                                                                  answered May 4 at 20:35









                                                                                  JonahJonah

                                                                                  3,3781019




                                                                                  3,3781019












                                                                                  • $begingroup$
                                                                                    66
                                                                                    $endgroup$
                                                                                    – FrownyFrog
                                                                                    May 9 at 9:21












                                                                                  • $begingroup$
                                                                                    62
                                                                                    $endgroup$
                                                                                    – FrownyFrog
                                                                                    May 9 at 9:41










                                                                                  • $begingroup$
                                                                                    This is great, many thanks. Will go over it and update tonight
                                                                                    $endgroup$
                                                                                    – Jonah
                                                                                    May 9 at 12:39










                                                                                  • $begingroup$
                                                                                    59
                                                                                    $endgroup$
                                                                                    – FrownyFrog
                                                                                    May 9 at 23:54


















                                                                                  • $begingroup$
                                                                                    66
                                                                                    $endgroup$
                                                                                    – FrownyFrog
                                                                                    May 9 at 9:21












                                                                                  • $begingroup$
                                                                                    62
                                                                                    $endgroup$
                                                                                    – FrownyFrog
                                                                                    May 9 at 9:41










                                                                                  • $begingroup$
                                                                                    This is great, many thanks. Will go over it and update tonight
                                                                                    $endgroup$
                                                                                    – Jonah
                                                                                    May 9 at 12:39










                                                                                  • $begingroup$
                                                                                    59
                                                                                    $endgroup$
                                                                                    – FrownyFrog
                                                                                    May 9 at 23:54
















                                                                                  $begingroup$
                                                                                  66
                                                                                  $endgroup$
                                                                                  – FrownyFrog
                                                                                  May 9 at 9:21






                                                                                  $begingroup$
                                                                                  66
                                                                                  $endgroup$
                                                                                  – FrownyFrog
                                                                                  May 9 at 9:21














                                                                                  $begingroup$
                                                                                  62
                                                                                  $endgroup$
                                                                                  – FrownyFrog
                                                                                  May 9 at 9:41




                                                                                  $begingroup$
                                                                                  62
                                                                                  $endgroup$
                                                                                  – FrownyFrog
                                                                                  May 9 at 9:41












                                                                                  $begingroup$
                                                                                  This is great, many thanks. Will go over it and update tonight
                                                                                  $endgroup$
                                                                                  – Jonah
                                                                                  May 9 at 12:39




                                                                                  $begingroup$
                                                                                  This is great, many thanks. Will go over it and update tonight
                                                                                  $endgroup$
                                                                                  – Jonah
                                                                                  May 9 at 12:39












                                                                                  $begingroup$
                                                                                  59
                                                                                  $endgroup$
                                                                                  – FrownyFrog
                                                                                  May 9 at 23:54




                                                                                  $begingroup$
                                                                                  59
                                                                                  $endgroup$
                                                                                  – FrownyFrog
                                                                                  May 9 at 23:54


















                                                                                  draft saved

                                                                                  draft discarded




















































                                                                                  If this is an answer to a challenge…




                                                                                  • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                                                                                  • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                                                                                    Explanations of your answer make it more interesting to read and are very much encouraged.


                                                                                  • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.



                                                                                  More generally…




                                                                                  • …Please make sure to answer the question and provide sufficient detail.


                                                                                  • …Avoid asking for help, clarification or responding to other answers (use comments instead).





                                                                                  draft saved


                                                                                  draft discarded














                                                                                  StackExchange.ready(
                                                                                  function () {
                                                                                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f185102%2fhostile-divisor-numbers%23new-answer', 'question_page');
                                                                                  }
                                                                                  );

                                                                                  Post as a guest















                                                                                  Required, but never shown





















































                                                                                  Required, but never shown














                                                                                  Required, but never shown












                                                                                  Required, but never shown







                                                                                  Required, but never shown

































                                                                                  Required, but never shown














                                                                                  Required, but never shown












                                                                                  Required, but never shown







                                                                                  Required, but never shown







                                                                                  Popular posts from this blog

                                                                                  Bruad Bilen | Luke uk diar | NawigatsjuunCommonskategorii: BruadCommonskategorii: RunstükenWikiquote: Bruad

                                                                                  What is the offset in a seaplane's hull?

                                                                                  Slayer Innehåll Historia | Stil, komposition och lyrik | Bandets betydelse och framgångar | Sidoprojekt och samarbeten | Kontroverser | Medlemmar | Utmärkelser och nomineringar | Turnéer och festivaler | Diskografi | Referenser | Externa länkar | Navigeringsmenywww.slayer.net”Metal Massacre vol. 1””Metal Massacre vol. 3””Metal Massacre Volume III””Show No Mercy””Haunting the Chapel””Live Undead””Hell Awaits””Reign in Blood””Reign in Blood””Gold & Platinum – Reign in Blood””Golden Gods Awards Winners”originalet”Kerrang! Hall Of Fame””Slayer Looks Back On 37-Year Career In New Video Series: Part Two””South of Heaven””Gold & Platinum – South of Heaven””Seasons in the Abyss””Gold & Platinum - Seasons in the Abyss””Divine Intervention””Divine Intervention - Release group by Slayer””Gold & Platinum - Divine Intervention””Live Intrusion””Undisputed Attitude””Abolish Government/Superficial Love””Release “Slatanic Slaughter: A Tribute to Slayer” by Various Artists””Diabolus in Musica””Soundtrack to the Apocalypse””God Hates Us All””Systematic - Relationships””War at the Warfield””Gold & Platinum - War at the Warfield””Soundtrack to the Apocalypse””Gold & Platinum - Still Reigning””Metallica, Slayer, Iron Mauden Among Winners At Metal Hammer Awards””Eternal Pyre””Eternal Pyre - Slayer release group””Eternal Pyre””Metal Storm Awards 2006””Kerrang! Hall Of Fame””Slayer Wins 'Best Metal' Grammy Award””Slayer Guitarist Jeff Hanneman Dies””Bullet-For My Valentine booed at Metal Hammer Golden Gods Awards””Unholy Aliance””The End Of Slayer?””Slayer: We Could Thrash Out Two More Albums If We're Fast Enough...””'The Unholy Alliance: Chapter III' UK Dates Added”originalet”Megadeth And Slayer To Co-Headline 'Canadian Carnage' Trek”originalet”World Painted Blood””Release “World Painted Blood” by Slayer””Metallica Heading To Cinemas””Slayer, Megadeth To Join Forces For 'European Carnage' Tour - Dec. 18, 2010”originalet”Slayer's Hanneman Contracts Acute Infection; Band To Bring In Guest Guitarist””Cannibal Corpse's Pat O'Brien Will Step In As Slayer's Guest Guitarist”originalet”Slayer’s Jeff Hanneman Dead at 49””Dave Lombardo Says He Made Only $67,000 In 2011 While Touring With Slayer””Slayer: We Do Not Agree With Dave Lombardo's Substance Or Timeline Of Events””Slayer Welcomes Drummer Paul Bostaph Back To The Fold””Slayer Hope to Unveil Never-Before-Heard Jeff Hanneman Material on Next Album””Slayer Debut New Song 'Implode' During Surprise Golden Gods Appearance””Release group Repentless by Slayer””Repentless - Slayer - Credits””Slayer””Metal Storm Awards 2015””Slayer - to release comic book "Repentless #1"””Slayer To Release 'Repentless' 6.66" Vinyl Box Set””BREAKING NEWS: Slayer Announce Farewell Tour””Slayer Recruit Lamb of God, Anthrax, Behemoth + Testament for Final Tour””Slayer lägger ner efter 37 år””Slayer Announces Second North American Leg Of 'Final' Tour””Final World Tour””Slayer Announces Final European Tour With Lamb of God, Anthrax And Obituary””Slayer To Tour Europe With Lamb of God, Anthrax And Obituary””Slayer To Play 'Last French Show Ever' At Next Year's Hellfst””Slayer's Final World Tour Will Extend Into 2019””Death Angel's Rob Cavestany On Slayer's 'Farewell' Tour: 'Some Of Us Could See This Coming'””Testament Has No Plans To Retire Anytime Soon, Says Chuck Billy””Anthrax's Scott Ian On Slayer's 'Farewell' Tour Plans: 'I Was Surprised And I Wasn't Surprised'””Slayer””Slayer's Morbid Schlock””Review/Rock; For Slayer, the Mania Is the Message””Slayer - Biography””Slayer - Reign In Blood”originalet”Dave Lombardo””An exclusive oral history of Slayer”originalet”Exclusive! Interview With Slayer Guitarist Jeff Hanneman”originalet”Thinking Out Loud: Slayer's Kerry King on hair metal, Satan and being polite””Slayer Lyrics””Slayer - Biography””Most influential artists for extreme metal music””Slayer - Reign in Blood””Slayer guitarist Jeff Hanneman dies aged 49””Slatanic Slaughter: A Tribute to Slayer””Gateway to Hell: A Tribute to Slayer””Covered In Blood””Slayer: The Origins of Thrash in San Francisco, CA.””Why They Rule - #6 Slayer”originalet”Guitar World's 100 Greatest Heavy Metal Guitarists Of All Time”originalet”The fans have spoken: Slayer comes out on top in readers' polls”originalet”Tribute to Jeff Hanneman (1964-2013)””Lamb Of God Frontman: We Sound Like A Slayer Rip-Off””BEHEMOTH Frontman Pays Tribute To SLAYER's JEFF HANNEMAN””Slayer, Hatebreed Doing Double Duty On This Year's Ozzfest””System of a Down””Lacuna Coil’s Andrea Ferro Talks Influences, Skateboarding, Band Origins + More””Slayer - Reign in Blood””Into The Lungs of Hell””Slayer rules - en utställning om fans””Slayer and Their Fans Slashed Through a No-Holds-Barred Night at Gas Monkey””Home””Slayer””Gold & Platinum - The Big 4 Live from Sofia, Bulgaria””Exclusive! Interview With Slayer Guitarist Kerry King””2008-02-23: Wiltern, Los Angeles, CA, USA””Slayer's Kerry King To Perform With Megadeth Tonight! - Oct. 21, 2010”originalet”Dave Lombardo - Biography”Slayer Case DismissedArkiveradUltimate Classic Rock: Slayer guitarist Jeff Hanneman dead at 49.”Slayer: "We could never do any thing like Some Kind Of Monster..."””Cannibal Corpse'S Pat O'Brien Will Step In As Slayer'S Guest Guitarist | The Official Slayer Site”originalet”Slayer Wins 'Best Metal' Grammy Award””Slayer Guitarist Jeff Hanneman Dies””Kerrang! Awards 2006 Blog: Kerrang! Hall Of Fame””Kerrang! Awards 2013: Kerrang! Legend”originalet”Metallica, Slayer, Iron Maien Among Winners At Metal Hammer Awards””Metal Hammer Golden Gods Awards””Bullet For My Valentine Booed At Metal Hammer Golden Gods Awards””Metal Storm Awards 2006””Metal Storm Awards 2015””Slayer's Concert History””Slayer - Relationships””Slayer - Releases”Slayers officiella webbplatsSlayer på MusicBrainzOfficiell webbplatsSlayerSlayerr1373445760000 0001 1540 47353068615-5086262726cb13906545x(data)6033143kn20030215029