Home > Software engineering >  How can I check if a 2 numbers have the same digits PowerShell?
How can I check if a 2 numbers have the same digits PowerShell?

Time:01-20

I want to compare two int so if they contain the same digits it outputs a true,for example:

$a=1260
$b=2106

and then because both of them contain: 0126 it outputs true how can this be made? And if it's possible with the fewest possible lines

CodePudding user response:

Here's one technique:

$null -eq (Compare-Object -ReferenceObject ([char[]][String]1260) -DifferenceObject ([char[]][String]2601))

Which returns true or false, depending on if the digits are the same or not.

  •  Tags:  
  • Related