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

added 77 characters in body
Source Link
Value Ink
  • 13.5k
  • 1
  • 18
  • 46

Ruby, (削除) 110 (削除ここまで) (削除) 97 (削除ここまで) 92(削除) 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[*1.=1if(s='';1.x+=1].combination(2x+=1).all?{|a,b||a|x%a>0||(x%a|x%b)>0||e=/[#{ba}]/!~a~s;s+=a.to_sto_s;e)}while n>0;x}

Try it online! Try it online!

Ruby, (削除) 110 (削除ここまで) (削除) 97 (削除ここまで) 92 bytes

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

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

->n{x=0;n-=1if[*1..x+=1].combination(2).all?{|a,b|(x%a|x%b)>0||/[#{b}]/!~a.to_s}while n>0;x}

Try it online!

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!

added 76 characters in body
Source Link
Value Ink
  • 13.5k
  • 1
  • 18
  • 46

Ruby, (削除) 110 (削除ここまで) 97(削除) 97 (削除ここまで) 92 bytes

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

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

->n{x=0;n.times{x+=1;x+=1until[*1-=1if[*1..x]x+=1].combination(2).all?{|a,b|(x%a|x%b)>0||/[#{b}]/!~a.to_s}};xwhile n>0;x}

Try it online! Try it online!

Ruby, (削除) 110 (削除ここまで) 97 bytes

-13 bytes by leveraging @Arnauld's JavaScript answer.

->n{x=0;n.times{x+=1;x+=1until[*1..x].combination(2).all?{|a,b|(x%a|x%b)>0||/[#{b}]/!~a.to_s}};x}

Try it online!

Ruby, (削除) 110 (削除ここまで) (削除) 97 (削除ここまで) 92 bytes

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

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

->n{x=0;n-=1if[*1..x+=1].combination(2).all?{|a,b|(x%a|x%b)>0||/[#{b}]/!~a.to_s}while n>0;x}

Try it online!

added 33 characters in body
Source Link
Value Ink
  • 13.5k
  • 1
  • 18
  • 46

Ruby, 110(削除) 110 (削除ここまで) 97 bytes

There's gotta be a better way to get the digits in a number in Ruby..-13 bytes by leveraging @Arnauld's JavaScript answer.

->n{x=0;n.times{x+=1;x+=1until[*1..x].combination(2).all?{|a,b|(x%a|x%b)>0||a.to_s.chars&b>0||/[#{b}]/!~a.to_s.chars==[]}};x}

Try it online!

Ruby, 110 bytes

There's gotta be a better way to get the digits in a number in Ruby...

->n{x=0;n.times{x+=1;x+=1until[*1..x].combination(2).all?{|a,b|(x%a|x%b)>0||a.to_s.chars&b.to_s.chars==[]}};x}

Try it online!

Ruby, (削除) 110 (削除ここまで) 97 bytes

-13 bytes by leveraging @Arnauld's JavaScript answer.

->n{x=0;n.times{x+=1;x+=1until[*1..x].combination(2).all?{|a,b|(x%a|x%b)>0||/[#{b}]/!~a.to_s}};x}

Try it online!

Source Link
Value Ink
  • 13.5k
  • 1
  • 18
  • 46
Loading

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