## 四個機率問題

• 每一次有 $\frac{1}{N}$ 成功的機率，跑 $N$ 次後最少成功一次的機率。
• $N$ 個球隨機丟到 $N$ 個籃子後有空籃子的機率。
• $N$ 個數字在隨機排序後有數字不改變位置的機率。
• $N$ 種 coupon 平均隨機出現，要抽中一套 $N$ 種都有的 coupon 需要抽幾次的期望值。

## eBay 提供的 TSV 工具組

Hacker News Daily 上看到的，eBay 提供了操作 TSV 的工具組：「eBay/tsv-utils」。

TSV 的確是比 CSV 好用不少，只是會用的單位好像有限...

## Perl 6 的名字被拿出來談...

When Perl 6 was announced, it was seen the way that Perl 2, Perl 3, Perl 4, and Perl 5 were seen: replacements for "\$VERSION - 1". Over time, it became clear that though Perl 6 was in the same family as Perl 5, a straightforward migration path was unlikely. One only needs to look at the problems with Python 2 and Python 3 and the upgrade obstacles with their minor syntactic differences to understand that an upgrade from Perl 5 to Perl 6 isn't trivial.

## 自產生程式的 HTML 版：看到的頁面就是 HTML 程式碼

Hacker News 上看到「Show HN: This page is a truly naked, brutalist HTML quine (secretgeek.github.io)」這個連結，裡面是 HTML 版的 Quine，原始網頁在「This page is a truly naked, brutalist html quine.」，頁面長這樣 (取前面的部份)：

The only other style that is special is "style" itself, which has to include an escape character to avoid being taken literally.

This is more readable than many news websites I've come across

## macOS 打算移除 Perl/Python/Ruby

Scripting language runtimes such as Python, Ruby, and Perl are included in macOS for compatibility with legacy software. Future versions of macOS won’t include scripting language runtimes by default, and might require you to install additional packages. If your software depends on scripting languages, it’s recommended that you bundle the runtime within the app. (49764202)

## 換到 vim-polyglot 上...

Vim supports basic syntax highlighting for JavaScript but I found it suboptimal especially when it comes to modern ES2015+ syntax, and it doesn’t support JSX when working with React. I found that vim-javascript and vim-jsx solved my problems in both instances.

However, I later replaced those two with vim-polyglot which is a plugin that bundles several other syntax plugins for over 100 languages, and loads them on demand so that performance is not affected.

## 找數列的平均值

2016 年的文章，不過算是經典的題目，所以最近又冒出來了。要怎麼找數列的平均值：「Calculating the mean of a list of numbers」。

You have a list of floating point numbers. No nasty tricks - these aren’t NaN or Infinity, just normal “simple” floating point numbers.

Now: Calculate the mean (average). Can you do it?

• 第一個要處理的就是設計演算法時各種會 overflow 的情況。
• 降低誤差。
• 合理的計算量。

It also demonstrates a problem: Floating point mathematics is very hard, and this makes it somewhat unsuitable for testing with Hypothesis.

#include <math.h>
#include <stdio.h>

int main(void)
{
int i;
float a;

for (i = 0; i < 32; i++) {
a = pow(2, i);
printf("2^%d     = %f\n", i, a);

a += 1;
printf("2^%d + 1 = %f\n", i, a);
}
}

2^23     = 8388608.000000
2^23 + 1 = 8388609.000000
2^24     = 16777216.000000
2^24 + 1 = 16777216.000000