Question: Let **M** and **n** be **d x d**- and **d**-dimensonal numpy arrays of integers, respectively. I want to count the number of triples of the form *(n(i), n(j), M(i,j))*. As a result I want a numpy array such that each entry counts the number of occurences of such a triple.

*Edit:* **M** is symmetric and I don't want to count triples with i=j.

I'm currently using `itertools.product` (for loop over all pairs) and `numpy.bincount` to do this, but it is too slow. Is there a smarter way doing this, probably using `numpy`?

Answer: 
Say you have a 4 digit int which has to be 24 hour time between 0000 and 2359

```
public static boolean isValid(int time) {
     int mins = time % 100;
     return mins < 60 && hrs >= 0 && hrs < 2400;
}

```

Say it is between 0001 and 2400

```
public static boolean isValid(int time) {
     int mins = time % 100;
     return mins < 60 && time >= 1 && time <= 2400;
}

```
If this is your exact code, you will have a compile time error from the if statement: `(Integer.parseInt(digits.charAt(0) > 1 )`. You are missing a closing parenthesis, so the compiler thinks that you are trying to parse `digits.charAt(0) > 1` (a `boolean` value) into an `Integer`, rather than what you intend (`Integer.parseInt(digits.charAt(0))`).