PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, July 20, 2022

[FIXED] How can I check if a 2 numbers have the same digits PowerShell?

 July 20, 2022     comparison, integer, powershell     No comments   

Issue

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


Solution

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.



Answered By - boxdog
Answer Checked By - Mildred Charles (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing