目次
// ↓間違い
let all = (n * (n + 1) * (2 * n + 1)) + 3 * n * (n + 1) / 12;
// ↓正しい
let all = (n * (n + 1) * (2 * n + 1) + 3 * n * (n + 1)) / 12;
tuple_windows と入力しようとしたら、tuple_combinations が補完の先頭に来て tuple_combinations が入力されてしまったというのがよくある。
tuple_windows も tuple_combinations も型が実質同じなせいで、気づくのも難しい。
参考: Rust itertools あるある: tuple_windows と tuple_combinations を間違える(Youtube のクリップ)
似たような事例として、izip
, iproduct
もある
i=3 のとき100、それ以外のとき1を出力しようとしたけど、すべて100が出力されてしまった
参考: https://youtu.be/s1mOBziNMwg?si=bkYbntnI1VQQkqb7&t=2350 (ARC183 A の動画)
↓こう出力すべきだったが、Yes を出力し忘れた