|
|
for ( every possible outcome i ) do { if ( i is a correct solution ) { print solution i; (exit if you only need one solution) } } |
T = acgttagatactaggatgcca P = gata Try: acgttagatactaggatgcca gata acgttagatactaggatgcca gata acgttagatactaggatgcca gata acgttagatactaggatgcca gata and so on... |
for ( pos = 0; pos < n-m; pos++ ) { if ( T[pos..pos+(m-1)] == P ) { return(pos); // Found match.... } } |
public static int BruteForce(String T, String P) { int i, j, m, n; n = T.length(); m = P.length(); T_ruler = ruler(n); P_ruler = ruler(m); i = 0; j = 0; for ( i = 0; i < n-m; i++ ) { if ( P.equals( T.substring(i, i+m) ) ) { return( i ); // Found P at position i in T } } return(-1); } |
How to run the program:
|
|
|
|
He has an interesting law of conservation, like the law of conservation of matter and energy in Physics.
His law is:
|
|