Example: 23450 is cool because 3+4+0 = 2+5; So is 91125;

The numbers 567, 34523 are not cool, since there is no such digit partition.

Write a program to check if inputted number is cool or not. ]]>

I need to create a program which finds possible values of X in matrix, so let's begin :).

We have a file.txt and there is stored:

Code Java:

8 / 2 = X + 1 - X = X * 2 = X
/ + - * * / + /
4 - X + X / 3 + 1 = 3 - X = 2
+ * + + * * + *
X + 2 * X = X - 2 + X / 3 = X
= = = = = = = =
3 + X - 2 - 6 + X / 5 * X = 6

Calculations are made from left to right and from top to bottom, so sign '=' means that the number( or symbol X) on the right or at the bottom is product of solution of equation on the left or at the top.

And there is one SUPER RULE :D calculations are made without priority , like 4+2/2 is 3 not 5, and X=[1;2;3;4;5;6;7;8;9] , every X can have any value like x+2=x, means 2+2=4 or 5+2=7.

I'm trying to think something , but :( i have no ideas on how to make it find those missing values, i have made only a code that reads the file checks for other rules and creaters a STRING matrix [4][8],

any ideas on algorithm for solving this? I don't need the code(but would be cool :D) , I need some ideas , please help :)

I do have an idea on how to make this though the problem is efficiency. I need to make (or implement) some algorithms that make the code usable for big source codes.

I don't expect you to write me a source code but rather guide through which is the best idea or algorithms that I should be considering.

Thank you in advance :) ]]>

I finished the player part of my mastermind game. Now i'm busy with the computer part. Now i've checked a few mastermind algorithms and have to say its difficult to implement them in my java script.

Can anyone help me to do this?

I am stuck at the guess phase. My code is as following

prevGUess is the previous guess

prevposright is the previous right guess at right position

prevcolright is the previous right guess wrong position

Code :

public String guessPhase(int curChance, String prevGuess, int prevPosRight, int prevColRight){
String posRight;
String colRight;
if(curChance == 1){
String letters = "ABCDEF";
Random r = new Random();
for(int i = 0; i < guessChars.length; i++){
int n = r.nextInt(5);
guessChars[i] = letters.charAt(n);
}
}else{
if(posRight_p == 0 && colRight_p == 0){
String letters = "ABCDEF";
Random r = new Random();
for(int i = 0; i < guessChars.length; i++){
int n = r.nextInt(5);
guessChars[i] = letters.charAt(n);
}
}
}
return String.valueOf(guessChars) + posRight + colRight;
}
Thanks in future.

We have a convoy of cars that are lined up in a row and must cross the bridge. Cars canīt overtake each other.

The bridge has limited capacity, which may not be exceeded.

Find the algorithm, which divides cars into groups so that the entire convoy cross the bridge in the shortest time.

Another group is allowed to enter only when the entire previous group cross the bridge.

Weight and speed of each car is known. The speed of group is determined by the slowest of car in the group.

Sample data:

output.jpgzadaniALG2.jpg

Thank you for your help, Petr

Given a set of whole weight stones, can divide them into 2 groups with weight

Exactly equal.

Write a recursive function

public static boolean canSplit (int [] stones, int left, int right)

Which, given a set of weights stones says the mother can divide them into two groups) left

And right- (so that the whole team is worth. Use the function subArray if necessary.

Training: Look at the first stone and recursive decided which group has associated with it.

(This problem belongs to the important problems in computer science called NP hard problems. Solution

Effective) polynomials (problem solver will win the prize of a million dollars) and will allow him to break all

Security system in the world (. In this task will fulfill naive solution) exponentially (the problem.)

Thank you

--- Update ---

Sorry, correction of the error:

Given a set of whole weight stones, can divide them into 2 groups with weight

Exactly equal.

Write a recursive function

public static boolean canSplit (int [] stones, int left, int right)

Which, given a set of weights stones mean function can be divided into two groups) left

And right- (so that the whole team is worth. Use the function subArray if necessary.

Training: Look at the first stone and recursive decided which group has associated with it. ]]>

Code Java:

class Quicksort {
// Set up a call to the actual Quicksort method.
static void qsort(char items[]) {
qs(items, 0, items.length-1);
}
private static void qs(char items[], int left, int right)
{
int i, j;
char x, y;
i = left; j = right;
x = items[(left+right)/2];
do {
while((items[i] < x) && (i < right)) i++;
while((x < items[j]) && (j > left)) j--;
if(i < j) {
y = items[i];
items[i] = items[j];
items[j] = y;
i++; j--;
}
} while(i < j);
if(left < j) qs(items, left, j);
if(i < right) qs(items, i, right);
}
}
class QSDemo {
public static void main(String args[]) {
char a[] = { 'x', 'r', 'p', 'j', 'i', 'd', 'a' };
int i;
System.out.print("Original array: ");
for(i=0; i < a.length; i++)
System.out.print(a[i]);
System.out.println();
// now, sort the array
Quicksort.qsort(a);
System.out.print("Sorted array: ");
for(i=0; i < a.length; i++)
System.out.print(a[i]);
}
}

However, in the following code

Code Java:

if(i < j) {
y = items[i];
items[i] = items[j];
items[j] = y;
i++; j--;
}
} while(i < j);

, if I change the two '<' to '<=', the complete program compiles. I am trying to understand why these two changes cause this compile error. Any help on this would be appreciated. ]]>