Problem 1081. Test if two numbers have the same digits
Given two integers x1 and x2, return true if the numbers written with no leading zeros contain the same digits. That is, the string representation of one number is a permutation of the string representation of the other.
For example
x1 = 1234; x2 = 4321; tf = same_digits(x1,x2)
would output
tf = true
whereas
x1 = 1234; x2 = 1244; tf = same_digits(x1,x2)
would output
tf = false
Solution Stats
Problem Comments
-
1 Comment
Freddy
on 29 Jan 2013
May you add some testcases concerning that ~mod(63-45,9) = true, but 63 and 45 has definitely not the same digits.
Solution Comments
Show commentsProblem Recent Solvers243
Suggested Problems
-
218 Solvers
-
Program an exclusive OR operation with logical operators
716 Solvers
-
Make a random, non-repeating vector.
9273 Solvers
-
Find the index of the largest value in any vector X=[4,3,4,5,9,12,0,4.....5]
378 Solvers
-
Convert given decimal number to binary number.
2070 Solvers
More from this Author56
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!