git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Help? How do i solve this problem with Python List Concept


On 2019-05-11 22:02:39 +0100, Ben Bacarisse wrote:
> Donald Tripdarlinq <tripdarlinq at gmail.com> writes:
> > In the traditional Yoruba tribal Set-Up in Nigeria,West Africa the
> > tradition of inheritance is very important. Now, The relative position
> > of a child in the family counts when the issue of inheritance is
> > considered.
> >
> > Question: Now a farmer with 10 children died without leaving a will
> > and the Family "Ebi"(Which consist of the extended family) decided
> > that the property would be in proportion of their respective age. The
> > Children were born with 3 years intervals except the second to last
> > and the last born with the interval of 2 and 4 years respectively. Use
> > the concept of list to write a simple python program to generate the
> > individual children inheritance if the man left N230,000 Before his
> > death
> 
> You need a little more than that.  If the inheritance is to be in
> proportion to the ages, you need to know at least one actual age, rather
> than just the age gaps.

The iron law of school maths problems says that all problems must have a
nice solution. This usually means something like ? or e, but in this
case we'll just settle for integers. 

So the sum of the ages of the children must be a divisor of 230000.

We can easily work out that the sum must be
10n + 9*4 + 8*2 + (7 + 6 + 5 + 4 + 3 + 2 + 1) * 3
(the details are left as an exercise for the reader) and we can
therefore compute the age of the youngest child:

#!/usr/bin/python3

def f():
    n = 0
    while True:
        s = 10 * n + 136
        if 230000 % s == 0:
            print(n)
        if s > 230000:
            return
        n += 1
f()

This immediately returns an empty result. Which means that there is an
error in the problem statement. Finding the teacher's mistakes is of
course every students favourite pastime and teachers try to please their
students by making trivial mistakes, like swapping two numbers. And
indeed, if we swap the age gaps between the youngest children, we get
nice round numbers:

The youngest child is 5, the oldest 32, and the divisor is 1250.
So the youngest inherits 6250 NGN, the oldest 40000 NGN, and the rest
are trivial to compute.

You owe the Oracle a first print of "Rechnung auff der Linihen und
Federn" and the first-born of a Nigerian princess. 

        hp

-- 
   _  | Peter J. Holzer    | we build much bigger, better disasters now
|_|_) |                    | because we have much more sophisticated
| |   | hjp at hjp.at         | management tools.
__/   | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20190514/1e30d29d/attachment.sig>