i have the class Password:

import java.util.Random;

public class Password {

private String _password = "";

public Password(int length) {

Random generator = new Random();

for (int i = 0; i < length; ++i) {

this._password = this._password + (char)(generator.nextInt(26) + 97);

}

}

public boolean isPassword(String st) {

return st.equals(this._password);

}

public String getPassword() {

return this._password;

}

i need to make the method:

public static string findPassword(Password p, int length)

which will try all possible password combinations until it will find the password

-I cant use loops in this project, only recursion

-I cant use getPassword()

-the password in only lower-case english letters

-and I cant use 26 recusive calls (one for each letter)

please help

thanks ;) ]]>

I am no longer good enough mathematically to deduce the number of moves and board positions, or maybe I never was. But I'm just trying to calculate them.

There are 28 fields, normally 4x 8 stones, there are 4 players, and stones can stack up to 5 high, normally (excluding the beginning stack, and excluding the "target" areas where the stones of that colour disappear, so can never create large stacks there.

I'm pretty sure there is an easy formula for it, but I don't know it. Something to do with combinations and I have the book here, I could look it up (discrete and combinatorial programming).

So what I'm doing instead is just creating an ordered array of populated fields, where the fields themselves are permutated, and accounted for duplicates and uniques, in that sense that the stack "index" has to go down (so combinations go only in one direction) and as a consequence stack sizes also go down.

This means you can have a stack array of 5 5 4 4 2 1 but not 2 5 3 4. This ensures that the only anomaly is when stacks are actually identical (because they cannot really be unique) and I take account of that by dividing by the right number. In the right place.

Other than that, the thing is really just multiplied by 28CR where "C" denotes combinations and R is the number of stacks, so that means just 28! / (28-R)!. That is the advance and limit of my unhelped mathematics thus far :p. I'm just trying to calculate the number of boards now. I'm not sure all boards are legal (they are not) but more importantly if, according to the rules of the game, they are even reachable. Although it is hard for me to see or prove, I think a considerable number are not even possible. Nevertheless if you are inventive enough you can reach some corner cases, but I'm sure that would exclude many other combinations that I am now counting or taking account of in my calculations. So it gets rather.... complicated in that sense :p.

The real goal is just... well I won't say. But at present I have been able to calculate the number of boards (including unreachable and illegal ones) pretty precisely, for ... well it's just that my "double" doesn't have enough precision for it. But still. It is about 384 x10²⁴ I think for a board with 6x4 stones and max 3 high. That took about 1 hour to calculate on one core (1 logical thread).

The number of illegal ones is abysmally low, about 1/1000000 so that's not even significant to worry about, because excluding them would greatly increase the cost of calculating. So that only leaves the number of unreachable ones, I have no clue, I would have to start out with a small board version that resembles the real thing and then see if I can calculate all moves, and then see what proportion of board positions (including the player whose turn it is) that can actually be reached. Something like 14 fields and 2 high stacks, but 2 high is much easier to reach than 5 high. So maybe 10 fields and 3 high and ..well it has to be a valid board. I need at least 12 to make a valid board, so it is gonna be 12 or 20.

Board calculations do not increase that much with the number of fields, but moves may. I really mean the cost of calculating the boards....

So yeah even if 1% of board positions is gonna be reachable, or even 1/1000000 that is still a hell of a lot of boards to choose from....

Still I gotta get something to eat, but this is what I'm doing :p. Regards. ]]>