Skip to content

Instantly share code, notes, and snippets.

@anirudh708
Created January 10, 2020 11:20
Show Gist options
  • Save anirudh708/6c069cd48077d22f2eca5ae258531c92 to your computer and use it in GitHub Desktop.
Save anirudh708/6c069cd48077d22f2eca5ae258531c92 to your computer and use it in GitHub Desktop.
public class One {
public static void main(String[] args) {
int A = 2, B = 5;
int a = 1, b = 1; String result = "";
while ((A+B)>0) {
if (A > B) {
if (a < 3) {
result += "a";
a++; b=1; A--;
} else {
result += "b";
b++; a=1; b--;
}
} else {
if (b < 3) {
result += "b";
b++; a=1; B--;
} else {
result += "a";
a++; b=1; A--;
}
}
}
System.out.println(result);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment