Sumar and the Floating Rocks

Sort by

recency

|

56 Discussions

|

  • + 0 comments

    "Sumar and the Floating Rocks" is an intriguing blend of fantasy and adventure, captivating with its imaginative world and compelling storytelling. Skyexchange bet login

  • + 0 comments

    JS:

    function gcd(a,b) {
     while(b !== 0) {
    	 const r = a % b;
    	 a = b;
    	 b = r;
    	 }
     return a;
    }
    function solve (x1,y1,x2,y2) {
    	const yd = Math.abs(y2-y1);
    	const xd = Math.abs(x2-x1);
    	const a = Math.max(yd, xd);
    	const b = Math.min(yd, xd);
    return gcd(a,b) - 1;
    	}
    
  • + 0 comments

    Equation of Line (y-y1)=(y2-y1)/(x2-x1) (x-x1)

    => y(x2-x1) - y1 (x2-x1) = x (y2-y1) - x1 (y2-y1)

    => y(x2-x1) - x (y2-y1) = - x1 (y2-y1) + y1 (x2-x1)

    => - x (y2-y1) + y(x2-x1) = - x1 (y2-y1) + y1 (x2-x1)

    => a=(x2-x1), b=(y2-y1)

    as per the Extended Euclid Algorithm : for integral solution to this equation, the RHS should be multiple of gcd(a,b) i.e. gcd (|x2-x1| ,| y2-y1|)

  • + 0 comments

    This problem is very insightful and has a simple solution after working it out. Let. a/b = (y2 - y1)/(x2 - x1) be the slope in the reduced form. Sabexch Registration

  • + 0 comments
    int a,b,c,d;
    BigInteger ans;
    // for x axis
    if(x1>x2){
        a=x2;
        b=x1;
    }else{
        a=x1;
        b=x2;
    }
    // for y axis
    if(y1>y2){
        c=y2;
        d=y1;
    }else{
        c=y1;
        d=y2;
    }
    // difference 
    BigInteger x=new BigInteger(String.valueOf(b-a));
    BigInteger y=new BigInteger(String.valueOf(d-c));
    // gcd calculation
    ans=x.gcd(y);
    int i= ans.intValue();
    
    return i-1;