Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class test
- {
- public static void main(String[] args)
- {
- String s1 = "GATC";
- System.out.println(s1);
- String s2 = shuffle(s1);
- System.out.println(s2);
- }
- public static String shuffle(String str)
- {
- if(str.length() <= 1)
- return str;
- String tmp1 = shuffle(str.substring(0, (str.length()/2)));
- String tmp2 = shuffle(str.substring(str.length()/2));
- if(Math.random() > 0.5)
- return tmp1 + tmp2;
- else
- return tmp2 + tmp1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement