/**
*
*
*/
package com
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import org.apache.commons.lang.StringUtils;
/**
* @author userya
* @since 2009-3-3
*/
public class Main {
/**
* @param args
*/
public static void main(String[] args) {
System.out.println(trueTest("i", "her", "like", "ilikeher"));
System.out.println(trueTest("i", "she", "like", "shelikei"));
}
/**
* test something
* @param a1
* @param a2
* @param a3
* @param target
* @return
*/
private static String trueTest(String a1, String a2, String a3,
String target) {
String temp = a1 + a2 + a3;
int ii = 0;
while (true) {
ii++;
if (StringUtils.isNotBlank(a3)) {
char[] a = temp.toCharArray();
Map map = new HashMap();
for (int i = 0; i < a.length; i++) {
map.put(i, a[i]);
}
StringBuffer sb = new StringBuffer();
Random r = new Random();
int j = map.size();
while (true) {
int rr = r.nextInt(j);
if (map.containsKey(rr)) {
sb.append(map.get(rr));
map.remove(rr);
}
if (map.size() == 0) {
break;
}
}
// System.err.println(sb);
if (target.equals(sb.toString())) {
return "time:" + ii + "->" + sb.toString();
}
}
}
}
}
生活中总是有随机性,爱情也一样,但愿有生之年能跳出循环,找到平衡点。
分享到:
相关推荐
随机信号处理英文教程probability and random processes This book has been written for several reasons, not all of which are academic. This material was for many years the rst half of a book in progress ...
Random forests are a combination of tree predictors such that each tree depends on the values of a random vector sampled independently and with the same distribution for all trees in the forest....
Math.Random()简介 Math.Random()函数能够返回带正号的double值,该值大于等于0.0且小于1.0,即取值范围是[0.0,1.0)的左闭右开区间,返回值是一个伪随机选择的数,在该范围内(近似)均匀分布。 for (int i = 0; i ...
1.random库的使用: random库是使用随机数的Python标准库 从概率论角度来说,随机数是随机产生的数据(比如抛硬币),但时计算机是不可能产生随机值,真正的随机数也是在特定条件下产生的确定值,只不过这些条件...
namespace 伪随机数{ class Program { static void Main(string[] args) { Random rnd=new Random (); char c; Random ro = new Random(); Console.WriteLine("{0}", ro); int d = ro.Next(); Console.WriteLine("{0...
An overview of decision trees and random forests A manual example of how a human would classify a dataset, compared to how a decision tree would work How a decision tree works, and why it is prone ...
该文档是关于random函数使用详细讲解,主要在代码编写产生随机数的时候用到,详细介绍了random函数的各种用法,赶快下载看看吧~
The primary goals of this book are to introduce the reader to the principles of random signals and to provide tools whereby one can deal with systems involving such signals . Toward these goals ,...
It is lecture notes for Random Process at UIUC, if you have interests, just have a look
Abstract—A random beamforming (RBF) technique is proposed to achieve omnidirectional coverage for broadcast channels in multipleantenna systems. In the proposed scheme, the time and frequency ...
Random Beans Because life is too short to generate random Java™ beans by hand.. Latest news 27/01/2019: Version 3.8.0 is finally out! Checkout what's new in the change log. 19/06/2017: ...
import random n=input() x,y=n.split(',') '''将两个整数从输入提取出来''' list1=[] i=0 for i in range(0,100) : b=random.randint(int(x),int(y)) list1.append(b) #每次结果加插入列表 dic1={} for j in ...
Probability & Random Processes for Electrical and Computer Engineers
Random Numbers with Android studio.
ASP Random Images ,好久才找到,很好用
Random bits generation with chaotic key sequence
如果你需要一款好用的密码生成工具,不妨试试小编带来的这款Random Password软件,功能强大全面,使用后可以帮助用户更轻松便捷的生成随机密码。用户可以根据自身的需要自定义密码的生成规律,包含了26个字母和数字...
This book gives a coherent and detailed description of analytical methods devised to study random matrices. These methods are critical to the understanding of various fields in in mathematics and ...
Random Number Generator v1.0 <br>一个随机数生成的小工具,可以用在需要随机数的地方 例如随机安排考场座位, <br>功能: 1、生成数列的随机排序 2、指定前缀 3、关联目标 4、结果保存为文本...
math.random函数的一些用法技巧