#julialang

mc@iviv.hu

You may know by now that I like I'm addicted to solve math puzzles. I even published a book about it. Only the first volume of it, to be more precise. But do not despair, the second volume is coming quickly. :-)
With more classical #puzzles. Here's a teaser (and a #challenge):

Two Spherical Phials

The problem that the Doctor propounded to the assembled pilgrims was this. He produced two spherical phials, (...), and pointed out that one phial was exactly a foot in circumference, and the other two feet in circumference.

"I do wish," said the Doctor, addressing the company, "to have the exact measures of two other phials, of a like shape but different in size, that may together contain just as much liquid as is contained by these two." (...). Of course the thickness of the glass, and the neck and base, are to be ignored.

The Two Spherical Phials is the same that The Puzzle of the Doctor of Physic by H. Dudeney, with the wording shortened.

Two solutions are presented, taking into account the use of means not available when Henry Dudeney wrote the puzzle:

  1. Considering the precision allowed by Julia programming language we get only one result.
function twosphericvols1()
    for d1 in 1.0:0.1:3.0
        for d2 in 1.0:0.1:3.0
            if (d1^3*pi)+(d2^3*pi) == 28.274333882308138 && [d1,d2] != sort([d1,d2]) 
                println("Radius of the bigger phial: ",d1)
                println("Radius of the smaller phial: ",d2)
                println("The 2 phials total volume: ",(d1^3*pi)+(d2^3*pi))
            end
        end
    end
end

#> twosphericvols1()
Radius of the bigger phial: 2.0
Radius of the smaller phial: 1.0
The 2 phials total volume: 28.274333882308138

.
Now, here's the challenge.

  1. Using a rounded value of the total volume we get three possible results.
# I'll put here my solution (in Julia) soon. :-)

It can be done just just by changing 2 little details in 1 line of the Julia code.

Note: You can, of course, use another programming language to write the solution.

#math #classical #puzzle #invitation #teaser #programming #code #julialang