Skip to content

Instantly share code, notes, and snippets.

@viveknarang
Created September 29, 2017 02:09
Show Gist options
  • Save viveknarang/5fc2c6088b028722fb2a70450117888f to your computer and use it in GitHub Desktop.
Save viveknarang/5fc2c6088b028722fb2a70450117888f to your computer and use it in GitHub Desktop.
import java.util.Scanner;
public class SimonSays {
public static void main (String [] args) {
String simonPattern = "";
String userPattern = "";
int userScore = 0;
int i = 0;
userScore = 0;
simonPattern = "RRGBRYYBGY";
userPattern = "RRGBBRYBGY";
/* Your solution goes here */
for (i = 0 ; i < simonPattern.length(); i++) {
if (simonPattern.charAt(i) == userPattern.charAt(i)) {
userScore++;
} else {
break;
}
}
System.out.println("userScore: " + userScore);
return;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment