Click here to Skip to main content
15,917,652 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralRe: Substring Matching (Harder than it sounds) Pin
Luc Pattyn5-Sep-07 9:00
sitebuilderLuc Pattyn5-Sep-07 9:00 
GeneralRe: Substring Matching (Harder than it sounds) Pin
Skippums5-Sep-07 10:46
Skippums5-Sep-07 10:46 
GeneralRe: Substring Matching (Harder than it sounds) Pin
Member 419459329-Mar-08 9:55
Member 419459329-Mar-08 9:55 
QuestionNeed some intelligent people... Pin
Paddy Boyd29-Aug-07 2:20
Paddy Boyd29-Aug-07 2:20 
AnswerRe: Need some intelligent people... Pin
Luc Pattyn29-Aug-07 2:56
sitebuilderLuc Pattyn29-Aug-07 2:56 
GeneralRe: Need some intelligent people... Pin
Paddy Boyd29-Aug-07 3:42
Paddy Boyd29-Aug-07 3:42 
GeneralRe: Need some intelligent people... Pin
Paddy Boyd29-Aug-07 3:55
Paddy Boyd29-Aug-07 3:55 
GeneralRe: Need some intelligent people... Pin
Luc Pattyn29-Aug-07 4:42
sitebuilderLuc Pattyn29-Aug-07 4:42 
Hi Paddy,

there are several ways to find the solution(s) of ax+by=c.

First of all a single, linear equation in two variables has either no solution
at all (say 2x + 4y = 1) or an infinite number, by adding the second coefficient
to the first number and subtracting the first coef from the second number.
So the main problem is to find a first solution.

Method 1: write a little prog, assume x=u+bt and y=v-at and have it try a lot
of values u (keep t at 0) and calculate real v until it happens to be integer.

Method 2: follow the strict mathematical approach; that's what you would need
if decent code is required to solve such problems in general

Method 3: the way in-between, with a couple of shortcuts, the ideal way
to solve a single problem manually. Like so:

3125r = 1024x - 8404 with constraint r=multiple of 5

lets try to replace variables by other variables and reduce the size of the
constants:

right hand side is multiple of 4, hence r must be multiple of 20, say r=20a

3125 * 20a = 1024x - 8404

15625a = 256x - 2101

lets ignore all multiples of the smallest coef, 256

15625=61*256+9
-2101=-9*256+203

9a = 203 (modulo 256)

try a couple of numbers 203 + 256k until a multiple of 9 is found;
this is bound to happen in 9 tries !

one immediately sees a solution is a=(203+256)/9=51
(this is where the mathematician would go more formally !)

hence r=1020, then calculate the x that goes with it, and add one variable t
with the right coefs.

Smile | :)



Luc Pattyn [Forum Guidelines] [My Articles]


this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google


GeneralRe: Need some intelligent people... Pin
Paddy Boyd29-Aug-07 4:44
Paddy Boyd29-Aug-07 4:44 
AnswerRe: Need some intelligent people... Pin
Russell'29-Aug-07 4:54
Russell'29-Aug-07 4:54 
AnswerRe: Need some intelligent people... Pin
cp987629-Aug-07 16:18
cp987629-Aug-07 16:18 
GeneralRe: Need some intelligent people... Pin
Luc Pattyn29-Aug-07 23:41
sitebuilderLuc Pattyn29-Aug-07 23:41 
QuestionGenetic Algorithm Pin
starist26-Aug-07 4:58
starist26-Aug-07 4:58 
AnswerRe: Genetic Algorithm Pin
Russell'26-Aug-07 22:08
Russell'26-Aug-07 22:08 
QuestionCOMBINATION Pin
Heljeeve22-Aug-07 23:36
Heljeeve22-Aug-07 23:36 
AnswerRe: COMBINATION Pin
Giorgi Dalakishvili22-Aug-07 23:51
mentorGiorgi Dalakishvili22-Aug-07 23:51 
AnswerRe: COMBINATION Pin
Russell'23-Aug-07 0:04
Russell'23-Aug-07 0:04 
AnswerRe: COMBINATION Pin
Giorgi Dalakishvili24-Aug-07 12:03
mentorGiorgi Dalakishvili24-Aug-07 12:03 
QuestionCircle Drawing Algorith... Pin
himuskanhere21-Aug-07 23:18
himuskanhere21-Aug-07 23:18 
AnswerRe: Circle Drawing Algorith... Pin
cp987622-Aug-07 0:07
cp987622-Aug-07 0:07 
GeneralRe: Circle Drawing Algorith... Pin
himuskanhere22-Aug-07 1:32
himuskanhere22-Aug-07 1:32 
GeneralRe: Circle Drawing Algorith... Pin
cp987622-Aug-07 1:54
cp987622-Aug-07 1:54 
GeneralRe: Circle Drawing Algorith... Pin
El Corazon22-Aug-07 4:29
El Corazon22-Aug-07 4:29 
GeneralRe: Circle Drawing Algorith... Pin
Luc Pattyn22-Aug-07 5:18
sitebuilderLuc Pattyn22-Aug-07 5:18 
GeneralRe: Circle Drawing Algorith... Pin
El Corazon22-Aug-07 6:30
El Corazon22-Aug-07 6:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.