# How many dogs of Oxford are there?

The dogs of Oxford, I declare:
Numbered one third of a square.
If one quarter left to roam,
Just a cube would stay at home.

What is the smallest possible number of dogs in Oxford?

This is a relatively easy question so I would recommend the more experienced solvers leave this question for new puzzlers.

Edit for attribution - I found this riddle here. Minor wording tweaks for cadence.

• What a lovely puzzle! I had fun solving it. I am not a new puzzler so I won’t post an answer now. Based on the wording of the puzzle and the reference to Oxford, I suspect that this might be a very old puzzle (maybe several decades old). Oct 25 at 4:56
• Surely I count as a newish puzzler? Oct 25 at 6:06
• @Randal'Thor I have no opinion on whether or not the OP would consider Stevo as new or not. I consider myself not a new puzzler because I have been solving puzzles for many decades before joining Puzzling Stack Exchange. Cheers! Oct 25 at 19:36
• @TobySpeight: I’m pretty sure this is original, or at least a recent imitation of a Carrollesque riddle, not a Carrollian or other Victorian original. Partly because I just googled it and found no results, but before that, because the scansion is a bit awkward — not terrible by any means, but not up to the baseline doggerel of well-educated nineteenth-century Brits, and certainly well below Carroll’s standard. Oct 26 at 22:22
• @PeterLeFanuLumsdaine In an earlier version, instead of dogs in Oxford, they are cats in Randwick, and the meter is different. Oct 27 at 22:12

I'll assume that any fractional dogs count as an entire animal for the purpose of this answer.

The dogs of Oxford, I declare:
Numbered one third of a square.

So we know

The number of dogs must be a multiple of three (because 3 is not a square number, so any square with three as a factor must be a multiple of 9).

If one quarter left to roam,

The number of dogs must be a multiple of 4.
Consequently, we only need consider multiples of 12 for the answer, given it's also a multiple of 3.

Just a cube would stay at home.

¾ of the number forms a perfect cube.
This cube must be a multiple of 9, since the number of dogs is a multiple of 12.

So, let's iterate over the possibilities, starting with

9³ + ⅓9³

Is this one-third of a square number? If we multiply this by 3, we get

4 ✕ 9³ = 2²·9⁶

As the powers are all even, then this is the smallest solution to the problem:

9³ + ⅓9³ = 9 ✕ 9 ✕ 12 = 972

• Accepting this one as the first complete answer (To the best of my understanding) Oct 25 at 21:36
• "Let's iterate over the possibilities, starting with ..." I think you could consider 3³ + ⅓3³ here ? Oct 26 at 11:46
• I think this is posted after Stevo's answer though. Oct 26 at 13:38

The smallest possible number of dogs is

0 🤓
because its 1 third of a square (0^2), and 3 quarters of a cube (0^3)

padding this spoiler out so it looks like there's more maths in it for people who haven't clicked the spoiler yet.

• Beautiful. Absolutely wonderful. Oct 25 at 19:16
• Haha, very funny. Technically correct I guess Oct 25 at 21:28
• If you upvote this answer be sure to give the other answers an upvote, too. Oct 26 at 6:00

If $$x$$ is the integer number of dogs, then

$$3x$$ is a square and $$\frac{3}{4}(x) = 3x/4$$ is a cube.

Now $$3x$$ is a square and $$4$$ is also a square. When a square is divided by another square, the answer is still a square. Therefore the amount of dogs left is not only a square, but also a cube.

Therefore it must be a 6th power, to be able to have a square root and a cube root. It also needs to be divisible by 3 (4%%4/3%%). The smallest such value is $$3^6$$. Note $$2^6$$ cannot be divisible by 3; prime factorisation can be left as an exercise to the reader.

That equals $$729$$, so reversing the operation, the number of dogs in Oxford is $$\frac{4}{3}\times729 = 972$$.

• A nice approach, but there's something I'm not following. How is the smallest 6th power $3^6$ ? How about $2^6$ ? Oct 25 at 21:27
• It needs to be divided by 3. @ApexPolenta, therefore $$3^6$$ Oct 26 at 1:41
• Nice. Intuitively understandable for even a math ignoramus like me, taught me a handy new rule of thumb, and has almost no iterating values (other than checking 2^6, unless there's some other rule of thumb that can exclude that without checking 64 for divisibility by 3). Can also be used to find or validate non-minimal answers, too. Oct 26 at 8:01
• 2^6 cannot be divded by 3 (2 * 2 * 2 * 2 * 2 * 2) leaves nothing to be divisible by 3, as 2 is a prime factor. @DewiMorgan Oct 26 at 8:08
• @DewiMorgan indeed! And you've discovered the fundamental theorem of arithmetics! :D Oct 27 at 7:50

I really liked this! Was interested by the title and clicked through from another site. Never done a puzzle before (nor posted to stack exchange) and normally just click the spoilers to see the answers.

Wrote some dirty code that I'll put below.

Was expecting the answer to be enormous, so optimised early by starting from the cube and reversing to see if it's a valid number of dogs.

for i in range(1, 99999):
at_home = i ** 3
dogs = at_home * 4 / 3
if dogs != int(dogs): continue
unsquared = (dogs * 3) ** (1 / 2)
if unsquared == int(unsquared):
print(dogs)
break


Spits out 972, or 0 if you start the loop from 0! (I have personally seen at least one dog in Oxford, so know this cannot be the solution)

• I like your reasoning that zero is not a possible solution. Oct 25 at 19:46
• Glad you enjoyed, I hope you stick around Oct 25 at 22:40
• You must have found 62208 also then? Since you've checked up to 99998. Oct 26 at 13:40
• @BenjaminWang Actually the code should produce all answers up to $\frac{4}{3}99999^3$. It breaks after finding one though, so as posted it will only produce the first Oct 26 at 22:49

Just for fun, here's the approach I took from the perspective of prime factors. I will use the notation $$a|b$$ to denote $$a$$ being divisible by $$b$$. All variables are integers.

From the first couplet,

The number of dogs is $$\frac{1}{3}$$ of a square, so $$d=\frac{n^2}{3}$$. Since $$n^2|3$$, $$n|3$$.

From the second couplet,

$$d|4$$, so $$\frac{n^2}{3}|4$$, so $$n|2$$.

From these divisibility statements,

$$n=2^x3^y$$ (times other primes, optionally, but the smallest answer doesn't include these).

Using the relationship between $$d$$ and $$n$$,

$$d=\frac{n^2}{3}=2^{2x}3^{2y-1}$$.

Multiplying by three quarters increases the index on $$3$$ by $$1$$ and decreases the index on $$2$$ by $$2$$, so $$\frac{3d}{4} = 2^{2x-2}3^{2y}$$ and this value must be a cube (implying all indices are multiples of $$3$$). Also, it must be divisible by $$3$$ (implying $$y\neq0$$).

Solutions to the above are

$$x=3X+1$$ and $$y=3Y$$, where $$Y\geq1$$. The minimal values are $$X=0$$ and $$Y=1$$, corresponding to $$\frac{3d}{4}=2^03^6=729$$.

Then the number of dogs is

$$\frac{4}{3}729 = 972$$.

This approach also allows generation of more answers. For example

The next answer at $$X=Y=1$$ generates $$d=62208$$.

Wow, I interpreted this question in an entirely different way than everyone else.

The dogs of Oxford, I declare: Numbered one third of a square.

I interpreted this to mean not a square number, but the four-sided polygon. We must assign a number to "a square," and then the number of dogs will be one third of that.

Let's say D is the number of dogs, and S is the number assigned to a square.

D = 1/3 * S

If one quarter left to roam, Just a cube would stay at home.

A cube (C) is comprised of six square faces, so a cube is six squares.

C = 6 * S

This tells us that one fourth of the total number of dogs plus six times the number of dogs equals the total number of dogs:

D = 1/4 * D + 6 * D

At this point things are looking weird, so I started looking at answers and discovered that my interpretation was likely not the intended one, but let's run with it anyway. That last one simplifies down to:

D = 6.25D, and we all know there's exactly one solution to that: D = 0.

That leaves the first two equations irrelevant unless one wants to know the values of the square and/or cube:

Both also zero.

What is the smallest possible number of dogs in Oxford?

Zero.
Of course, the question implies that there should be multiple solutions, and in this case there is only the one. It's also a bit disappointing; there should be nonzero dogs in Oxford because dogs are awesome. All of this points to my interpretation of the question being incorrect, but I thought my mistake was amusing and figured I'd share. It might've helped if I had noticed the mathematics tag. 😅

By a chain of divisibility rules:

Let $$d_1$$ be the number of dogs (a positive integer - though I was going to write zero as a cheeky answer until I saw someone else had done before me!), so the question statement is finding the smallest $$d_1$$ such that $$d_1 = x_1^2/3$$ and $$3d_1/4 = y_1^3$$ for integer $$x_1$$ and $$y_1$$.

Rewrite the equations as $$3d_1 = x_1^2$$ and $$3d_1 = 4y_1^3$$. We will consider the divisibility of $$x_i$$ and $$y_i$$ first, and then $$d_i$$. Clearly $$x_1$$ and $$y_1$$ are both divisible by three, so write $$x_1 = 3x_2$$ and $$y_1 = 3y_2$$. The equations become $$d_1 = 3x_2^2$$ and $$d_1 = 36y_2^2$$, so we can put $$d_1 = 36d_2$$.

The equations are now $$36d_2 = 3x_2^2$$ and $$36d_2 = 36y_2^2$$, which simplify to $$12d_2 = x_2^2$$ and $$d_2 = y_2^2$$. Now we repeat the process. Since $$x_2^2$$ has a factor of $$12 = 2^2 \times 3$$, we know $$x_2$$ must have factor $$2 \times 3 = 6$$. So put $$x_2 = 6x_3$$, and hence $$d_2 = (6^2/12) x_3^2 = 3x_3^2$$. We don't learn much about $$y_2$$ from $$d_2 = y_2^2$$ so I'll keep $$y_3 = y_2$$. But from $$d_2 = 3x_3^2$$ we can put $$d_2 = 3d_3$$.

Putting this in and simplifying, our equations are $$d_3 = x_3^2$$ and $$3d_3 = y_3^3$$. So $$y_3 = 3y_4$$ and $$d_3 = 9y_4^3$$. We put $$d_4 = 9d_3$$ since it must be divisible by nine. But then $$9d_4 = x_3^2$$ so we see $$x_3$$ must be divisible by three, hence $$x_4 = 3x_3$$.

At this stage our equations are $$d_4 = x_4^2$$ and $$d_4 = y_4^3$$. We want $$d_4$$ to be the smallest positive integer that is both square and cube, so let's take $$d_4 = x_4 = y_4 = 1$$. But if we wanted all solutions, not just the smallest, we would $$d^4$$ to be any sixth power (since it must be both a square and a cube) and then $$x_4 = \sqrt{d_4}$$ and $$y_4 = \sqrt[3]{d_4}$$

Finally we work back to the original variables: $$d_1 = 36 \times 3 \times 9 \times d_4 = 972d_4$$, $$x_1 = 3 \times 6 \times 3 \times x_4 = 54x_4$$ and $$y_1 = 3 \times 1 \times 3 \times y_4 = 9y_4$$. The smallest solution is $$972$$ dogs, which is indeed one third of $$54^2$$, and three quarters of it is $$729$$ which is $$9^3$$.

Where x is the number of dogs.

$$x \in \mathbb{N}+ \\ \left\{ \begin{array}{c} x=\frac{1}{3}x^2 | \times (\frac{-3}{4}) \\ \frac{3}{4}x=x^3 \end{array} \right.$$ $$\left\{ \begin{array}{c} \frac{-3}{4}x=\frac{-1}{4}x^2 \\ \frac{3}{4}x=x^3 \end{array} \right.$$ $$0 = x^3-\frac{1}{4}x^2$$ $$x^2(x-\frac{1}{4}) = 0$$ $$x= 0 \vee x=\frac{1}{4}\notin \mathbb{N+}$$ $$x= 0$$

• I think you've gone wrong early in your answer - $\frac{3x}{4}$ is a cube, but it is not equal to $x^3$. Oct 26 at 22:46