Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!

Problem 1081. Test if two numbers have the same digits

Created by @bmtran

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


    x1 = 1234;
    x2 = 1244;
    tf = same_digits(x1,x2)

would output

    tf = false


Problem Group

Solution Statistics

95 correct solutions 90 incorrect solutions
Last solution submitted on Jul 19, 2016

Problem Comments