Not A Big Deal

Just Kidding, it matters!


  • Home

  • Categories

  • About

  • Archives

  • Tags

  • Search

Spring的小坑

Posted on 2019-05-12 | In Spring |

这几天被奇怪的bug搞的头大,技术宅一开始都不知道发生了啥,后来我们合力搞明白了root cause

先放上Exception:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[junit] Testcase:
testDependencyExceptionHandler(com.amazon.calypso.document.tools.webapp.controller.SignatureHelperControllerTest): Caused an ERROR
[junit] Could not initialize class com.amazon.calypso.document.tools.webapp.util.LdapGroupControl$$EnhancerByMockitoWithCGLIB$$2918b0e4
[junit] java.lang.NoClassDefFoundError: Could not initialize class com.amazon.calypso.document.tools.webapp.util.LdapGroupControl$$EnhancerByMockitoWithCGLIB$$2918b0e4
[junit] at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
[junit] at org.objenesis.instantiator.sun.SunReflectionFactoryInstantiator.newInstance(SunReflectionFactoryInstantiator.java:45)
[junit] at org.objenesis.ObjenesisBase.newInstance(ObjenesisBase.java:73)
[junit] at org.mockito.internal.creation.instance.ObjenesisInstantiator.newInstance(ObjenesisInstantiator.java:14)
[junit] at org.powermock.api.mockito.repackaged.ClassImposterizer.createProxy(ClassImposterizer.java:143)
[junit] at org.powermock.api.mockito.repackaged.ClassImposterizer.imposterise(ClassImposterizer.java:58)
[junit] at org.powermock.api.mockito.repackaged.ClassImposterizer.imposterise(ClassImposterizer.java:49)
[junit] at org.powermock.api.mockito.repackaged.CglibMockMaker.createMock(CglibMockMaker.java:24)
[junit] at org.powermock.api.mockito.internal.mockmaker.PowerMockMaker.createMock(PowerMockMaker.java:46)
[junit] at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:33)
[junit] at org.mockito.internal.MockitoCore.mock(MockitoCore.java:59)
[junit] at org.mockito.Mockito.mock(Mockito.java:1285)
[junit] at org.mockito.internal.configuration.MockAnnotationProcessor.process(MockAnnotationProcessor.java:33)
[junit] at org.mockito.internal.configuration.MockAnnotationProcessor.process(MockAnnotationProcessor.java:16)
[junit] at org.mockito.internal.configuration.DefaultAnnotationEngine.createMockFor(DefaultAnnotationEngine.java:43)
[junit] at org.mockito.internal.configuration.DefaultAnnotationEngine.process(DefaultAnnotationEngine.java:66)
[junit] at org.mockito.internal.configuration.InjectingAnnotationEngine.processIndependentAnnotations(InjectingAnnotationEngine.java:71)
[junit] at org.mockito.internal.configuration.InjectingAnnotationEngine.process(InjectingAnnotationEngine.java:55)
[junit] at org.mockito.MockitoAnnotations.initMocks(MockitoAnnotations.java:108)
[junit] at com.amazon.calypso.document.tools.webapp.controller.SignatureHelperControllerTest.setup(SignatureHelperControllerTest.java:56)

看起来是Mockito的问题,由于我们package用到了PowerMock 1.6.3(技术宅说他也不知道为啥用这个,他说应该找时间refactor去掉这个),不兼容Mockito 2.x,所以我们现在还在用Mockito 1.x,我一直以为bug是因为我引入的新package用到了Mockito 2.0的新特性,所以不兼容,于是我陷入了两难的境地。

不过!!在我看了个sage还是StackOverflow说他的controller和service不能一起跑unit test之后,我仿佛有了点思路,仔细研究了一下LdapGroupControl的class,突然发现有可能是我在其中用到了

1
2
final private String s1 = AppConfig.findString("aa.bb.cc");
final private String s2 = AppConfig.findString("aa.bb.dd");

然而这些个controller的unit test并没有initialize AppConfig,所以找不到这些String来初始化,给技术宅一说,技术宅觉得有可能,于是我就改成了@Value形式:

1
2
3
4
5
@Value("${aa.bb.cc}")
private String s1;
@Value("${aa.bb.dd}")
private String s2;

恩成功了!!!不报那个错误了!!!!

对的 报了另外一个错误 :)

还原一下当时的大概代码:

1
2
3
4
5
6
7
@Value("${aa.bb.cc}")
private String s1;
@Value("${aa.bb.dd}")
private String s2;
final private Map<EnumA, String> map = ImmutableMap.of(A.X, s1, A.Y, s2);

这个map疯狂报错,说映射结果是A.X = null。于是又一顿找原因为什么。我一度怀疑是我的@Value没有配置好。

疯狂操作疯狂试验…

疯狂操作疯狂试验…

疯狂操作疯狂试验…

疯狂操作疯狂试验…

结果最后还是在StackOverflow搜到了原因…有人把@Value标记的值加在了Constructor里,导致变量值为null,回答是Constructor的加载发生在Spring inject之前,所以会为null。恍然大悟,但是@PostConstruct annotation只适用于method level,对于attribute不适用,于是我直接把这个map放到了我需要用的method里面。。

解决了,build成功了,真是一堆坑。

Single Number Triple Kill 三连击

Posted on 2017-11-07 | In Java , Algorithm |

被Leetcode上面的Single Number上面的骚操作震惊到了,尤其是2和3,简直神一般的脑洞和操作。

先放上原题

Single Number

Single Number 2

Single Number 3

Single Number:

Given an array of integers, every element appears twice except for one. Find that single one.

Note:
Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?

这道题没什么好说的,一路XOR到底直接搞定。

1
2
3
4
5
6
public int singleNumber(int[] nums) {
int n = 0;
for (int i=0; i<nums.length; i++)
n ^= nums[i];
return n;
}
Single Number II:

Given an array of integers, every element appears three times except for one, which appears exactly once. Find that single one.

Note:
Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?

这道题就有点意思了,直接丢出Discuss第一的答案,个人觉得非常完美了。

1
2
3
4
5
6
7
8
9
public int singleNumber(int[] nums) {
int ones = 0;
int twos = 0;
for (int i=0; i<nums.length; i++){
ones = (ones ^ nums[i]) & (~twos);
twos = (twos ^ nums[i]) & (~ones);
}
return ones;
}

简单分析这段代码想表达的意思:

ones代表一个数是否为第一出现,twos代表一个数是否为第二次出现。

当一个数出现第一次:

​ ones = (ones ^ nums[i]) & (~twos)

​ ones设为1(将nums[i]存在ones里面,下同),并检查twos里面是否为1,此时twos为0,所以ones为1(这个数)。

​ twos = (twos ^ nums[i]) & (~ones)

​ twos设为1,并检查ones是否为1,此时因为第一次出现,故已在上一行将ones设为1,此时twos结果为0。

当一个数出现第二次:

​ ones = (ones ^ nums[i]) & (~twos)

​ ones设为0,并检查twos里面是否为1,此时twos为1,所以ones为0。

​ twos = (twos ^ nums[i]) & (~ones)

​ twos设为1,并检查ones是否为1,此时ones为0,所以ones为1。

当一个数第三次出现:

​ ones = (ones ^ nums[i]) & (~twos)

​ ones设为1,并检查twos里面是否为1,此时twos为1,所以ones为0。

​ twos = (twos ^ nums[i]) & (~ones)

​ twos设为0,并检查ones为1或者0,此时ones为0,所以ones为0。

这时候ones和twos都变为0,达到一个数出现三次全部清零。这个时候只剩下一个distinct的数,而它只出现了一次,并且存在了ones里,此时只需要返回ones,即所求答案。

此题可推广为其他数出现k此,而某一个数出现p次的情况,这时候用此方法一样可以解决。

假设k = 5,而p为1,即其他数都出现了5次而只有一个数出现了一次,我们可以设定三个bit来对每一个数出现次数进行计数,分别为a,b,c:

出现1次:100, a=1, b=0, c=0;

出现2次:010, a=0, b=1, c=0;

出现3次:110, a=1, b=1, c=0;

出现4次:001, a=0, b=0, c=1;

出现5次:000, a=0, b=0, c=0;

注意观察三个数的变化所需要哪些个其他数来判断,比如说:

b需要根据a来判断是否变化,而a则根据c来判断是否清零,而c则需要a和b都为1才能变为1。

每次只需要更新a,b,c的值,可写出代码如下:

1
2
3
4
5
6
7
8
9
int singleNumber(int A[], int n) {
int na = 0, nb = 0, nc = 0;
for(int i = 0; i < n; i++){
nb = nb ^ (A[i] & na);
na = (na ^ A[i]) & ~nc;
nc = nc ^ (A[i] & ~na & ~nb);
}
return na & ~nb & ~nc;
}

想写的太长了有点偷懒,还有第三题
未完待续

Google-OA(Flower)

Posted on 2017-09-16 | In Java , Algorithm |

有一个长度为N的花坛,每天开exactly一朵花,给定一个1-N的permutation,代表每天开花的位置。假设某一个时刻,i和j位置的花开了,且i和j之间没有别的花开,那么中间就有一个长度为j-i-1的empty slot(最左的花就考虑和花坛左端的empty slot,最右的考虑和花坛右端的empty slot)。给定permutation P和一个指定empty slot size K,返回最早是哪一天,花坛中出现了大小为K的empty slot,如果始终没有出现,返回-1。要求O(N)空间,O(NlogN)时间。

思路:TreeSet,The time complexity of lower() and higher() are both O(logn),非常直接

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class Solution {
public int theEarlyDay(int[] order, int size) {
int len = order.length;
TreeSet<Integer> set = new TreeSet<>();
for (int i=0; i<len; i++){
set.add(order[i]);
int left = 0, right = 0;
if (set.lower(order[i]) == null) left = order[i] - 1;
else left = order[i] - set.lower(order[i]) - 1;
if (left == size) return i+1;
if (set.higher(order[i]) == null) right = len - order[i];
else right = set.higher(order[i]) - order[i] - 1;
if (right == size) return i+1;
}
return -1;
}
}

还是自己测试了一下,应该没问题。

Google OA(HH:MM)

Posted on 2017-09-16 | In Java , Algorithm |

input给一个format “00:00” - “23:59” 的时间,里面每位数字可以重复使用,问组成的下一个时间是多少。 例23:59 —> 22:22

直接暴力

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
class Solution {
public String nextTime(String time) {
StringBuffer res = new StringBuffer();
TreeSet<Integer> set = new TreeSet<>();
for(int i=0; i<5; i++){
if (i == 2) continue;
set.add(time.charAt(i)-48);
}
int point = 0;
// 最后一位
if (set.higher(time.charAt(4)-48) == null) point = 1;
if (point == 1) res.append(set.first());
else res.append(set.higher(time.charAt(4)-48));
// 倒数第二
if (point == 0) res.append(time.charAt(3));
else {
if (set.higher(time.charAt(3) - 48) == null || set.higher(time.charAt(3) - 48) > 5)
res.append(set.first());
else {
res.append(set.higher(time.charAt(3) - 48));
point = 0;
}
}
res.append(':');
if (point == 0) res.append(time.charAt(1));
else {
if (time.charAt(0) == 2) {
if (set.higher(time.charAt(1) - 48) == null || set.higher(time.charAt(1) - 48) > 3)
res.append(set.first());
else {
res.append(set.higher(time.charAt(1) - 48));
point = 0;
}
}
else{
if (set.higher(time.charAt(1) - 48) == null)
res.append(set.first());
else {
res.append(set.higher(time.charAt(1) - 48));
point = 0;
}
}
}
if (point == 0) res.append(time.charAt(0));
else{
if (set.higher(time.charAt(0)-48) == null || set.higher(time.charAt(0)-48) > 2) res.append(set.first());
else res.append(set.higher(time.charAt(0)-48));
}
res.reverse();
return res.toString();
}
}

自己随便测试了一下,应该可行。

Valid Perfect Square

Posted on 2017-07-24 | In Java , Algorithm |

经典的二分查找

1
2
3
4
5
6
7
8
9
10
11
12
public boolean isPerfectSquare (int num){
if (num < 1) return false; //0为啥不算?
long lo = 1; long hi = num; //避免 2147483647
while (lo <= hi){
long mid = (lo + hi) / 2;
long tem = mid * mid;
if (tem == num) return true;
if (tem < num) lo = mid+1;
else hi = mid-1;
}
return false;
}

牛顿迭代法

1
2
3
4
5
6
7
8
public boolean isPerfectSquare (int num){
if (num < 1) return false;
long x = num;
while (x * x > num){
x = (x + num/x) / 2;
}
return x * x == num;
}

还有个神奇的算法,完全平方数都是由 1+3+5+7…构成,所以可以写成

1
2
3
4
5
6
7
8
public boolean isPerfectSquare(int num){
int i=1;
while (num > 0){
num -= i;
i += 2;
}
return num == 0;
}

Product of Array Except Self

Posted on 2017-07-12 | In Java , Algorithm |

脑洞不一样大之神奇算法系列再现。

Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].

Solve it without division and in O(n).

For example, given [1,2,3,4], return [24,12,8,6].

Follow up:
Could you solve it with constant space complexity? (Note: The output array does not count as extra space for the purpose of space complexity analysis.)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
public class Solution {
public int[] productExceptSelf(int[] nums) {
int n = nums.length;
int[] res = new int[n];
res[0] = 1;
for (int i = 1; i < n; i++) {
res[i] = res[i - 1] * nums[i - 1];
}
int right = 1;
for (int i = n - 1; i >= 0; i--) {
res[i] *= right;
right *= nums[i];
}
return res;
}

愣是没看懂什么意思系列= =

评论区看了大神解答,终于看懂了什么意思。假设数组为[2,3,4,5],如果我们要计算res[2],也就是2*3*5,那么计算可以分为 left 和 right 两部分,left为2*3,right为5,而最终只需要计算left * right即可,

可以列表为

1
2
3
Numbers 2 3 4 5
left 1 2 2*3 2*3*4
right 3*4*5 4*5 5 1

所以原代码中

1
res[i] = res[i - 1] * nums[i - 1]

即为计算left部分,2 的 left 是1,3的 left 是第一列 Numbers * left ,4 的 left 是第二列的 Numbers * left,5 的 left 是第三类列的 Numbers * left。

同理计算 right,分别乘的res中,即为所求。

时间复杂度为O(n),而我们把 left 直接存在了res的数组中,免去了单开 O(n) 的空间复杂度,空间复杂度只有right一个O(1)。

再次跪拜脑洞。

Majority Element

Posted on 2017-07-11 | In Java , Algorithm |

Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.

You may assume that the array is non-empty and the majority element always exist in the array.

又是大神级别算法,O(n) time O(1) space fastest solution,比快排一遍找中位数还要快。。给跪

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
public class Solution {
public int majorityElement(int[] num) {
int major=num[0], count = 1;
for(int i=1; i<num.length;i++){
if(count==0){
count++;
major=num[i];
}else if(major==num[i]){
count++;
}else count--;
}
return major;
}
}

顺便附上证明论文:

http://www.cs.utexas.edu/~moore/best-ideas/mjrty/

虽然我知道你们肯定没人看的。

Intersection of Two Linked Lists

Posted on 2017-07-11 | In Java , Algorithm |

看到非常聪明的解法,跟用两个指针判断链表是否存在环有点相同的思想(不想仔细想有什么相同的,只不过有这直觉),当然记录下来,跪倒在天才的脑洞下。

Write a program to find the node at which the intersection of two singly linked lists begins.

For example, the following two linked lists:

1
2
3
4
5
A: a1 → a2
↘
c1 → c2 → c3
↗
B: b1 → b2 → b3

begin to intersect at node c1.

I found most solutions here preprocess linkedlists to get the difference in len.
Actually we don’t care about the “value” of difference, we just want to make sure two pointers reach the intersection node at the same time.

We can use two iterations to do that. In the first iteration, we will reset the pointer of one linkedlist to the head of another linkedlist after it reaches the tail node. In the second iteration, we will move two pointers until they points to the same node. Our operations in first iteration will help us counteract the difference. So if two linkedlist intersects, the meeting point in second iteration must be the intersection point. If the two linked lists have no intersection at all, then the meeting pointer in second iteration must be the tail node of both lists, which is null

Below is my commented Java code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
> public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
> //boundary check
> if(headA == null || headB == null) return null;
>
> ListNode a = headA;
> ListNode b = headB;
>
> //if a & b have different len, then we will stop the loop after second iteration
> while( a != b){
> //for the end of first iteration, we just reset the pointer to the head of another linkedlist
> a = a == null? headB : a.next;
> b = b == null? headA : b.next;
> }
>
> return a;
> }
>

假设A的长度为a+c,B的长度为b+c,指针a走完A的长度再走B一遍,一共走了a+c+b+c,指针b走完B的长度再走了一遍A的长度,一共走了b+c+a+c,于是两个指针a和b必然会在第二遍的公共节点c处相遇。

单单一个机智我觉得已经无法形容了。

Solutions of Power of Three

Posted on 2017-07-04 | In Java , Algorithm |

Found a summary of some solutions of this problem, thought that these are interesting and it is worth to record all these ideas.

Recursive Solution
1
2
3
public boolean isPowerOfThree(int n){
return n>0 && (n==1 || (n%3 == 0 && isPowerOfThree(n/3)));
}
Iterative Solution
1
2
3
4
5
public boolean isPowerOfThree(int n){
if (n>1)
while(n%3 == 0) n /= 3;
return n==1;
}
Other Method 1
1
2
3
4
public boolean isPowerOfThree(int n) {
int maxPowerOfThree = (int)Math.pow(3, (int)(Math.log(0x7fffffff) / Math.log(3)));
return n>0 && maxPowerOfThree%n==0;
}

Or simply hard code it since we know maxPowerOfThree = 1162261467:

1
2
3
public boolean isPowerOfThree(int n) {
return n > 0 && (1162261467 % n == 0);
}

It is worthwhile to mention that Method 1 works only when the base is prime. For example, we cannot use this algorithm to check if a number is a power of 4 or 6 or any other composite number.

Other Method 2

If log10(n) / log10(3) returns an int (more precisely, a double but has 0 after decimal point), then n is a power of 3. But be careful here, you cannot use log(natural log) here, because it will generate round off error for n=243. This is more like a coincidence. I mean when n=243, we have the following result:

1
2
3
4
5
log(243) = 5.493061443340548 log(3) = 1.0986122886681098
==> log(243)/log(3) = 4.999999999999999
log10(243) = 2.385606273598312 log10(3) = 0.47712125471966244
==> log10(243)/log10(3) = 5.0

This happens because log(3) is actually slightly larger than its true value due to round off, which makes the ratio smaller.

1
2
3
public boolean isPowerOfThree(int n) {
return (Math.log10(n) / Math.log10(3)) % 1 == 0;
}
Other Method 3
1
2
3
public boolean isPowerOfThree(int n) {
return n==0 ? false : n==Math.pow(3, Math.round(Math.log(n) / Math.log(3)));
}
Other Method 4
1
2
3
public boolean isPowerOfThree(int n) {
return n>0 && Math.abs(Math.log10(n)/Math.log10(3)-Math.ceil(Math.log10(n)/Math.log10(3))) < Double.MIN_VALUE;
}
Cheating Method

Array:

1
2
3
4
public boolean isPowerOfThree(int n) {
int[] allPowerOfThree = new int[]{1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147, 531441, 1594323, 4782969, 14348907, 43046721, 129140163, 387420489, 1162261467};
return Arrays.binarySearch(allPowerOfThree, n) >= 0;
}

HaseSet:

1
2
3
4
public boolean isPowerOfThree(int n) {
HashSet<Integer> set = new HashSet<>(Arrays.asList(1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147, 531441, 1594323, 4782969, 14348907, 43046721, 129140163, 387420489, 1162261467));
return set.contains(n);
}
Radix-3 Method

The idea is to convert the original number into radix-3 format and check if it is of format 10* where 0* means k zeros with k>=0.

1
2
3
public boolean isPowerOfThree(int n) {
return Integer.toString(n, 3).matches("10*");
}

再战The Big Wheel轮盘赌博

Posted on 2017-07-03 | In Diary |

上个月去了趟LV,迫不及待想把我上次说的方法再次实践一次,去之前几天天天幻想着自己能赚一笔,或许能赚回来学费和一辆车的钱呢(哈哈哈想多了)。

既然分类是日记,就先说一些题外话,LV真是有钱的天堂,沙漠中的明珠。从LA早上开车三小时,看到了电影里那种四周都是戈壁,唯有中间一条马路望不到尽头的画面。有时候想想,或许以后自己能生活在这样的地方,休息的时候出来这种公路上开一开车(当然不是LA与LV这样两个大城市中间),仿佛自己与世隔绝,这才是真正亲身体会到了电影里的感觉。

LV给我的感觉只有一个:金碧辉煌。并不是说豪车有多少,论豪车又有几个地方比得上Beverly Hills,而是建筑风格。LV中心地区几乎全是酒店,每个酒店又各有特色(这里就不上图了,比较网络上图片太多),只要不是全年龄酒店,一楼必定就是赌场,各种财大气粗的黑哥哥和各种衣着暴露的外国妹妹仿佛成了一道亮丽的风景线。有钱人,没钱人和旅游的游客混杂在这个地方,在这个地方仿佛一眼就能看穿每一个人心中的一切拘束与欲望。有钱人有兴致了随手来一把,无论是输是赢都搂着姑娘哈哈大笑,随手给前来送酒的侍女一张钞票;职业赌徒仿佛把这里当做了家,在一个机器面前一坐就是一整天,抽着烟喝着酒,目不转睛盯着屏幕,经验丰富地操作,似乎想在这里走上人生巅峰,或者不稳定地维持着自己的生计,赢了大钱还会转头对我咧嘴笑一下,看到我差一点就赢钱也会对我发出可惜的感叹;游客是典型的另类,各国面孔游走在各个酒店的赌场当中,中老年人带着子女四处漫步,有的有时会停在某些机器面前看别人玩看好久,然后又无动于衷继续前进,而更多的年轻人则会掏出十几美元,即兴来参与。记得旁边一对情侣,女的赢钱了就站起来开始跟着大厅的音乐摇摆身体,而太过于激动撞倒了椅子,被男的尴尬地拉起来。大部分年轻人还是可以克制自己,最多十几美元,输光了就走了也不留恋,没输光也可能停下来拿了剩下的钱走人,赢了也不贪心,取了钱就高高兴兴离开。我因为玩Big Wheel,坐在椅子上可以说坐了整整一天,闲暇时看着每一个路过的人,看着他们,仿佛看遍了社会上的百态人生,每个人内心的欲望虽然没有写在脸上,却踏踏实实表现在了行动中,从中仿佛看到了百态人生中的每一种不同的快乐与艰辛。

闲扯了这么多,终于要进入主题了。根据上一篇文章的分析,我这次进行了实践。跟我五年前在澳门不同,这次的The Big Wheel选择了压25而不是12,原因是因为我观察了很久,发现12太坑了……..即使12的数量比25多,但出现的次数甚至比不上25….下面摆上数据(不完整),以25开头,而后继续观察,括号里为两个25中间所出现别的数字的次数。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
25
1 3 1 1 3 1 12 1 1 1 1 1 1 25 (13)
3 1 1 12 1 6 6 1 12 6 3 1 25 (12)
1 3 3 3 1 1 25 (6)
3 1 1 12 1 25 (5)
3 6 6 1 6 1 1 25 (7)
1 1 6 1 1 25 (5)
6 3 1 6 25 (4)
1 1 1 6 1 1 3 1 1 1 1 12 3 3 1 1 50 6 6 1 12 3 1 1 1 3 6 12 1 (29 未完)
3 12 12 1 6 1 1 3 25 (8)
1 6 1 1 1 1 1 1 1 1 6 1 1 1 3 1 1 6 1 25 (19)
6 1 3 6 25 (4)
1 52 1 52 52 1 1 1 12 1 3 1 3 6 3 1 1 3 3 1 1 1 12 12 1 52 3 1 3 1 25 (30)
1 12 1 1 3 52 1 1 1 1 25 (10)
1 1 3 1 6 25 (5)
3 1 3 1 1 3 1 1 1 6 1 1 3 25 (13)
3 1 6 1 3 1 1 6 1 1 1 6 3 12 1 6 12 6 52 3 52 1 1 1 6 1 3 3 6 1 1 1 3 25 (33)
25 (0)
1 3 6 3 6 1 6 1 6 6 3 3 6 1 52 1 1 3 3 1 3 1 12 12 1 52 6 25 (27)
12 3 6 1 6 3 1 3 1 6 12 3 12 6 1 1 1 1 3 1 1 1 3 1 1 25 (25)
1 12 1 3 1 52 1 3 1 6 1 1 1 1 6 1 1 3 12 1 3 1 1 12 3 1 1 1 3 1 3 3 1 25 (33)
52 3 1 1 1 3 1 6 3 1 1 1 12 3 12 1 1 3 6 1 1 6 1 3 1 25 (25)
1 1 6 1 1 1 1 3 6 6 6 1 3 1 1 1 6 6 3 1 12 12 6 6 3 3 1 1 6 6 3 52 3 1 1 1 3 3 1 1 6 1 3 1 1 1 3 1 1 3 1 12 3 3 6 (55 未完)

以上是两个不同赌场的机器的数据汇总,其实据我观察两者数据差不多,所以就没有细分。

当我刚去的时候在第一个机器面前坐了一个小时,就是为了记录数据,记录下了第一个系列

1
13 12 6 5 7 5 4 29

看起来很不可思议吧,25作为转盘上仅有4个的数字,出现频率竟然如此之高。记录下来前几个的时候我简直不敢相信,平均下来每隔7.4次就出一次25,让我怀疑,然而亲眼所见又不得不服。最后一个29打破了我的疑惑,终于出现一个正常数字了,之后就没记录了,我就有事离开了。

由于再次回来时换了个赌场,于是我不得不重新观察一下数据,不敢直接套用上一个机器的数据记录下了前三组

1
8 19 4

两个小于10的数字你敢信?!但我为了稳妥,还是选择了15作为切入点,也就是说第15个数字还没有出现25的时候,开始从第16个开始压25,这样我拥有的误差范围大概在41,只要41个数字以内出现25,我就是赚,据我当时观察,还没出现过超过41以上的范围,真的感觉自己是稳定收入啊(对自己的算法迷之自信)。

拿出口袋里仅有的16美元现金,以以前的观察来看,即使31也已经觉得不太可能这么晚,所以必定能赢回来,然而……………..

没错,下一个数字是30…….我从16开始压,我身上就16块钱,当我前15个都没中的时候,我真觉得自己的赌场生涯还没开始就要结束了,感觉我中了头号彩票…….根据之前的记录30次不出现真的概率太小了…….然而事实再次愚弄了我 ,我在最后一块钱的时候中了……….我甚至以为自己已经结束了的时候中了………这是上天给我开的玩笑吗??? 于是我有了26块钱,我的本金多了起来,允许的误差范围也就更大了。

套路我已经讲过了,剩下的就只有赢钱啦,本金太少,只能1块1块压也是没办法的事情,后期我觉得更稳的时候开始压2块3块,相当于一次中2次或者3次,压缩了时间。值得一提的是,根据我观察后来的数据,没错,我边玩还在边数….我把自己的15改成了20,因为后来的数据表示20貌似更靠谱一点。

但是,我以为自己走上人生巅峰的时候,意外发生了………………

其中有一次很久很久没出25,没错,我开始找退路,开始压flag或者是joker(52),幸好中了一次(这其中有别的方法,也有运气)……..还有那就是最后一个55,直到我走的时候都没有出现25………….这种小概率事件碰到了只能说是倒霉吧,但只要本金足够,还是可以弥补回来这些损失的。

顺便放上我本金的变化

1
16 26 32 45 60 62 124 174 163 209 183 230 190

没错,最后一次就是因为那个55,从230亏成了190。也就是我本金太可怜,才最后变成了200刀,距离我学费车费目标还是挺大,但是换个思路,若是我本金当初是1600刀,最后我岂不是有23000刀?!但是就算我有1600刀,我敢不敢100刀100刀来压那就是外话了(笑)。

期待下次去LV,估计早已经毕业了,那就一定把车费赚回来!

12
Ucm

Ucm

19 posts
6 categories
18 tags
GitHub Zhihu Weibo
© 2017 - 2019 Ucm
Powered by Hexo
Theme - NexT.Muse