Skip to content

Instantly share code, notes, and snippets.

@LaurentTreguier
Last active February 3, 2016 12:12
Show Gist options
  • Select an option

  • Save LaurentTreguier/6f10d79ddad480ffd857 to your computer and use it in GitHub Desktop.

Select an option

Save LaurentTreguier/6f10d79ddad480ffd857 to your computer and use it in GitHub Desktop.
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment