# Third and Triple

This is inspired from Half and Double Value. Please see that puzzle, too.

Okay, so now you're really bored.

A good puzzle wastes time, so you make one.

Try to find the smallest number, that, when you rearrange the digits, it can triple or third.

$$update -$$ I meant the 2 NEW numbers are a third and triple of the original number.

Bonus for anyone who does this with logic.

• It takes @ngn 's program a lot longer to do this than half and double. (Not posting the answer because no logic was used and I literally just stole all his work) – Joel Rondeau Sep 25 '18 at 16:16

If I understand it correctly:

$$31046895$$. When divided by three it becomes $$10348965$$ and when multiplied by three it becomes $$93140685$$.

As with the previous riddle that you linked, I wrote a lazy brute force in C# to solve it. It took roughly 45 seconds to perform all of the needed calculations. I could refactor this, but meh.

for (int i = 0; i < int.MaxValue; i++) {
if (contains(i)) {
WriteLine(i);
break;
}
}
WriteLine("Done");

static bool contains(int i) {
Dictionary<char, int> ivals = getVals(i);
Dictionary<char, int> tdvals = getVals(i / 3);
Dictionary<char, int> tpvals = getVals(i * 3);

if (i.ToString().Length != (i / 3).ToString().Length ||
i.ToString().Length != (i * 3).ToString().Length)
return false;

foreach (char c in ivals.Keys) {
if (!tdvals.ContainsKey(c)) return false;
else if (tdvals[c] != ivals[c]) return false;

if (!tpvals.ContainsKey(c)) return false;
else if (tpvals[c] != ivals[c]) return false;
}

WriteLine($$"third {i / 3}"); WriteLine($$"triple {i * 3}");
return true;
}
static Dictionary<char, int> getVals(int i) {
Dictionary<char, int> vals = new Dictionary<char, int>();
foreach (char c in i.ToString()) {
if (vals.ContainsKey(c))
vals[c]++;
else
}
return vals;
}

• How does rearranging the digits make 1 or 9? The only digit is 3. – Alto Sep 25 '18 at 16:22
• 3 rearranged is 3. It's a technical answer, as I said; I'll be giving another answer in a bit as I am working on it lol – PerpetualJ Sep 25 '18 at 16:23
• Okay, I see. [extra text] – Alto Sep 25 '18 at 16:25
• @Alto I see that I didn't understand the requirements fully when I gave my initial answer; I've corrected. – PerpetualJ Sep 25 '18 at 16:45
• You seem to grab a 9 out of nowhere for your triple. – TheMadHaberdasher Sep 25 '18 at 16:47

My answers are probably breaking the rules, but here goes.