473,386 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Another math problem...

Another math problem easier to solve by hand, but, IMHO, difficult to
program in a concise way like the solution of Bill Mill
(linalg_brute.py) to the problem of engsol.

I appreciated very much the Bill Mill's solution and that inspired in
a certain way the solution for my problem.

# Problem and solution:

# ab * cb = dab 35 * 26 = 936
# + + - + + -
# ifd + chg = eaf 179 + 258 = 437
# --------------- ---------------
# cih + cge = edd 215 + 284 = 499

From that you can get 6 equations:

# equation n. 1 : (10a+b) * ( 10c+b) = 100d+10a+b
# equation n. 2 : 100i+ f d + 100c+ h g = e+ a f
# equation n. 3 : c+ i h + c g e = e d d
# equation n. 4 : ( a b) + i f d = c i h
# equation n. 5 : ( c b) + c h g = c g e
# equation n. 6 : d+ a b - e a f = e d d

(I removed most of digit part to enhance the variables).

My solution:

def Hund(w): # hundreths
.. return int(w/100)
def Ten2(w): # tenths for 2 digits
.. return int(w/10)
def Ten(w): # tenths for 3 digits
.. return int((w%100)/10)
def Unit(w): # units
.. return w%10

nc = range(100,1000) # range of 3 digits numbers
nd = range(10,100) # range of 2 digits numbers

def eq_1():
.. return [(x,y,z) for x in nd \
.. for y in nd \
.. for z in nc \
.. if x*y-z == 0 \
.. and Unit(x) == Unit(y) \
.. and Unit(x) == Unit(z) \
.. and Ten2(x) == Ten(z) \
.. and Ten2(x) != Ten2(y) ]

lResult1=eq_1()
print lResult1

From the results you can choose other equations to treat with the same
approach.

I know it's a rather long process.. but that is the best I can do.
Jul 18 '05 #1
1 1275
Sorry, in writing down the problem and the corresponding solution, I
made a mistake. It's evident, but anyway...

Wrong:
# ab * cb = dab 35 * 26 = 936
# + + - + + -
# ifd + chg = eaf 179 + 258 = 437
# --------------- ---------------
# cih + cge = edd 215 + 284 = 499

Correct:
# ab * cb = dab 36 * 26 = 936
# + + - + + -
# ifd + chg = eaf 179 + 258 = 437
# --------------- ---------------
# cih + cge = edd 215 + 284 = 499

(wrong 35 correct 36)

Bye.
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Frank Millman | last post by:
Hi all I was helping my niece with her trigonometry homework last night. Her calculator's batteries were flat, so I thought I would use Python's math module to calculate sin, cos, and tan. I...
1
by: Reiner Apke | last post by:
Hello, I have got a very strange problem with the calcualtion of the the square root (Math.Sqrt()). I calculate in a loop a lot of of diameters maxDiameter = Math.Sqrt(maxCrossSection *...
5
by: Ark | last post by:
Hi everyone, Does anyone know if Direct3D overloads System.Math functions? Also is it possible to access the base functions of the overloaded function (in other words restore original of the...
6
by: ng_mr | last post by:
No, not a question about "banker's rounding" or whatever it's called. I want to round a double to the nearest 100th, so I perform the following: // original is a double double result =...
3
by: David Lozzi | last post by:
Howdy, ISSUE 1: See issue 2 below. I have a distance calculator on my site which works great. However, the users need to sort by distance, which make sense. I'm not sure how to do it other than...
11
by: Sambo | last post by:
I have the following module: ------------------------------- import math def ac_add_a_ph( amp1, ph1, amp2, ph2 ): amp3 = 0.0 ph3 = 0.0 ac1 = ( 0, 0j ) ac2 = ( 0, 0j )
8
by: Geoff Cox | last post by:
Hello, When using Internet Explorer, on networked PCs in a college, to view a page of mine with Javascript code in it the "stack overflow" error message appears. When I access the same file...
10
by: David Coleman | last post by:
I am running VS 2003 and have applied SP1. (On WinXP SP2, .Net 1.1) In the Command Window I get the following ? Math.Round(0.715, 2) 0.72 ? Math.Round(0.725, 2) 0.72 ? Math.Round(0.735, 2)...
4
by: =?Utf-8?B?UmVuZQ==?= | last post by:
Hello everyone I have a problem with Math.Round, it´s ocurring some strange: Math.Round(12.985) = 12.98, it´s wrong. It should be: 12.99 Why?? What is the problem? Help ME !!!!
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.