3
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ 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) $\endgroup$ – Joel Rondeau Sep 25 '18 at 16:16
2
$\begingroup$

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");
ReadKey();

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
            vals.Add(c, 1);
    }
    return vals;
}
$\endgroup$
  • $\begingroup$ How does rearranging the digits make 1 or 9? The only digit is 3. $\endgroup$ – Alto Sep 25 '18 at 16:22
  • $\begingroup$ 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 $\endgroup$ – PerpetualJ Sep 25 '18 at 16:23
  • $\begingroup$ Okay, I see. [extra text] $\endgroup$ – Alto Sep 25 '18 at 16:25
  • $\begingroup$ @Alto I see that I didn't understand the requirements fully when I gave my initial answer; I've corrected. $\endgroup$ – PerpetualJ Sep 25 '18 at 16:45
  • 1
    $\begingroup$ You seem to grab a 9 out of nowhere for your triple. $\endgroup$ – TheMadHaberdasher Sep 25 '18 at 16:47
1
$\begingroup$

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

My first answer

0. But, I'm assuming that you meant to specify 'positive' integer.

My second answer (I cheated by using fractions)

1

3 => (27 / 4) / (9 / 4)
1 => (94 / 47) / 2
1 / 3 => (9 / 4) / (27 / 4)

$\endgroup$
  • $\begingroup$ What? How did you see that? $\endgroup$ – Alto Sep 26 '18 at 0:18
  • $\begingroup$ Honestly I think I got lucky! I had the idea to try fractions but I was having difficulty with getting the triple, and then I tried those numbers and it actually worked. $\endgroup$ – obl Sep 26 '18 at 4:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.