import java.util.*;
public class A17 {
static String cappyturnaround(String[]positions,int i, int j)
{ for
( i=0; i<positions.length;i++)
{
for
( j=i+1; j< positions.length;j++)
{
if
(positions[i]!="H"||positions[j]!="H"||positions[j]!="V"||positions[i]!="V")
{
throw new IllegalArgumentException(positions[i|j]);
}
}
}
for
( i=0; i<positions.length; i++)
{
for
( j=i+1; j< positions.length;j++)
{
if
(positions[i]=="H"||positions[j] == "H")
{ positions[i]=positions[i].replace("H", "V");
}
}
}
return positions[i|j];
}
static String cappyturnaround2(String[]positions,int i, int j)
{
return "x";}
}
I am searching for a method to count the H's and V's to turn the Element which appears Less in to the other one e.g. 4 H's 2V's --> 6 H's. 4H's 6V's-> 10 V's
So far i just solved the problem in general so that I just can replace one Element without reviewing the effort. it would also be possible to solve the problem just for chars.
Aucun commentaire:
Enregistrer un commentaire