Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- public class MainB {
- public static void main(String[] args)
- {
- int min = 272091;
- int max = 815432;
- int[] tempCode = new int[6];
- int count = 0;
- for(int y = min; y < max; y ++)
- {
- for(int x = 0; x < 6;x++)
- {
- tempCode[x] = Integer.toString(y).charAt(x);
- }
- boolean pass = false;
- for (int i = 0; i < 5; i++)
- {
- if(tempCode[i] == tempCode[i+1])
- {
- if(i == 0)
- {
- if(tempCode[i+2] != tempCode[i])
- {
- pass = true;
- }
- } else if(i == 4)
- {
- if (tempCode[i - 1] != tempCode[i])
- {
- pass = true;
- }
- }else
- {
- if(tempCode[i-1] != tempCode[i] && tempCode[i+2] != tempCode[i])
- {
- pass = true;
- }
- }
- }
- }
- for (int i = 1; i < 6; i++) {
- if (tempCode[i] < tempCode[i - 1]) {
- pass = false;
- }
- }
- if (pass) {
- count++;
- }
- }
- System.out.println(count);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement