Skip to content

Instantly share code, notes, and snippets.

@kazoo04
Last active December 26, 2015 00:49
Show Gist options
  • Save kazoo04/7067261 to your computer and use it in GitHub Desktop.
Save kazoo04/7067261 to your computer and use it in GitHub Desktop.
@s0bc
import java.util.Random;
public class RandomChars
{
private final static String answer = "あいうえ";
public static int count = 0;
public static void main(String[] args)
{
char[] chars = answer.toCharArray();
String strs = "";
while(!strs.equals(answer))
{
count++;
if(strs.length() >= answer.length()) {
strs = strs.substring(1, answer.length());
}
char c = chars[(int)(Math.random() * chars.length)];
strs += c;
System.out.print(c);
}
System.out.println("\ncount = " + count);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment