Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Day1 {
- public static void main(String[] args) {
- // First problem of the day
- String capcha = " //YOUR CAPCHA CODE GOES HERE //";
- int summe = 0;
- int length = capcha.length();
- for(int i=1; i<length; i++) {
- if ((capcha.charAt(i)-'0') == (capcha.charAt(i-1)-'0')) {
- summe = summe + (capcha.charAt(i)-'0');
- }
- if ((i+1) == length) {
- if ((capcha.charAt(i)-'0') == (capcha.charAt(0)-'0'))
- summe = summe + (capcha.charAt(0)-'0');
- }
- }
- System.out.println("Capcha 1:" + summe);
- // Second problem of the day
- for(int i=0; i<length; i++) {
- int j= 0;
- if ( i + ( length/2 ) >= length )
- j = i - length/2;
- else
- j = i + length/2;
- if ((capcha.charAt(i)-'0') == (capcha.charAt(j)-'0'))
- summe = summe + (capcha.charAt(i)-'0');
- }
- System.out.println("Capcha 2:" + summe);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment