LaurentTreguier
2/2/2016 - 11:00 PM

Computes the smallest positive integer which digits are the same ones as its double, but shuffled

Computes the smallest positive integer which digits are the same ones as its double, but shuffled

import std.algorithm;
import std.array;
import std.conv;
import std.stdio;

int main(string[] args)
{
    int n;
    byte[] number;
    byte[] twice;

    do
    {
        ++n;
        number = cast(byte[])n.to!(char[]);
        twice = cast(byte[])(n * 2).to!(char[]);
    }
    while (number.sort() != twice.sort());

    writeln(n);

    return 0;
}