Skip to content

Instantly share code, notes, and snippets.

@MrP123
Created August 4, 2014 20:11
Show Gist options
  • Save MrP123/3c41f74cebeb8c397923 to your computer and use it in GitHub Desktop.
Save MrP123/3c41f74cebeb8c397923 to your computer and use it in GitHub Desktop.
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