Question: I have setup a spark cluster using cassandra as data cluster in stand alone mode. On the other hand I'm using IntelliJ IDEA to write the driver code to be sent to the spark cluster to be executed by the workers.

What I would like to know if it is possible to execute code from intellij (in my local machine) into the remote cluster or I must create a .jar file and deploy it to the workers with the sopark-submit?.

I'm just looking for a confirmation because I'm having problems doing all setup and need to reduce possibilities.

Thanks in advance.

Answer: 
Imagine 

```
kangoroo(1,1,2,2)

```

So the first code would return *No* while the second does return *Yes*. You may implement the first condition into the second:

```
function kangaroo(x1, v1, x2, v2){
  if ((x1 - x2) % (v2 - v1) === 0 && !(x2 > x1 && v2 > v1)) {
    return "YES";
  }
 return " No";
}

```
Try this(written in Java)

x1: initial location of kangaroo 1
& x2: initial location of kangaroo 2

If it is given that x2 > x1

```
static String kangaroo(int x1, int v1, int x2, int v2) {

    int i;
    for(i=0; x1<x2; i++){
        x1 = x1 + v1;
        x2 = x2 + v2;
        if(x1 == x2){
            return "YES";
        } 
    }   
    return "NO";
}

```

Below solution covers all the possibilities like, x1 > x2 or x1 == x2 or x1 < x2.

```
static String kangaroo(int x1, int v1, int x2, int v2) {

    int i, flag = 0;

    if(x1 > x2){
        for(i=0; x1>x2; i++){
            x1 = x1 + v1;
            x2 = x2 + v2;
            if(x1 == x2){
                return "YES";
            }
        }
    }else if(x1 < x2){
        for(i=0; x1<x2; i++){
            x1 = x1 + v1;
            x2 = x2 + v2;
            if(x1 == x2){
                return "YES";
            } 
        }   
    }else
        return "YES";

    return "NO";
}

```