Created
August 4, 2014 20:11
-
-
Save MrP123/3c41f74cebeb8c397923 to your computer and use it in GitHub Desktop.
This file contains 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
package Challenge_174_Easy; | |
public class ThueMorseSequence{ | |
private static int orders = 6; | |
private static boolean printSequence = false; | |
public static void main(String[] args){ | |
sequence(orders); | |
} | |
private static void sequence(int orders){ | |
StringBuilder sb1 = new StringBuilder("0"); | |
StringBuilder sb2 = new StringBuilder("1"); | |
String s1, s2; | |
for(int i = 0; i < orders; i++){ | |
s1 = sb1.toString(); | |
s2 = sb2.toString(); | |
sb1.append(s2); | |
sb2.append(s1); | |
} | |
if(printSequence) System.out.println(sb1.toString()); | |
else System.out.println(orders + " : " + sb1.toString().length()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment