Find an algorithm
-
incorrect, none of the test cases have (f||f1) true. :|
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.
result = ((f&&f1) || (d&&d1) || (r&r1)) && (f==f1) && (d==d1) && (r==r1);
-
I've probably been staring at this far too long but I can't find an algorithm that will return the correct results for the code below. Anyone have some fresh ideas?
private void Test()
{
Logic(false, false, false, false, false, false, false);
Logic(false, false, false, false, true, true, true);
Logic(false, false, false, false, true, false, false);
Logic(false, false, true, false, true, true, false);
Logic(false, false, true, true, true, true, true);
}private void Logic(bool f, bool fl, bool d, bool dl, bool r, bool rl, bool expected)
{
bool result = [What algorithm goes here];System.Diagnostics.Debug.Assert(result == expected, "Does not match expected results");
}
I know the language. I've read a book. - _Madmatt
Is it simply the number of TRUE arguments passed? No TRUE args ==> FALSE even no of TRUE args ==> TRUE Otherwise ==> FALSE :confused: Tadeusz Westawic Sum quid sum.
-
I've probably been staring at this far too long but I can't find an algorithm that will return the correct results for the code below. Anyone have some fresh ideas?
private void Test()
{
Logic(false, false, false, false, false, false, false);
Logic(false, false, false, false, true, true, true);
Logic(false, false, false, false, true, false, false);
Logic(false, false, true, false, true, true, false);
Logic(false, false, true, true, true, true, true);
}private void Logic(bool f, bool fl, bool d, bool dl, bool r, bool rl, bool expected)
{
bool result = [What algorithm goes here];System.Diagnostics.Debug.Assert(result == expected, "Does not match expected results");
}
I know the language. I've read a book. - _Madmatt
( ( d && dl ) && ( r && rl ) ) || ( (d && dl) && ( !r && !rl) ) || ( (!d && !dl) && ( r && rl ) )
I wasn't, now I am, then I won't be anymore.
-
Is it simply the number of TRUE arguments passed? No TRUE args ==> FALSE even no of TRUE args ==> TRUE Otherwise ==> FALSE :confused: Tadeusz Westawic Sum quid sum.
What are you confused about? Perhaps you are confused that the problem had been solved 18 days ago by people how were not confused.:confused:
I know the language. I've read a book. - _Madmatt
-
( ( d && dl ) && ( r && rl ) ) || ( (d && dl) && ( !r && !rl) ) || ( (!d && !dl) && ( r && rl ) )
I wasn't, now I am, then I won't be anymore.
Only 18 days after everyone else. Glad it wasn't urgentz
I know the language. I've read a book. - _Madmatt
-
What are you confused about? Perhaps you are confused that the problem had been solved 18 days ago by people how were not confused.:confused:
I know the language. I've read a book. - _Madmatt
There are unanswered posts of my own that are months old and I would still appreciate any other point of view as long as it is mathematically valid and programmable. Are you saying my post is illegal? Take off that heavy badge once in a while. Tadeusz Westawic Sum quid sum.
-
Only 18 days after everyone else. Glad it wasn't urgentz
I know the language. I've read a book. - _Madmatt
:laugh: I didn't even notice that. Man, do I suck... :-D
I wasn't, now I am, then I won't be anymore.
-
There are unanswered posts of my own that are months old and I would still appreciate any other point of view as long as it is mathematically valid and programmable. Are you saying my post is illegal? Take off that heavy badge once in a while. Tadeusz Westawic Sum quid sum.
Tadeusz Westawic wrote:
There are unanswered posts of my own
There is the difference. This post was answered by several people quite a long time ago.
Tadeusz Westawic wrote:
Are you saying my post is illegal?
losen up and perhaps vist more often
I know the language. I've read a book. - _Madmatt
-
I've probably been staring at this far too long but I can't find an algorithm that will return the correct results for the code below. Anyone have some fresh ideas?
private void Test()
{
Logic(false, false, false, false, false, false, false);
Logic(false, false, false, false, true, true, true);
Logic(false, false, false, false, true, false, false);
Logic(false, false, true, false, true, true, false);
Logic(false, false, true, true, true, true, true);
}private void Logic(bool f, bool fl, bool d, bool dl, bool r, bool rl, bool expected)
{
bool result = [What algorithm goes here];System.Diagnostics.Debug.Assert(result == expected, "Does not match expected results");
}
I know the language. I've read a book. - _Madmatt
private void Logic( bool f1, bol f2, bool f3, bool f4, bool f5, bool f6, bool expected)
{
bool result = ((!f1) && (!f2) && f5 && f6 && ( ((!f3) && (!f4)) || ( f3 && f4 )));
System.Diagnostics.Debug.Assert( result == expected, "Does not match expected results" );
} -
I've probably been staring at this far too long but I can't find an algorithm that will return the correct results for the code below. Anyone have some fresh ideas?
private void Test()
{
Logic(false, false, false, false, false, false, false);
Logic(false, false, false, false, true, true, true);
Logic(false, false, false, false, true, false, false);
Logic(false, false, true, false, true, true, false);
Logic(false, false, true, true, true, true, true);
}private void Logic(bool f, bool fl, bool d, bool dl, bool r, bool rl, bool expected)
{
bool result = [What algorithm goes here];System.Diagnostics.Debug.Assert(result == expected, "Does not match expected results");
}
I know the language. I've read a book. - _Madmatt
yeah I know it was answered a while ago but here is a slightly more elegant algorithm
bool result = (f == fl) && (d == dl) && (r == rl) ? f | d | r : false;
or in a less descriptive formbool result = f == fl && d == dl && r == rl && f | d | r;
modified on Tuesday, November 9, 2010 6:28 PM
-
yeah I know it was answered a while ago but here is a slightly more elegant algorithm
bool result = (f == fl) && (d == dl) && (r == rl) ? f | d | r : false;
or in a less descriptive formbool result = f == fl && d == dl && r == rl && f | d | r;
modified on Tuesday, November 9, 2010 6:28 PM
Such a timely response :rolleyes:
I know the language. I've read a book. - _Madmatt
-
Such a timely response :rolleyes:
I know the language. I've read a book. - _Madmatt
-
Robert Croll wrote:
Well I teach at college
What course do you teach, procrastination?
I know the language. I've read a book. - _Madmatt
-
Robert Croll wrote:
Well I teach at college
What course do you teach, procrastination?
I know the language. I've read a book. - _Madmatt