Click here to Skip to main content
15,898,643 members
Home / Discussions / Algorithms
   

Algorithms

 
AnswerRe: Contours / Isolines Pin
Alan Balkany19-Oct-10 4:08
Alan Balkany19-Oct-10 4:08 
QuestionPV, FV and IRR Calculation Pin
davjanks10-Oct-10 21:24
davjanks10-Oct-10 21:24 
AnswerRe: PV, FV and IRR Calculation Pin
Luc Pattyn11-Oct-10 1:29
sitebuilderLuc Pattyn11-Oct-10 1:29 
GeneralRe: PV, FV and IRR Calculation Pin
davjanks11-Oct-10 7:35
davjanks11-Oct-10 7:35 
GeneralRe: PV, FV and IRR Calculation Pin
Luc Pattyn11-Oct-10 8:07
sitebuilderLuc Pattyn11-Oct-10 8:07 
AnswerRe: PV, FV and IRR Calculation Pin
Ian Shlasko15-Oct-10 4:44
Ian Shlasko15-Oct-10 4:44 
QuestionFind an algorithm Pin
Not Active9-Oct-10 19:40
mentorNot Active9-Oct-10 19:40 
AnswerRe: Find an algorithm Pin
Luc Pattyn9-Oct-10 23:08
sitebuilderLuc Pattyn9-Oct-10 23:08 
Mark Nischalke wrote:
bool result = [What algorithm goes here];


I can not possibly tell you what the name is of what you want. What do you want? What fits there is a logic expression, probably one involving the object's state (no "static") and/or the input parameters.

BTW: it looks like a function, but doesn't return anything. A more natural set-up would be:

private void TestAll()
{
    Test(false, false, false, false, false, false, false);
    Test(false, false, false, false, true, true, true); 
    Test(false, false, false, false, true, false, false);
    Test(false, false, true, false, true, true, false);
    Test(false, false, true, true, true, true, true);
}

private bool Test(bool f, bool fl, bool d, bool dl, bool r, bool rl, bool expected)
{
    bool result=Logic(bool f, bool fl, bool d, bool dl, bool r, bool rl);
    bool OK=result==expected;
    System.Diagnostics.Debug.Assert(OK, "Test failed: "+f+f1+d+d1+r+r1+result+expected);
    return OK;
}

private bool Logic(bool f, bool fl, bool d, bool dl, bool r, bool rl, bool expected)
{
    bool result = ???;
    return result;
}


Assuming you meant a static function, one possible expression fitting the test vectors is:
bool mf = f==f1;
bool md = d==d1;
bool mr = r==r1;
bool result=mf && md && mr && (f||d||r);

but there are many more. In fact, your Logic function seems to have 64 different input combinations, each leading to some result, and only 5 test vectors have been defined, so 59 cases are undefined. If no (easy) expression is available, you can always implement a table look-up.

Smile | :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.


GeneralRe: Find an algorithm Pin
Not Active11-Oct-10 2:38
mentorNot Active11-Oct-10 2:38 
AnswerRe: Find an algorithm PinPopular
harold aptroot10-Oct-10 1:32
harold aptroot10-Oct-10 1:32 
GeneralRe: Find an algorithm Pin
Not Active10-Oct-10 4:34
mentorNot Active10-Oct-10 4:34 
GeneralRe: Find an algorithm Pin
harold aptroot10-Oct-10 4:39
harold aptroot10-Oct-10 4:39 
AnswerRe: Find an algorithm Pin
lepipele10-Oct-10 19:24
lepipele10-Oct-10 19:24 
AnswerRe: Find an algorithm Pin
Member 419050110-Oct-10 21:01
Member 419050110-Oct-10 21:01 
GeneralRe: Find an algorithm Pin
Not Active11-Oct-10 2:03
mentorNot Active11-Oct-10 2:03 
GeneralRe: Find an algorithm Pin
Luc Pattyn11-Oct-10 3:06
sitebuilderLuc Pattyn11-Oct-10 3:06 
GeneralRe: Find an algorithm Pin
parth.p11-Oct-10 5:27
parth.p11-Oct-10 5:27 
GeneralRe: Find an algorithm Pin
Luc Pattyn11-Oct-10 5:46
sitebuilderLuc Pattyn11-Oct-10 5:46 
AnswerRe: Find an algorithm [modified] Pin
R. Erasmus10-Oct-10 23:01
R. Erasmus10-Oct-10 23:01 
GeneralRe: Find an algorithm Pin
Luc Pattyn11-Oct-10 1:30
sitebuilderLuc Pattyn11-Oct-10 1:30 
AnswerRe: Find an algorithm Pin
grgran11-Oct-10 4:59
grgran11-Oct-10 4:59 
GeneralRe: Find an algorithm Pin
Luc Pattyn11-Oct-10 5:04
sitebuilderLuc Pattyn11-Oct-10 5:04 
GeneralRe: Find an algorithm Pin
grgran11-Oct-10 5:32
grgran11-Oct-10 5:32 
GeneralRe: Find an algorithm Pin
Not Active11-Oct-10 7:20
mentorNot Active11-Oct-10 7:20 
GeneralRe: Find an algorithm Pin
grgran11-Oct-10 10:54
grgran11-Oct-10 10:54 

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.