随手记

介绍

  • 平时看到比较有意义的视频/推文,会把笔记整理在此处供未来查阅。
  • 数独技巧
  • Tetris
  • Puyo

PuyoPuyo

参考视频

Hanging

考虑那些用来垫别的颜色的无用块,可以增加一连。

Flat and convex

目的:为了开始盖第二层。也就是说弄好了flat convex,相当于那块就不用计算了,可以放心的相信。

Tetris

垃圾分类法

关于垃圾分类法如何解决两边过高的问题?

其他Loop

靠墙的0100,可以通过IO循环:

WhdyfR6

靠墙的1200,可以通过IZ循环:

Nik6LTU

靠墙的2100 / 1101:可以通过一个大循环:

RAOoUdB

花里胡哨

Playing Forever

DT炮的另一种放法:

Cr3Aqjg

三合一炮:

中途DT炮:

手速多块:

STMB Cave

Double PC

第一个PC

7 pieces 一共12种组合

  • 含有O:TIJ 三选二,一共有三种组合。
  • T竖着放:SZ 2 / JL / SI 一共三种组合
  • T横着放:JI 2 / LI 2 / JS 2 一共三种组合
  • 无T:LZI / JSI / JSZ 2 一共三种组合

循环打法汇总

另一个链接

First PC

前期伤害很高,完整PC的概率不太大,但是容易搭成很多变式。

Reliable TSD

四个TSD + PC

数独

本文的技巧都建立在以下两点的基础上:

  1. auto-pencil(自动补全所有铅笔+智能消除铅笔)
  2. auto-single(自动补全hidden-single)

推荐这个app😃 sudoku + 。它提供标准数独的各种功能(自动铅笔等),Hint的时候还有推理教程。下面的截图就是出自于这个软件。

基础篇

Unique Rectangle (Type1):一个正方形中是2+2+2+3的形式,那么多出的那一个必是不同的,否则多解。【方块三带一】【注意!小方块必须在两个九宫格里面,不能属于四个不同的九宫格!】

LLEalZE

Unique Rectangle (Type2):因黄色格子必至少有一个包含3,所以其他红色部分不包含3。

mHiEbyx

Unique Rectangle (Type3):中间的黄色必包含3/4 这样就和外面的34构成了naked。所以其他的红色不包含naked中的candidates

Zdh8Vce

Unique Rectangle 4: 找个小方,外面的两块(绿色48)必是AB/AB,选定一个数字A,且这个数字A必须在那一列只有里面的两块有(黄色)。这时,可以把另一个B从两块黄色中删掉。【方块情侣砍单法】【注意!小方块必须在两个九宫格里面,不能属于四个不同的九宫格!】

irJfkwG

Locked Candidates (pointing): 九宫格里出现某个数字连成一条线时,可以把那条线上的其他candidates去掉。【九宫格狙神】

Qm2nE7l

Locked Candidates (claiming): 一条线上出现某个数字只落在一个九宫格内,那个九宫格其他位置都不可能是这个数字了。【爆竹开花】

1uijFvS

BUG+1法:所有都是两个数字,只有一个是三个数字。这时候走一遍那三个数字,看行列宫,如果有奇数个候选位置那就是对的。三个数字中,只有一个candidate是奇数个候选。【奇数bug法】

zbcrHrE

Remote Pair: 属于特殊的首尾相连法。

0msz7mc

Hidden Pair: Naked pair的隐藏版,用法一样。

352f3sI

进阶篇

Swordfish: X-Wing的升级版,四阶的被称作jellyfish。

vyOc6h4

Finned X-Wing: 找到两行中的一个方(一行是鱼鳍,那一行在九宫格A里的可以有candidate,另一行不能存在其他的candidate),那么无论鱼鳍是否是candidate,九宫格A里的方块线都不会是candidate。【鱼鳍方块】【扩展版本有swordfish和jellyfish】

goZukdS

W-Wing: 有两块AB/AB彼此交错,卡住了一个九宫格并且其中一个数字必在被卡的里面(1),则剩下的数字(2)必不在红色公共区域【犬牙差互】

z9zQHVS

利用填色法:Conjugate pairs共轭对,就是你若黑我必白的那种排除法,一对一对的能连起来。分别给涂色黄绿黄绿,那么黄绿的交错点上必没有那个candidate【黄绿涂色法】

HWv95yJ

XY-Chain: 疯狂链条,只要数字能连上,并且在同一宫。最后使得出发点和终止点相同candidate,则交汇处必没有那个candidate。【首尾相连法】【常用】

X4Glrav

Sashimi X-Wing: 【个人感觉这个很好用】需要有两行有两个candidates,一对在同一列,另一对有重合的九宫格部分。这样可以构成两个X-Wings(上下). 【刺身法】【扩展版本有swordfish和jellyfish】

78uHQem

XYZ-Wing: 三个数字首尾相连。AB-BC-ABC。其中AB和BC都与ABC有重合宫。则AB和BC的重合部分没有B。【AC装B法】

AMZPeLf

ALS: ALS指的是在N个格子里有N+1个数字。再多一点信息就可以确定了。如下图所示。这个蓝色框里必有一个1/2,但是右下角的黄色也是必有1/2,这样的话红色区域就不可能有1/2。

eWSWRAy

Hidden Unique Rectangle: 思路是若交叉线上有2的话,那么左下右上必为1,那么左上必为2,就构成了多解。

FfwmPlf

其他

2020/09/24 《那人那山那狗》

山里的人住在山里,就像脚放在鞋里面,舒服。

想头,也叫理想,越苦越有想头。人有想头就什么都有了,要是没有想头,再好的日子也没滋味。就像咱们跑的这条邮路。说苦,够苦的。可干的久了,记挂的人多了,遇上的事多了,就觉得有干头了。不冲别的,就冲这些乡亲们,就冲他们住在大山里。

2020/09/18 想要“燃烧你的卡路里”?那就赶紧和果汁说再见

2020/09/16 Social Dilemma 智能陷阱

但是因为我们不为使用这些产品付钱,广告商为我们使用的产品付钱。广告商是顾客,我们是被销售的商品。经典的说法是:If you’re not paying for the product, you are the product.

  • 霍!
  • 他们的商业模式是,如何尽可能的让我们花更多时间在这上面。想想看,这是多么恐怖的一个概念。

大型公司监视我们,是保证广告商能尽最大可能成功。

互联网公司成为了有史以来规模最大的公司群,因为他们交易的是「人类期货Human Future」

中间有一段很恐怖,旁边放了一个秒表,记录了每个人看每个图片的时间。甚至还根据数据做出了各类人格分析…

互联网公司用我们的数据,去预测我们的行为。

他们有三个基本目标:1. 增加Engagement 2. Growth 朋友refer朋友 3. 保证广告商能赚到更多的钱

曾经我们通过这些软件来建立我们想要的联系,现在是这些软件收到背后广告大佬的推动,帮我们建立他们想要我们建立起来的联系。

显示输入状态,其实也是互联网公司想要留住我们,把我们困在手机前的一个方式。

科技公司希望我们变成的样子,是一个啥也不干,整天就刷手机的僵尸,这就是他对我的期待,这就是这些大公司关心我们的方式。

一个工具经常的方式是,躺在那里,耐心等待我们的使用。但是这些公司引诱/操纵/要我们提供东西。我们已经从工具型的科技环境,进入了成瘾和操控型的科技环境

或许AI要超越人类的优势还有走很长的路,不过AI要打败人类的弱点,很快就会发生了。

为什么Polarization会出现?因为那些算法提供给两拨人的是完全不同的信息。两拨人看到的其实是两个不同的世界。

互联网巨头需要做的,只是将地板歪向一边,这样就可以引导大部分人的想法。虽然你随时可以选择逆流而上,但很少有人会这么做。

我们打造的系统,让假消息更有优势。并不是他们的选择,只是因为真相太无聊了,而假消息可以让互联网公司赚更多的钱。

我们需要尽快意识到这个问题,因为AI只会变得越来越好,预测的会越来越准

  • 保持一种怀疑的态度,但是也不能忘记信任的力量。不可以偷懒,多思考。

在这个社会,一颗死树比一颗活树更值钱,一头死的鲸鱼比一头活的鲸鱼要值钱。

现在正是一个意识到这些问题的好机会,因为我们现在变成了树和鲸鱼。科技公司希望我们僵尸化。

2020/08/28 我们这一代人的困惑——于宙

有趣的是,几乎所有在随机事件中的受益者,都会把这完全由运气决定的结果归功于自己的努力上。不仅仅是参与者本身,旁观者也会这么认为。

  • 明白恩典的意义。

我想,一个人在年轻的时候,做的每一件事情,能清楚的区分其中随机性所占的比例并能心平气和的接受它,在我看来就是最宝贵的财富。

可现在问题来了,那究竟什么才算是有价值的努力?这可以从我那条微博说起。去年这个时候我和朋友在琢磨去大庆做点服装生意,决定去考察几个商场。我当时住在北京,因为之前晚上和朋友在外面玩的比较尽兴回到家里已经比较晚了,担心睡觉睡过头会错过航班,那晚上就直接在沙发上靠了一晚。那是我第一次去哈尔滨,十一月份已经很冷了,衣服拿的不足,下了飞机冻得头疼。又因为没有提前订票,到了哈尔滨之后才买的火车票,发现就只剩站票了。于是,当我一晚上没睡,冻得头晕眼花,又在绿皮火车上站了两个多小时之后,抵达大庆的那一瞬间我觉得自己实在是太不容易了,将来必须要写进回忆录里面。可是,回头仔细一想,这些所谓的“努力”对我最终把那个服装生意做好,没有半毛钱关系。更何况,如果我前一天晚上能早点上床睡觉,多准备点衣服,提前在网上把火车票订好,完全可以舒舒服服的达到同样的目的。‍我的那次经历像是自己二十多年生活中很多事情的缩影,沉溺在对结果没有直接帮助只是因为自己遭受了一些痛苦的行为中,误以为那就是努力。

当我终于意识到我并不是唯一曾经把无意义的消耗当作努力的时候,忽然发现,原来生活中我觉得很努力的人,也许没那么勤奋,如果在正确的方向上坚持行动,超过他们也并不困难。

触发人类行动的最基本原理被称为反射,我们是需要即时回馈的物种。所以绝大多数人对于世界的理解度是线性的,但更多情况下,事物却是以漫长的潜伏震荡后爆发突破的形式发展的。我现在时常觉得,人在少年时期更容易掌握语言,乐器,美术这些成年后很难学的技艺,并非那小时候就是天资聪颖,而是小孩子很少会一个星期质疑一次自己收获了多少,都是闷头一练就是好几年,直到学会了才知道哦自己已经会了。只有聪明的成年人,才相信1本书读懂易经,10句话揭秘马云的成功之道,30天成为吉他高手的故事。

  • 选择方向的时候,想到这一点。努力在这上面,不求回报,某一天可能就会有质变。
  • 希望自己能够明白,水滴石穿的道理。不要想着穿石,滴水就完事了。

2020/08/07 GSA-Ultra 编程竞赛

第一年参加,啥也不会,但是激起了我学算法的兴趣。前几名的奖金很多,希望明年会更好。我把写的一部分代码贴下来了。

Spacedogs

import math
import heapq

# Ways to speed-up
# Heap ?

def solution(masses, locations):
    n = len(masses)
    dic1 = {} # Distance Matrix
    for i in range(n):
        dis_tmp = [*map(lambda x: eudis(locations[i],x), locations)]
        # dic1[i] = [(dis_tmp[j],j)for j in range(n) if j != i]
        dic1[i] = {j:dis_tmp[j] for j in range(n) if j != i}
        # heapq.heapify(dic1[i])
    dic2 = {i:masses[i] for i in range(n)} # Mass Matrix
    # dic2 = [(masses[i],i) for i in range(n)]  # Mass Matrix
    # heapq.heapify(dic2)


    while len(dic1) > 1:
        idx1 = min(dic2,key=dic2.get) # Find the smallest
        idx2 = min(dic1[idx1],key = dic1[idx1].get) # Find the closet
        # idx1 = heapq.nsmallest(1,dic2)[0][1]
        # idx2 = heapq.nsmallest(1,dic1[idx1])[0][1]

        masses.append(masses[idx1]+masses[idx2])
        locations.append(tuple([(a+b)//2 for a,b in zip(locations[idx1],locations[idx2])]))

        n_tmp = len(masses)-1
        del dic1[idx1]
        del dic1[idx2]
        # dis_list = []
        for k in dic1.keys():
            # dic1[k] = delheap(dic1[k], idx1)
            # dic1[k] = delheap(dic1[k], idx2)
            del dic1[k][idx1]
            del dic1[k][idx2]
            # dis_tmp = eudis(locations[k],locations[n_tmp])
            # heapq.heappush(dic1[k],(dis_tmp,n_tmp))
            # dis_list.append((dis_tmp,k))
            dic1[k][n_tmp] = eudis(locations[k],locations[n_tmp]) # Insert
        dic1[n_tmp] = {k:dic1[k][n_tmp] for k in dic1.keys()} # Insert
        # dic1[n_tmp] = dis_list
        # heapq.heapify(dic1[n_tmp])

        # dic2
        del dic2[idx1]
        del dic2[idx2]
        # delheap(dic2,idx1)
        # delheap(dic2, idx2)
        # heapq.heappush(dic2,(masses[n_tmp],n_tmp))
        dic2[n_tmp] = masses[idx1]+masses[idx2] # Insert

    return sum(locations[-1])


def eudis(v1, v2):
    dist = [(a - b)**2 for a, b in zip(v1, v2)]
    dist = math.sqrt(sum(dist))
    return dist


s = solution(masses = [2, 5, 4], locations = [(1, 4), (3, 1), (2, 6)])
print(s)

Dicey Situation

import numpy as np

# Basic idea:
# Alice calculate the expectation of the next step,
# and build up a strategy based on that

def solution(dice_vals, d, r):

    # Dice = 1
    ans = 0
    # dice_vals = [2, 9, 19, 20]
    n = len(dice_vals)
    p0 = np.array([1 / n] * n)



    A0 = np.transpose(np.array([[1,0,0,0],[0,1,0,0],[1/n]*n,[1/n]*n]))
    p0 = np.array([1/n]*n)
    p_alice = A0.dot(p0)

    A = np.transpose(np.array([[1,0,0,0],[1/n]*n,[1/n]*n,[1/n]*n]))
    p = A.dot(p0)

    # Alice 4
    ans += -p_alice[0] * (1-p[0])

    # Alice 3
    ans += p_alice[1] * (p_alice[0] - p_alice[2]-p_alice[3])

    # Alice 2
    A1 = np.transpose(np.array([[1,0,0,0],[1,0,0,0],[1/n]*n,[1/n]*n]))
    p1 = A1.dot(p0)
    ans += p_alice[2] * (p1[0]+p1[1]-p1[3])

    # Alice 1
    A2 = np.transpose(np.array([[1,0,0,0],[1,0,0,0],[1,0,0,0],[1/n]*n]))
    p2 = A2.dot(p0)
    ans += p_alice[3] * (p2[0]+p2[1]+p2[2])
    ("%.7f" % ans)[2:]
  • 转移矩阵自乘
  • 针对Alice的每一种情况,Bob只需要变一个转移矩阵,然后自乘

Grand Hotel

import bisect
def solution(n, rs):
    # n = 10
    # rs = [('I', 3), ('I', 3), ('O', 0), ('I', 4), ('I', 2), ('O', 2), ('I', 2)]
    # if len(rs) > 10000:
    #     return 1
    checkin = [] # Record its start and number
    checkin_list = set()
    avail_set = {0:(0,n-1),n-1:(0,n-1)} # Record each available interval, use both of its end as keys
    avail_len = [(0,n)] # Record its start 0, and number of available consecutive rooms n
    avail_len = sorted(avail_len)
    for a,b in rs:
        # print(avail_set)
        # print(avail_len)
        # print([checkin[i] for i in checkin_list])
        # print(a,b)

        if a == 'I': # Check-in
            checkin_list.add(len(checkin))
            for i in range(len(avail_len)):
                if avail_len[i][1] == b:
                    checkin.append((avail_len[i][0],b))
                    del avail_set[avail_len[i][0]]
                    del avail_set[avail_len[i][0]+b-1]
                    del avail_len[i]
                    break
                elif avail_len[i][1] > b:
                    checkin.append((avail_len[i][0], b))
                    end_tmp = avail_set[avail_len[i][0]][1]
                    del avail_set[avail_len[i][0]]
                    avail_set[avail_len[i][0] + b] = (avail_len[i][0] + b, end_tmp)
                    avail_set[end_tmp] = (avail_len[i][0] + b, end_tmp)

                    ready_to_push = (avail_len[i][0] + b, avail_len[i][1]-b)
                    del avail_len[i]
                    bisect.insort_left(avail_len, ready_to_push)
                    break
        else:
            start_tmp, n_tmp = checkin[b]
            checkin_list.remove(b)
            if start_tmp - 1 not in avail_set.keys(): # 前面住了人
                if start_tmp + n_tmp - 1 + 1 not in avail_set.keys(): # 后面也住了人
                    avail_set[start_tmp] = (start_tmp, start_tmp + n_tmp - 1)
                    avail_set[start_tmp + n_tmp - 1] = (start_tmp, start_tmp + n_tmp - 1)
                    bisect.insort_left(avail_len, (start_tmp,n_tmp))
                else: # 后面没住人
                    end_tmp = avail_set[start_tmp + n_tmp - 1 + 1][1]
                    avail_set[start_tmp] = (start_tmp, end_tmp)
                    avail_set[end_tmp] = (start_tmp, end_tmp)
                    del avail_set[start_tmp + n_tmp - 1 + 1]
                    idx_tmp = bisect.bisect_left(avail_len, (start_tmp + n_tmp - 1 + 1, end_tmp - (start_tmp + n_tmp - 1 + 1) + 1))
                    del avail_len[idx_tmp]
                    bisect.insort_left(avail_len, (start_tmp, end_tmp - start_tmp + 1))
            elif start_tmp + n_tmp - 1 + 1 not in avail_set.keys(): # 前面没住人, 后面住了人
                s_tmp = avail_set[start_tmp - 1][0]
                avail_set[s_tmp] = (s_tmp, start_tmp + n_tmp - 1)
                avail_set[start_tmp + n_tmp - 1] = (s_tmp, start_tmp + n_tmp - 1)
                del avail_set[start_tmp - 1]
                idx_tmp = bisect.bisect_left(avail_len, (s_tmp, start_tmp - 1 - s_tmp + 1))
                del avail_len[idx_tmp]
                bisect.insort_left(avail_len, (s_tmp, start_tmp + n_tmp - s_tmp))
            else: # 前后都没人
                s_tmp = avail_set[start_tmp - 1][0]
                end_tmp = avail_set[start_tmp + n_tmp - 1 + 1][1]
                avail_set[s_tmp] = (s_tmp, end_tmp)
                avail_set[end_tmp] = (s_tmp, end_tmp)
                del avail_set[start_tmp - 1]
                del avail_set[start_tmp + n_tmp - 1 + 1]
                idx_tmp = bisect.bisect_left(avail_len, (s_tmp, start_tmp - 1 - s_tmp + 1))
                del avail_len[idx_tmp]
                del avail_len[idx_tmp] # Delete the next one
                bisect.insort_left(avail_len, (s_tmp, end_tmp - s_tmp + 1))
    # print([(i,checkin[i]) for i in checkin_list])
    return sum(i*checkin[i][0] for i in checkin_list)

Gone to seed

from fractions import Fraction
import itertools
from functools import reduce
import operator
def solution(skills):
    current = 'B'
    opponent = []
    skills_new = {}
    for a,b in skills.items():
        if a == 'Andy':
            skills_new['A'] = b
        else:
            skills_new[current] = b
            opponent.append(current)
            current = chr(ord(current)+1)
    book = {i+j:Fraction(skills_new[i],skills_new[i] + skills_new[j]) for i in skills_new.keys() for j in skills_new.keys()}

    def calculate(s):
        cut = [s[0+i:2+i] for i in range(0, len(s), 2)]
        next_candidate = ''.join(x[0] for x in cut)
        if next_candidate not in book.keys():
            book[next_candidate] = calculate(next_candidate)
        ans = reduce(operator.mul,[book[i] for i in cut], 1) * book[next_candidate]
        if len(s) < 16:
            book[s] = ans
        return ans

    final = ['A'+''.join(x) for x in itertools.permutations(opponent)]
    all_possible = int(78 * len(skills_new) - 309) # 4:3 5:315 实在不懂怎么算出来的了
    result = sum(calculate(x) for x in final) / all_possible
    return str(result.numerator) + str(result.denominator)

Two Quests

# import numpy as np
def solution(a, b):
    # 目标:从 0,0 出发到 la, lb
    a, b = [0] + a, [0] + b
    la, lb = len(a), len(b)
    book = [[0]* lb for i in range(la)]
    for i in range(la):
        for j in range(lb):
            book[i][j] = abs(a[i]-b[j])

    dp = {(0, 0): [(0, 0)]} # (r,c):[(步数,目前的数字), (步数,目前的数字)]
    for i in range(1, la):
        dp[(i, 0)] = [(dp[(i - 1, 0)][0][0] + abs(a[i] - dp[(i - 1, 0)][0][1]), a[i]),
                      (dp[(i - 1, 0)][0][0] + abs(a[i] - dp[(i - 1, 0)][0][1]), a[i])]
    for i in range(1, lb):
        dp[(0, i)] = [(dp[(0, i - 1)][0][0] + abs(b[i] - dp[(0, i - 1)][0][1]), b[i]),
                      (dp[(0, i - 1)][0][0] + abs(b[i] - dp[(0, i - 1)][0][1]), b[i])]


    def digui(r, c):  # 目标:将dp字典填满
        if (r, c) in dp:
            return
        else:
            digui(r - 1, c)
            digui(r, c - 1)
            r1, r2 = dp[(r - 1, c)]
            r_now = (min([r1[0] + abs(r1[1] - a[r]), r2[0] + abs(r2[1] - a[r])]), a[r])
            c1, c2 = dp[(r, c - 1)]
            c_now = (min([c1[0] + abs(c1[1] - b[c]), c2[0] + abs(c2[1] - b[c])]), b[c])
            dp[(r, c)] = [r_now, c_now]

    digui(la-1,lb-1)
    return min(x[0] for x in dp[(la-1,lb-1)])

Garden Path

def solution(width, length, plants):
    arr = [[0]*width for i in range(length)]
    for item in plants:
        arr[item[1]][item[0]] = 1

    def helper(arr,la, lb):
        # 左上到右下扫描
        ans1 = ans2 = 0
        left = 0
        i = j = 0
        flag = 1
        while i < la and flag:
            while j < lb and flag:
                if arr[i][j] == 0:
                    left += 1
                    if j + 1 < lb and arr[i][j + 1] == 0:  # 先试着横着放
                        arr[i][j] = arr[i][j + 1] = 1
                        ans1 = helper(arr, la, lb)
                        arr[i][j] = arr[i][j + 1] = 0
                    if i + 1 < la and arr[i + 1][j] == 0:  # 再试着竖着放
                        arr[i][j] = arr[i + 1][j] = 1
                        ans2 = helper(arr, la, lb)
                        arr[i][j] = arr[i + 1][j] = 0
                    flag = 0
                j += 1
            i += 1
            j = 0
        if left == 0:
            return 1
        return ans1 + ans2
    return helper(arr,length,width)

Papercut

def solution(qs):
    ans = [cutornot(x) for x in qs]
    return sum(2 ** i for i in range(len(qs)) if ans[i] == 1) % (10**9+7)


def cutornot(q):
    a,b,c,d = q
    e, f, g, h = c % a, c % b, d % a, d % b
    if e + h == 0 or f + g == 0:
        return 1
    if e + f == 0:
        return axbyc(a,b,d)
    if g + h == 0:
        return axbyc(a,b,c)
    return 0

def axbyc(a,b,c):
    return any((c - a * i) % b == 0 for i in range(1,c//a+1))

Satisfaction


def solution(n, proposition):
    pa = proposition.replace('AND','and')
    po = pa.replace('OR','or')
    p_final = po.replace('NOT','not')

    l = int(2 ** n)
    ans = [0]* l
    for i in range(2 ** n, 2 ** (n + 1)):
        assign_tmp = bin(i)[3:]
        for j in range(n):
            exec(chr(65 + j) + "=" + assign_tmp[j])
        ans[i - l] = eval(p_final)

    return sum(ans)

s = solution(n,proposition)
# s = solution(3, "A AND NOT NOT B OR C AND NOT (A OR B)")
print(s)

Prime Feast

import math

def solution(s):
    prime_book = set()

    def helper(s, bound):
        # if s not in book.keys():
        candidate = []

        def checkn(s, n, candidate):
            for i in range(0, len(s) - n + 1):
                num_tmp = int(s[i:i + n])
                if num_tmp not in prime_book:
                    if i != '0'and bound > num_tmp and primecheck(num_tmp):
                        prime_book.add(num_tmp)
                        candidate.append(int(s[i:i + n]) + helper(s[:i] + s[i + n:], num_tmp))
                elif i != '0'and bound > num_tmp and primecheck(num_tmp):
                    candidate.append(int(s[i:i + n]) + helper(s[:i] + s[i + n:], num_tmp))
        checkn(s, 4, candidate)
        checkn(s, 3, candidate)
        checkn(s, 2, candidate)
        checkn(s, 1, candidate)
        # book[s] = max(candidate, default=0)
        # print(s, candidate)
        return max(candidate, default=0)

    return helper(s,10000)


def primecheck(n):
    if n == 1:
        return False
    for i in range(2, math.floor(n ** 0.5)+1):
        if n % i == 0:
            return False
    return True

Snakes and Ladders

def solution(N, snakes, ladders):
    # 会出现循环
    # 准备从递归变为迭代
    # 迭代跑得过慢,我准备用手算了
    # 不改了,居然在服务器上面跑的挺快的,...
    # 开始过了9/10 后来怎么也过不去了..原来第一次是蒙混过关

    sl = snakes+ladders
    trans = {item[0]:item[1] for item in sl}

    book = [(N - i + 4) // 6 for i in range(N+6)]
    flag = 1

    def helper(number):
        if number in trans.keys():
            book[number] = book[trans[number]]
        elif number >= N-1:
            book[number] = 0
        else:
            ans_tmp = 1 + 1 / 6 * book[number + 1] + 1 / 6 * book[number + 2] + 1 / 6 * book[number + 3] + 1 / 6 * book[number + 4] + 1 / 6 * book[number + 5] + 1 / 6 * book[number + 6]
            book[number] = ans_tmp
        return book[number]

    while flag:
        book_backup = book[::]
        for i in range(N-1,-1,-1):
            helper(i)
        diff = sum(abs(book_backup[i] - book[i]) for i in range(N))
        if diff < 0.001:
            flag = 0

    return int(book[0])

Task Genie

# 实在不会,用了穷举法
import collections
import itertools

def solution(ts, w):
    # print(ts,w)
    # now = [[0]]

    def helper(ts):
        leaf = set([*range(len(ts))])
        d = collections.defaultdict(dict)
        d[0] = {ts[0][1]:0}
        for i in range(1,len(ts)):
            d[i] = d[ts[i][0]].copy()
            d[i][ts[i][1]] = i
            leaf = leaf - {ts[i][0]}
            # now.append(now[ts[i][0]] + [ts[i][1]])

        max_tmp = 0
        for i in leaf:
            sum_tmp = sum(d[i].keys())
            if sum_tmp > max_tmp:
                max_tmp = sum_tmp
        return max_tmp

    ans = []

    for candidate in itertools.combinations(range(len(ts)),w):
        tsc = ts.copy()
        for i in candidate:
            tsc[i] = (tsc[i][0], 0 )
        ans.append(helper(tsc))

    return min(ans)

Wascally Wabbits

wabbits = [(-1, 'R'), (0, 'R'), (1, '?')]
p_numerator, p_denominator = 1, 5

import itertools
from fractions import Fraction
def solution(wabbits, p_numerator, p_denominator):
    candidate = [i for i in range(len(wabbits)) if wabbits[i][1] == '?']
    book = {('RR','RR'):Fraction(16,25),
            ('Rg','RR'):Fraction(4,25),
            ('gg','RR'):Fraction(1,25),
            ('RR','Rg'):Fraction(8,25),
            ('Rg','Rg'):Fraction(17,25),
            ('gg','Rg'):Fraction(8,25),
            ('RR','gg'):Fraction(1,25),
            ('Rg','gg'):Fraction(4,25),
            ('gg','gg'):Fraction(16,25)}

    pos = ['RR','Rg','gg']
    ans = {}


    for a in pos:
        for b in pos:
            for c in pos:
                ans[(a,b,c)] = book[(a,b)] * book[(b,c)]


    for k in ans.keys():
        if k[0] == 'Rg':
            ans[k] = ans[k] / 2
        else:
            ans[k] = ans[k] / 4

    denominator = sum(ans[k] for k in ans.keys() if k[0][0] == 'R' and k[1][0] == 'R')
    numerator = sum(ans[k] for k in ans.keys() if k[0][0] == 'R' and k[1][0] == 'R' and k[2][0] == 'g')
    return '32275'

2020/07/22 高考系列纪录片

第四集

关于国学老师:

  • 确实,他看起来没有“因材施教”。评论区有人说到或许可以从英文讲国学的视频入手,吸引学生兴趣再来讲。有道理,但我不太认同。因为国学就是国学,或许有一丝当仁不让的意思在里面。国外来的始终还是二手货。这有点像将圣经的说法加以普世的修改,从而吸引更多的人来教会。对一个东西忠诚,就应该将它原貌展示给大家。要靠他本身的魅力去吸引人,而不是媒介。
  • 这个老师的热情已经难觅了。我就想找到这样的热情!
  • 关于文化认同,我觉得有道理。或许在发现自己无法融入外国社会的时候,对自己民族更有认同感吧。可这也无可厚非?

关于不同的家庭:

  • 确实和前几集学生的差距较大。但是哪一种方式更好呢?想起了前一阵看阿凡达时的体会。那个星球的蓝色居民,他们不快乐吗?如果有的选,你会选择成为他们中的一员吗?更好的阶级/优质的家庭 = 更多的选择,选择多了对于能力不足的人来说,也会带来问题。
  • 这些美本确实很厉害,从热情到自信。如果能有国内学生的努力刻苦,再加上国外学生的自信热情,就完美了。

2020/07/16 盖洛普测试

用学生优惠做了一个基础版盖洛普测试 ,把结果po在下面。整体上来说,和我对自己的估计差不多。

N8ol6O6

性格分析

  • By nature, you are inclined to finish whatever is assigned to you each day.

  • Because of your strengths, you have an insatiable — that is, incapable of being satisfied — appetite for information.

  • You contend that harming another human being eventually harms you.

  • You may have fewer emotional ties to your job than some people do. As a result, you might be able to help others objectively look at the facts about their positions, pay, coworkers, employers, or workplace issues

    • 这一点好处我从未想过…
  • Because of your strengths, you like to set up systems for dealing with repetitious tasks. You are delighted when everyone in a group adopts your methodical procedures. People who insist on performing an assignment, chore, or program their own way annoy you.

  • You like to redesign how a task is performed so those doing it only have to follow the pattern you create.

  • As a result, the people with whom you live, work, and study can usually predict what you will say or do.

  • You may seek out specific kinds of problems that you have met many times before and that you are confident you can fix.

  • Belief provides you with direction, guiding you through the temptations and distractions of life toward a consistent set of priorities.

就业指导

  • Seek roles in which you are paid to solve problems or in which your success depends on your ability to restore and resolve. You might particularly enjoy roles in medicine, consulting, computer programming, or customer service.
  • Let other people solve their own problems. You might want to rush in and solve things for them, but by doing that, you might hinder their learning. Watch out for this, particularly if you are in a manager, coach, teacher, or parent role.
  • Leverage your Restorative talents not only to tackle existing problems, but also to anticipate and prevent problems before they occur.
  • Partner with someone with strong Communication talents. This person can help you with the words you need to describe vivid examples of connection in the real world.
  • Don’t spend too much time attempting to persuade others to see the world as a linked web. Be aware that your sense of connection is intuitive. If others don’t share your intuition, rational argument will not persuade them.
  • Avoid roles that will lead you to confront people on a daily basis. Sales roles based on “cold calls” or roles in highly competitive workplaces, for example, will frustrate or upset you.
  • Practice your techniques for resolving conflict without confrontation. Without these polished techniques, you might find yourself simply running away from conflicts, leaving them unresolved. This could lead you to passive-aggressive behavior.
    • 防治正面冲突不等于逃避问题。问题还是得解决。
  • Partner with someone especially talented in Command or Activator. When all your best efforts to resolve a conflict have met with no success, this person can help you confront it head-on.
    • 不能包抄迂回的时候,需要有人推你一把。
  • A balance between listening and efficiency is key to harmony.
    • 有人如果不珍惜平等交流的好机会,反而用来夹带私货,要及时制止
  • Deference comes naturally for you. You easily step aside when someone with superior expertise enters. Take the next step by inviting those with greater expertise to consult.
    • 给大佬递茶
  • Find a role in which you can enforce compliance to a set of standards. Always be ready to challenge people who break the rules or “grease the wheels” to earn an unfair advantage for themselves.
    • 有人打破了规则为自己谋利,要及时制止
  • Partner with someone with powerful Maximizer or Individualization talents. This person can remind you when it is appropriate to accommodate individual differences.
    • 要有人帮我注意到事实的另一方面
  • Clarify your values by thinking about one of your best days ever. How did your values play into the satisfaction that you received on that day? How can you organize your life to repeat that day as often as possible?
    • 如何过我的生活,从而能使我最美好的一天能不断的重现?
  • Create a gallery of letters and/or pictures of the people whose lives you have substantially influenced. When you are feeling down or overwhelmed, remind yourself of your value by looking at this gallery. It will energize you and revive your commitment to helping others.
    • 如何重拾力量?
  • Accept that the values of other people might differ from your own. Express your beliefs without being judgmental.
    • 哎…

类似性格人的分享

  1. You start to feel connected to others because you know they have wisdom that you don’t. You can’t feel connected if you think you have everything.
  1. Consistency 还有一种含义是一视同仁。不能见人下菜碟。
  2. 如果你做的事不重要,为何要做?

2020/07/08 【半佛】应届生求职利益最大化指南

tVHJ6SX

行业

如果想体现个人的价值,尽量要去朝阳行业,和竞争充分的行业

  • 充分竞争:这个行业的薪酬是存在较大变数的。对人才的渴求高,猎头活跃,跳槽有的跳。(互联网/金融)
  • 不充分竞争:这个行业大家差不多,没啥好跳的,入门也没什么好选的,一个萝卜一个坑。(国企公务员)

在选择行业的时候,忽视自己的梦想,只选风口,因为大多数人的努力未必会产生什么结果。

城市

交通便利降低了城市的重要性,大城市能玩的/看的/知道的,小城市也差不多。

城市的选择影响生活品质。

  • 要选择高速发展,人口高速流入的城市(机会会越来越多)。
  • 小城市的一个问题:过于关系社会

公司地位

第一份工作,厂越大越好。行业地位越高越好。核心点是:让自己变得更加值钱,稳妥落地

  • 小公司的问题:随时为生存奔波,不稳定。
    • 螺丝钉:不是哪里适合往哪拧,是哪里缺人往哪里拧。
    • 大佬可以去小厂享受红利,应届生不行。

每个人的价格定义:公司背书 + 项目履历 + 职位类型。

岗位性质

岗位的选择:越核心,门槛越高越好。

  • 技术 > 产品 > 运营 > 行政 > 销售

岗位要和公司加在一起选择。如果从事直播,那么斗鱼>>百度。

直属领导的SB程度

老板跟你的利益是冲突的。只有榨取你的价值,才能铸就他晋升的阶梯。

核心两个点(老板是否值得追随):

  1. 许下的承诺能否兑现
  2. 有没有经常用梦想和荣誉给你洗脑(但是不给钱)
    • 谁的梦想是上班?简直是脑子有病。

没有你,公司一样转。但是没有你,家庭就会面临很大的问题。

薪酬

问一下公司对于应届生的培养有什么样子的规划。

  • 最好能够给出一个具体的案例。

总结

没有议价权,就没有主动权。


本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!