Skip to main content
2 of 2
Commonmark migration

Brachylog, 16 bytes

⟦₂{ṗṗᵐ}ˢ⟨⌋≡⌉⟩|∧0

Try it online!

The completely non-sensical "return 0 if there's no prime" makes us lose 3 bytes (|∧0) for no reason (it would return false. if we didnt add them)

Explanation

⟦₂                Range from the smallest element of the input to the biggest
  {   }ˢ          Select on that range:
   ṗ                Numbers that are primes
    ṗᵐ              And whose digits are primes
        ⟨   ⟩     Fork on this new list:
         ⌋          Minimum
           ⌉        maximum
          ≡         Do nothing and return [Minimum, Maximum]
             |∧0  If all of this fails (i.e. the list after selection is empty), return 0
Fatalize
  • 39.3k
  • 5
  • 70
  • 162