I need some help with a simple problem involving the basic logical operators: AND, OR, and NOT, along with the relational operator EQUAL TO, and truth values TRUE and FALSE.
Let's assume that we have a function tD() that tests whether 3 integers are all different. So, tD( 1, 2, 2 ) will return FALSE, and tD( 6, 6, 6 ) will return TRUE.
Now, my problem is to define a function the uses the above to determine whether or not 4 integers are equal. Let's call it
bool fE( a, b, c, d )
defined completely in terms of
bool tD( a, b, c)
and the aforementioned operators.
you can write in any code you prefer.
please explain tD again.
>>2
tD() returns TRUE
if the 3 integers are equal and FALSE
if they are unequal.
bool fE(a, b, c, d) =
tD(a, b, c) == tD(a, b, d) == TRUE
>>2
sorry about that, td( 6, 6, 6 ) would return FALSE, not TRUE.
td() tests whether three integers are all different.
td( 1, 2, 1 ) returns FALSE
td( 2, 3, 5 ) returns TRUE
>>3
no, td returns TRUE if 3 integers are all different
and FALSE if any of them are equal.
again, my fault for the confusion.
>>5
Ok then, now it makes more sense
tD(a, b, c) =
!(((a & b & c) | b | c) == a)
fE(a, b, c, d) =
tD(a, b, c) == tD(a, b, c) == TRUE
fE returns FALSE if they are all equal and TRUE if they are unequal.
>>6
no, fE() should return TRUE if they are all equal and FALSE if they are unequal.
fE() and tD() test for opposite things, and on a different number of arguments.
fE() - fourEqual() - are these fourEqual()?
tD() - threeDifferent() - are these threeDifferent()?
The point is that one takes an even number of integers and tests for equality, and the other takes an odd number of integers and tests for distinction.
>>7
Then change the == TRUE
to == FALSE
you god damn retard.
>>8
and exactly where does the variable d come into play?
>>8
also, let me tell you right now that if you're referring to >>6
thinking that the absolute gibberish
tD(a,b,c) == tD(a,b,c) == TRUE
(which ill assume you meant what was posted in >>3)
tD(a,b,c) == tD(a,b,d) == False //you're correction
is anywhere close to being right
you are the fucking retard my dear friend.
fE(1, 2, 1, 2)
tD( 1, 2, 1) == tD(1, 2, 2) == false
false == false == false
true
not gonna cut it faggot
or the other way
fE(1, 1, 1, 1)
tD(1, 1, 1) == tD(1, 1, 1) == true
false == false == true
false
not gonna cut it nigger
Do your own homework, dude.
>>11
this isn't homework. this is a simple problem i made up for this board, that apparently no one here is capable of solving.
>>12
Oh hai
thrD(a,b,c) := not(a=b=c)
frE( a, b, c, d ) := not( thrD( a, b, c) or thrD(b,c,d) )
>>13
well, let's see...
frE( 1, 2, 1, 1 ) =>
not( thrD( 1, 2, 1) or thrD( 2, 1, 1) ) =>
not( FALSE or FALSE ) =>
not( FALSE ) =>
TRUE
close, but no cigar. and this is assuming thrD() actually does what it's suppose to, namely determine if all three arguments are different. your code for thrD() does not do this.
thrD( 1, 2, 1 ) =>
not( 1 == 2 == 1 )
not( FALSE )
TRUE
>>10,14
HOLY SHIT You're a fucking retard.
I used only the binary operators AND, OR and the equality operator.
(((a & b & c) | b | c) == a)
tests whether b and c equal a.
Let's call that expression A.
!A means they are unequal
tD(a, b, c) <- !A(a, b, c)
So far, good.
!A(a, b, c) == !A(a, b, d)
means all four not the same number if true, else the same number.
tD(a, b, c) == tD(a, b, d)
means the same
fE(a, b, c, d) <- !(tD(a, b, c) == tD(a, b, d))
There. I did it assuming it's possible to use only once the equal operator in every definition, and that you meant binary operators AND, OR.
Now, to your actual retarded problem
tD(a, b, c) <- !(a == b == c)
fE(a, b, c, d) <- !tD(a, b, c) && !tD(a, b, d)
OK? Got it? Now, that's all based to your first post, because of your mistake.
On to your second post:
tD(a, b, c) <- !(a == b || a == c || b == c)
fE(a, b, c, d) <- !tD(a, b, c) && !tD(a, b, c)
I love your attitude, you make mistakes, then you blame us for them, then you call us uncapable of solving such "problem".
Fuck.
>>15
First of all, I acknowledged my mistake as well as the confusion it would bring, early on.
Second, my attitude was only brought about because you called me "fucking retarded".
Third, your answer is still wrong.
I suppose I failed miserably to explain this problem, but I'm going to try once more.
We are given a function called threeDifferent(). It does not need to be defined, it is given to us. What this function does is take three integer arguments and determine whether or not they are all different. If they are all different it returns true. If any of them are the same, it returns false. Here are some examples:
threeDifferent( 1, 2, 3 ) *returns* TRUE
threeDifferent( 1, 2, 1 ) *returns* FALSE
In the first case, all three integers are different. In the next case, the first and the last are the same, so no.
Now what I want is a function called fourEqual() defined using threeDifferent(). What fourEqual() does is determine if four integers are all equal. Here are some examples:
fourEqual( 1, 1, 1, 1) *returns* TRUE
fourEqual( 1, 2, 1, 1) *returns* FALSE
In the first case, each argument is 1, so they are in fact all equal. In the second case, 2 is different, so they are not equal.
Now, lets look at your code:
fE(a, b, c, d) <- !tD(a, b, c) && !tD(a, b, d)
In particular, the case of (1, 2, 1, 1)
fE(1, 2, 1, 1) <- !tD(1, 2, 1) && !tD(1, 2, 1)
Obviously (1, 2, 1, 1) are not all equal, so fE(1, 2, 1, 1) should return FALSE.
And (1, 2, 1) are not all different, so tD(1, 2, 1) should return FALSE. Why? Because they are not all different.
So, the result of evaluating !tD(1, 2, 1) is TRUE.
So, the expression
!tD(1, 2, 1) && !td(1, 2, 1)
becomes
!(FALSE) && !(FALSE)
TRUE && TRUE
TRUE
Therefore, your function fE(1, 2, 1, 1) will return TRUE. But is it true that they are all equal? NO.
> Therefore, your function fE(1, 2, 1, 1) will return TRUE. But is it true that they are all equal? NO.
It would not, with my definition (or at least what I understood from your definition).
But fine, with your definition of tD(), yes, it wouldn't be correct.
I have another question, do you consider TRUE and FALSE as integers? (1 and 0). It would make things easier in solving this
>>17
Your definition doesn't really make sense to me:
(((a & b & c) | b | c) == a)
Since a, b, and c are integers, and | is a logical operator,
(((a & b & c) | b | c)
will always evaluate to TRUE unless a, b, and c are all 0.
here is what tD() would look like in C:
bool tD( int a, int b, int c )
{
return !( (a == b) || (b == c) || (a == c) )
}
>>14
Oh, I though tD returned true when all three are not the same. After reading >>16, I don't think there is an actual solution to this unless you know beforehand that a,b,c,d are all not a specific value. If you know that, then you can do
frE(a,b,c,d) = not( thrD(a,b,k) or thrD(a,c,k) or ...[rest of the pairs])
Otherwise, I don't see any solution.
So why are you making up utterly pointless homework problems? Just get a job in academia already if that's what you want to do.
Also, your problem is unsolvable as stated.
tD(a,a,a)==tD(a,a,b)==tD(a,b,a)==tD(b,a,a)==FALSE
However, fE(a,a,a,a) != fE(a,a,a,b), but as fE can only be defined in terms of the above expressions, which all have the same value, fE(a,a,a,a) will be equal to fE(a,a,a,b) no matter how it is defined.
bool fE(a, b, c, d){
return tD(0, 1, 2) && a == b && b == c && c == d;
}
>>23
YOU JUST WON THE GAME!
>>22
take a chill pill dude.
GREAT GOING KID!
lol the hilarious memories
(NOT dif(a,a,b) )AND (NOT dif(b,b,c)) AND (NOT dif( c,c,d))
Am I doing it wrong?
Ye you are.
>>27
Already been proven to not have a solution. What more can you want to see that, yes, you are doing it wrong.
I think I learned about this in my english class
Man is mortal, Socrates is man, theirfore Socrates is mortal.
I'm not a real programer but I think this makes some sence
>>30 wants us to post a joke about his english typos, that's why he mentioned he goes to an english class. just silly.
But does it make sense?
If you want to know if all are true you just need to compare one value against every other.
The other ways just tell you how true the statement is which isn't necessary in this case.
P.S. Only a troll would point out something as stupid as spelling typos.
Acknowledged.
I sincerely apologize for my inappropriate conduct and hope you can forgive me.
I'm a bit new at this.
I can't forgive you but you won't be punished this time.
tD( a, b, c) AND tD( b, c, d)
This tread needs to die.
indeed
do we have TeX on this board?
int td (int a, int b, int c)
{
if (a == b && a == c)
return 1;
else
return 0;
}
What exactly was the problem here?
haha.
Thats what I would have done. if A = B = C then
oh hai, this thread @___@ ~___~ ^__^