473,885 Members | 2,419 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.p y) 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) ]

print lResult1

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

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

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

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

(wrong 35 correct 36)

Jul 18 '05 #2

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

Similar topics

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 tried the example in the text book first, to ensure that I was getting the correct result, but it did not agree. Then my wife had the idea of using the Microsoft calculator in scientific mode, and that one did give the correct result.
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 * 4.00 / Math.PI); minDiameter = Math.Sqrt(minCrossSection * 4.00 / Math.PI);
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 overlaoded function)? Thank you
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 = Math.Round( original, 2 ); But I'm not happy with the results. E.g. if original is
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 like this. With the returning query include the distance from origin. Here's my dilemma, I have the script working great in VB which provides the distance, but that is not sortable, but when I port it over to TSQL I get differing results. Here is the...
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 )
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 from my home PC no such message. Is it possible for this to be caused by any IE setting?
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) 0.74
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 !!!!
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.