店面:ABC 小哥很nice 很sharp,我介绍了我的一些project 他可以一下子很简练的总结,总之交流挺愉快。考了一道R code 题,大概就是用dplyr package data manipulation\n\nonsite 1: 醉酒问题,100个人上飞机,一号醉了,randomly sit,接下来每一个人按序号上飞机,如果座位被占了,就random sit,如果没有就对号入座,问最后一个人坐在自己位置上的概率,然后code 出来,要能跑\n\nonsite 2: A& B flip coin,A wins with HT and B wins with HH, then who is more likely to win first。。答案是A。。见下方PMF table\n\nWin at Round 2 3 4 5 6 7 8+\nA 0.25 0.25 0.1875 0.125 0.078125 0.046875 0.0625\nB 0.25 0.125 0.125 0.09375 0.078125 0.0625 0.265625\n\nonsite 2: Spend calculator 具体不记得了,要code 出来\n\nset.seed(12345)\nyear = (1:65)\n\n\ntrack of the leftover discretionary expense year over year. I improperly called it "profit".\n\n#suppose someone has 65 years of cashflow. Doesn't really matter how many years.\n. Χ\n\nprofit0 = rnorm(65,1000,100)\n\nthisdata = data.frame(year=year,profit=profit)\n\nThe goal is to redistribute the profit so they are as close to each other as possible, in such a way we maximize the total utility. .1point3acres\nBut we cannot spend future's money.\n\nThis algorithm finds all the decreasing sequences and take the average, iteration by iteration, until convergence.\n\nnewprofit = rep(0,65) ..\nprofit = profit0. 1point3acres.com\n\nmydata=data.frame(profit0) \n. ----\nwhile(TRUE)\n{ \n\n i=1\n count=0\n while(i<=64){.\n while(profit[i+1]<=profit[i])\n {. Waral dи,\n count=count+1\n i=i+1\n if(i==65) break\n }\n newprofit[(i-count):i]=mean(profit[(i-count):i])\n i=i+1\n count=0\n }\n if (identical(profit,newprofit)) {break}\n profit = newprofit .google и\n mydata=data.frame(mydata,newprofit). 1point 3 acres\n}\n. ----\nmydata\napply(mydata,2,sum) . 1point3acres\n\nonsite 4: BQ