Mathematics

Associated with Math.SE; for both general discussion & math qu...
Jan 7, 2018 11:41
hahahah
Jan 7, 2018 11:41
Leaky Nun already sounds like a rapper's name
Jan 7, 2018 11:32
Not sure if he'll be giving the exam or taking the exam
Jan 7, 2018 11:30
@LeakyNun best of luck for your exams tomorrow bro
Jan 7, 2018 11:27
@LeakyNun Yeah got my mistake.. Thank you
Jan 7, 2018 11:23
hahahah sorry once again XD
Jan 7, 2018 11:22
@LeakyNun any comments bro?
Jan 7, 2018 11:21
@BalarkaSen Sorry brother.. Actually it was a math problem..
Jan 7, 2018 11:21
But doing the same thing
Jan 7, 2018 11:21
here basically I am sorting such that my comparisons are reduced
Jan 7, 2018 11:20
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int a[4];
        for(int i=0;i<4;i++)
            cin>>a[i];

        sort(a,a+4);

        if(a[0] == a[1] && a[2] == a[3])
        {
            cout<<"YES"<<endl;
        }
        else
        {
            bool flag = true;
            for(int i=0;i<2;i+=2)
            {
                if(a[i] != a[i+1])
                {
                    flag = false;
                    break;
Jan 7, 2018 11:20
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
int t;
cin>>t;
while(t--)
{
int a[4];
for(int i=0;i<4;i++)
cin>>a[i];

sort(a,a+4);

if(a[0] == a[1] && a[2] == a[3])
{
cout<<"YES"<<endl;
}
else
{
bool flag = true;
for(int i=0;i<2;i+=2)
{
if(a[i] != a[i+1])
{
flag = false;
break;
}
}
if(flag)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
}
return 0;
}
Jan 7, 2018 11:19
GOD DAMN.. Tried the same with C++.. Getting Wrong answer
Jan 7, 2018 11:18
yes dude
Jan 7, 2018 11:18
Guys make sure we are not checking a parallelogram in our algorithms
Jan 7, 2018 11:17
haha
Jan 7, 2018 11:17
@LeakyNun and @Mr.Xcoder try submitting your solutions here codechef.com/JAN18/problems/RECTANGL
Jan 7, 2018 11:15
wabalalbadubdub
Jan 7, 2018 11:14
@Mr.Xcoder Try submitting your solution too over ther
Jan 7, 2018 11:13
also PYTH
Jan 7, 2018 11:12
Dude the site supports python
Jan 7, 2018 11:12
@Mr.Xcoder which language are you talking about?
Jan 7, 2018 11:11
Because I tried this approach and it gives WRONG ANSWER
Jan 7, 2018 11:10
Would you mind submitting your solution there?
Jan 7, 2018 11:10
@LeakyNun @Mr.Xcoder any idea on how to determine the rectangle problem?
Jan 7, 2018 11:06
as pointed out by @LeakyNun check the constraints
Jan 7, 2018 11:06
and numbers are positive
Jan 7, 2018 11:06
@Mr.Xcoder what do you mean by equal 2-by-2?
Jan 7, 2018 11:04
So surely comparing the equal sides is not the only thing
Jan 7, 2018 11:04
but when I submit the problem it gives wrong answer
Jan 7, 2018 11:04
My algorithm passes the test cases
Jan 7, 2018 11:04
Yeah. the problem here is that I my algorithm is only comparing two equal sides as given in the test cases
Jan 7, 2018 11:02
It <b> must </b> form bro
Jan 7, 2018 11:02
This is the correct link codechef.com/JAN18/problems/RECTANGL
Jan 7, 2018 11:01
Yeah I sent the wrong link
Jan 7, 2018 11:00
But simply comparing the equal sides doesn't seem to do the trick
Jan 7, 2018 11:00
That is what the problem is asking me in the link given above
Jan 7, 2018 11:00
I am writing a program to check 4 integer values form a rectangle or not..
Jan 7, 2018 10:58
You said check for 4 right angles rather than lengths so I thought of Pythagoras theorem
Jan 7, 2018 10:57
So are you saying if I am given a,b,c,d as length then I must apply Pythagoras theorem?
Jan 7, 2018 10:56
The example are basically any random 4 whole numbers. Like 5 5 5 5 or 4 4 5 5 or 1 2 3 4 etc
Jan 7, 2018 10:53
yes.. integer length of 4 sides
Jan 7, 2018 10:52
@LeakyNun Yeah my mistake.. It must form a rectangle.
Jan 7, 2018 10:50
@LeakyNun but then I am comparing the equal I am just checking if the numbers form a parallelogram and not a rectangle. I want to know if there are other things that I need to check for the given 4 numbers such that it is confirmed to be a rectangle?
Jan 7, 2018 10:25
I mean apart from the fact that I have 2 equal sides, How do I play around with these 4 numbers and claim this to be a rectangle?
Jan 7, 2018 10:23
Hence, for example 5 5 6 6, How do I say if this is a rectangle?
Jan 7, 2018 10:22
yes you are right
Jan 7, 2018 10:19
Hence I want to know all the possible values of side that my algorithm will fail