Created
July 28, 2014 11:03
-
-
Save stopfaner/e25a13db5c2e8494aaf6 to your computer and use it in GitHub Desktop.
Turtle moving algorithm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Solution { | |
/* | |
* Initialisation of sum | |
* Initialization of parametres of field | |
*/ | |
public static double sum=1; | |
public static double heigth = 3; | |
public static double length = 3; | |
//---------------------------------------------------------- | |
public static void main(String[]args) { | |
//checking up | |
if(heigth == length) { | |
sum*=2; | |
for(int i=(int)heigth-1;i>2;i--) { | |
sum*=(length-1)/(i-1)+1; | |
} | |
sum*=length; | |
} | |
else { | |
if(heigth==2) { | |
sum=length; | |
} | |
else { | |
sum*=(length-1)/(heigth-1)+1; | |
for (int i=(int)heigth-1;i>2;i--) { | |
sum*=(length-1)/(i-1)+1; | |
} | |
sum*=length; | |
} | |
} | |
//printing | |
System.out.println(sum); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment