Generate Monday Numbers

Python 2, 85 bytes

print[n for n in range(1,9**9)if(n<10**len(set(`n`)))>any(n%(int(d)or.3)for d in`n`)]

Prints a list.

I'm basically combining two of my answers to previous challenges:

  • Checking if a number is divisible by each of its digits

    lambda n:any(n%(int(d)or.3)for d in`n`)<1 
    

    (thanks to FryAmTheEggman for reminding me about this).

  • Determine if all decimal digits are unique

    lambda n:10**len(set(`n`))>n
    

Thanks to xsot for 1 byte saved by combining the conditions better.


Perl, 61 47 bytes

46 bytes code + 1 byte command line parameter.

/(.).*\1|0/||1*s/./$_%$&/rge||print for 1..1e7

Usage:

perl -l entry.pl

Explanation

/(.).*\1|0/ returns 1 if the number-under-test contains a duplicate character or a 0

s/./$_%$&/rge replaces each digit with the value of the number-under-test % the digit. For example, 15 -> 00, 16 -> 04 (because 16%6=4). This means that any input which is divisible by all of its digits will consist of all 0s, otherwise it will contain a digit >0. In order to treat this as a number, we *1, which means any number-under-test will return 0 for this block if it is divisible by all of its digits, otherwise >0.

By separating these two statements and the print with 'or's, if either of the first two conditions returns >0, the condition matches and the subsequent parts of the expression will not evaluate. If and only if both previous conditions are 0, the print will then execute. The -l flag ensures to add a new line after each print.


Pyth, 22 21

f&.{`T!f%T|vY.3`TS^T7

Thanks to Jakube for golfing off 1 byte of unnecessary formatting.

Heavily inspired by this CW answer to the related question.

I have a paste of the result here, from when it printed newline separated, now it prints as a pythonic list.

I would recommend not trying it online unless you use a number smaller than 7... I've set it to 2 in this link.

Filters from 1 to 10^7-1 which covers all the necessary values. This version may cause a memory error if it cannot make the list S^T7, which is similar to list(range(1,10**7)) in python 3 (However, it works fine for me). If so, you could try:

.f&.{`Z.x!s%LZjZT0548

Which finds the first 548 Monday numbers. This also demonstrates another way to check for the 0s in the number, instead of replacing them with .3 this uses a try-catch block. Credit for this version goes entirely to Jakube. (Note that this is still much to slow for the online interpreter)