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

Husk, 2424 22 bytes

Edit: -2 bytes thanks to Razetime

m?o`:'*ssȯ#2`m₁¹oa-₁'*ssȯ#2`m₁¹≠₁
fṗḣ

Try it online!Try it online!

Husk doesn't particularly like mixing numerics + characters.

fṗḣ                   # helper function: primes up to input
m?o`:'*ssȯ#2`m₁¹oa-₁  # main function:
m                  ₁  # for each element in primes up to input
                oa-   # get the absolute differences to 
            `m₁¹      # all primes up to input
         ȯ#2          # and count how many '2's there are:
 ?                    # if it's zero
        s             # convert it to a string
  o`:'*s              # otherwise convert it to a string & prepend with '*'

Husk, 24 bytes

m?o`:'*ssȯ#2`m₁¹oa-₁
fṗḣ

Try it online!

Husk doesn't particularly like mixing numerics + characters.

fṗḣ                   # helper function: primes up to input
m?o`:'*ssȯ#2`m₁¹oa-₁  # main function:
m                  ₁  # for each element in primes up to input
                oa-   # get the absolute differences to 
            `m₁¹      # all primes up to input
         ȯ#2          # and count how many '2's there are:
 ?                    # if it's zero
        s             # convert it to a string
  o`:'*s              # otherwise convert it to a string & prepend with '*'

Husk, 24 22 bytes

Edit: -2 bytes thanks to Razetime

m?o`:'*ssȯ#2`m₁¹≠₁
fṗḣ

Try it online!

Husk doesn't particularly like mixing numerics + characters.

fṗḣ                   # helper function: primes up to input
m?o`:'*ssȯ#2`m₁¹oa-₁  # main function:
m                  ₁  # for each element in primes up to input
                oa-   # get the absolute differences to 
            `m₁¹      # all primes up to input
         ȯ#2          # and count how many '2's there are:
 ?                    # if it's zero
        s             # convert it to a string
  o`:'*s              # otherwise convert it to a string & prepend with '*'
Source Link
Dominic van Essen
  • 36.4k
  • 2
  • 22
  • 60

Husk, 24 bytes

m?o`:'*ssȯ#2`m₁¹oa-₁
fṗḣ

Try it online!

Husk doesn't particularly like mixing numerics + characters.

fṗḣ                   # helper function: primes up to input
m?o`:'*ssȯ#2`m₁¹oa-₁  # main function:
m                  ₁  # for each element in primes up to input
                oa-   # get the absolute differences to 
            `m₁¹      # all primes up to input
         ȯ#2          # and count how many '2's there are:
 ?                    # if it's zero
        s             # convert it to a string
  o`:'*s              # otherwise convert it to a string & prepend with '*'