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

Fixed the problem
Source Link
celtschk
  • 4.7k
  • 2
  • 24
  • 21

Wolfram Language (Mathematica), (削除) 33 (削除ここまで) 26(削除) 26 (削除ここまで) 31 bytes

Fixed an error noted by Kelly Lowder in the comments.

x/.{}⋃Solve[#==0,x,Integers]&

Try it online!

Previous incorrect solutions:

I just noticed that for no integer solution, the output is undefined instead of empty list; that allows to remove a few bytes.

x/.Solve[#==0,x,Integers]&

Try it online!

Now if no integer solution exists, the function returns x.

Previously:

x/.Solve[#==0,x,Integers]/.x->{}&

Try it online!

Wolfram Language (Mathematica), (削除) 33 (削除ここまで) 26 bytes

I just noticed that for no integer solution, the output is undefined instead of empty list; that allows to remove a few bytes.

x/.Solve[#==0,x,Integers]&

Try it online!

Now if no integer solution exists, the function returns x.

Previously:

x/.Solve[#==0,x,Integers]/.x->{}&

Try it online!

Wolfram Language (Mathematica), (削除) 33 (削除ここまで) (削除) 26 (削除ここまで) 31 bytes

Fixed an error noted by Kelly Lowder in the comments.

x/.{}⋃Solve[#==0,x,Integers]&

Try it online!

Previous incorrect solutions:

I just noticed that for no integer solution, the output is undefined instead of empty list; that allows to remove a few bytes.

x/.Solve[#==0,x,Integers]&

Try it online!

Now if no integer solution exists, the function returns x.

Previously:

x/.Solve[#==0,x,Integers]/.x->{}&

Try it online!

added 520 characters in body
Source Link
celtschk
  • 4.7k
  • 2
  • 24
  • 21

Wolfram Language (Mathematica), 33(削除) 33 (削除ここまで) 26 bytes

I just noticed that for no integer solution, the output is undefined instead of empty list; that allows to remove a few bytes.

x/.Solve[#==0,x,Integers]&

Try it online!

Now if no integer solution exists, the function returns x.

Previously:

x/.Solve[#==0,x,Integers]/.x->{}&

Try it online!

Wolfram Language (Mathematica), 33 bytes

x/.Solve[#==0,x,Integers]/.x->{}&

Try it online!

Wolfram Language (Mathematica), (削除) 33 (削除ここまで) 26 bytes

I just noticed that for no integer solution, the output is undefined instead of empty list; that allows to remove a few bytes.

x/.Solve[#==0,x,Integers]&

Try it online!

Now if no integer solution exists, the function returns x.

Previously:

x/.Solve[#==0,x,Integers]/.x->{}&

Try it online!

Source Link
celtschk
  • 4.7k
  • 2
  • 24
  • 21

Wolfram Language (Mathematica), 33 bytes

x/.Solve[#==0,x,Integers]/.x->{}&

Try it online!

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