Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

String interpolation is nice
Source Link
user
  • 457
  • 2
  • 21
  • 71

Scala, 173(削除) 173 (削除ここまで) 170 bytes

n=>((""+n)s"$n".indices.toSet.subsets.filter{x=>1<x.size&x.size<(""+n)size<s"$n".size}.map(_.toSeq.sorted.map(""+n).mkString.toInt).toSet+n).filter{x=>x>1&(2 to x/2).forall(x%_>0)}==Set(n)

Try it online!

Scala , 172 bytes

n=>(n.indices.toSet.subsets.filter{x=>1<x.size&x.size<n.size}.map(_.toSeq.sorted.map(n).mkString.toInt).toSet+n.toInt)x=>x>1&2.filter{x=>x>1&(2 to(x/2).forall(x%_>0)}==Set(n.toInt)

Try it online!

It's a tad shorter if the input is already a string, but only by a byte.Try it online!

Scala, 173 bytes

n=>((""+n).indices.toSet.subsets.filter{x=>1<x.size&x.size<(""+n).size}.map(_.toSeq.sorted.map(""+n).mkString.toInt).toSet+n).filter{x=>x>1&(2 to x/2).forall(x%_>0)}==Set(n)

Try it online!

Scala , 172 bytes

n=>(n.indices.toSet.subsets.filter{x=>1<x.size&x.size<n.size}.map(_.toSeq.sorted.map(n).mkString.toInt).toSet+n.toInt).filter{x=>x>1&(2 tox/2).forall(x%_>0)}==Set(n.toInt)

Try it online!

It's a tad shorter if the input is already a string, but only by a byte.

Scala, (削除) 173 (削除ここまで) 170 bytes

n=>(s"$n".indices.toSet.subsets.filter{x=>1<x.size&x.size<s"$n".size}.map(_.toSeq.sorted.map(""+n).mkString.toInt).toSet+n).filter{x=>x>1&2.to(x/2).forall(x%_>0)}==Set(n)

Try it online!

Source Link
user
  • 457
  • 2
  • 21
  • 71

Scala, 173 bytes

n=>((""+n).indices.toSet.subsets.filter{x=>1<x.size&x.size<(""+n).size}.map(_.toSeq.sorted.map(""+n).mkString.toInt).toSet+n).filter{x=>x>1&(2 to x/2).forall(x%_>0)}==Set(n)

Try it online!

Scala, 172 bytes

n=>(n.indices.toSet.subsets.filter{x=>1<x.size&x.size<n.size}.map(_.toSeq.sorted.map(n).mkString.toInt).toSet+n.toInt).filter{x=>x>1&(2 to x/2).forall(x%_>0)}==Set(n.toInt)

Try it online!

It's a tad shorter if the input is already a string, but only by a byte.

AltStyle によって変換されたページ (->オリジナル) /