ときどきの雑記帖 RE* (新南口)
Heaven & Hell
ノイエ銀英伝
第3部「激突」第3章を観てきた(アレのついでに)。
あそこで切るかー(笑)
と書いたけど、また同じ感想になるとは😓 でもまあ狙いというか目論見というかはわからないでもない。
ククルスドアンの島
↑で行った映画館でみたWBクルー集合的なポスターに、 スレッガーがいてリュウがいないのは? と思ったけど、 そうかORIGINベースだからそうなるのか。
R.I.P.
ヴァンゲリスが79歳で死去 『炎のランナー』『ブレードランナー』など映画音楽の巨匠 | マイナビニュース
独立したサントラとしては出てなかったので訃報の記事で触れられてはいなかったけど、 ヴァンゲリスの曲でわたしが好きなのは COSMOS で使われていた曲。
その中でも、このアルバムの6曲目「α」が一番のお気に入り。
何枚かCDを持っていたはずだけどさて。
10年戦えるデータ分析入門
「SQLはこの本の1章読んでおけば完璧」といろいろな人に説明してるんだけど、この本出たのが2015年で本当に10年戦えてる本だから本当にすごい。
— 今別府すてぃお (@suthio_) May 17, 2022
物理本が絶版になってしまってるのが本当に惜しくて、第2版求めてるひとたくさんいると思いますhttps://t.co/O1eBUWF6Bp
というのを見かけ、
を見るといい値段になってるなあ。 わりと最近処分しちまったよ 😓
I don’t know the numbers
さらにつづき。
“I don’t know the numbers”: a math puzzle · Caffeinspiration
にあるPythonスクリプトをちょっといじって
I could know the numbers after
が出きった後に組み合わせが残っているかどうかを確かめてみた。
N = 1
remain:0
*****
N = 2
Peter: I could know the numbers after 1 rounds: (1, 1)
remain:0
*****
N = 3
remain:0
*****
N = 4
*****
間を飛ばしてN=10ではこうなった。
N = 10
Peter: I could know the numbers after 3 rounds: (1, 4)
Sandy: I could know the numbers after 4 rounds: (2, 3)
Peter: I could know the numbers after 5 rounds: (1, 6)
Sandy: I could know the numbers after 6 rounds: (3, 4)
Peter: I could know the numbers after 7 rounds: (2, 6)
Sandy: I could know the numbers after 8 rounds: (4, 4)
Peter: I could know the numbers after 9 rounds: (2, 8)
remain: 8 pairs
{(4, 6), (1, 9), (3, 3), (3, 6), (2, 4), (1, 8), (3, 8), (2, 9)}
[[6, [[2, 4], [3, 3]]],
[9, [[1, 8], [3, 6]]],
[10, [[1, 9], [4, 6]]],
[11, [[2, 9], [3, 8]]],
[[8, [[1, 8], [2, 4]]],
[9, [[1, 9], [3, 3]]],
[18, [[2, 9], [3, 6]]],
[24, [[3, 8], [4, 6]]],
だったので間違ってはいなかったようだ。 ということは全部が消えるわけではないということだったのか。
この後も見ていくと
N = 37
Sandy: I could know the numbers after 6 rounds: (24, 35)
Peter: I could know the numbers after 7 rounds: (28, 30)
Sandy: I could know the numbers after 8 rounds: (22, 36)
Peter: I could know the numbers after 9 rounds: (24, 33)
Sandy: I could know the numbers after 10 rounds: (21, 36)
Peter: I could know the numbers after 11 rounds: (27, 28)
Sandy: I could know the numbers after 12 rounds: (20, 35)
Peter: I could know the numbers after 13 rounds: (25, 28)
remain: 379 pairs
*****
N = 38
Sandy: I could know the numbers after 6 rounds: (24, 35)
Peter: I could know the numbers after 7 rounds: (28, 30)
Sandy: I could know the numbers after 8 rounds: (22, 36)
Peter: I could know the numbers after 9 rounds: (24, 33)
Sandy: I could know the numbers after 10 rounds: (21, 36)
Peter: I could know the numbers after 11 rounds: (27, 28)
Sandy: I could know the numbers after 12 rounds: (20, 35)
Peter: I could know the numbers after 13 rounds: (25, 28)
remain: 379 pairs
のようにそれなりの数のI could know the numbers after n rounds
を出すものがある一方で
N = 45
Sandy: I could know the numbers after 4 rounds: (2, 3)
Peter: I could know the numbers after 5 rounds: (1, 6)
remain: 556 pairs
*****
N = 46
remain: 588 pairs
*****
N = 47
remain: 632 pairs
*****
N = 48
remain: 632 pairs
*****
N = 49
remain: 670 pairs
*****
N = 50
Sandy: I could know the numbers after 6 rounds: (28, 48)
Peter: I could know the numbers after 7 rounds: (32, 42)
remain: 699 pairs
*****
のように一個もないもの(もちろん初手から消せるものは別)もあった。 そして問題のN=100の場合はというと
N = 100
Sandy: I could know the numbers after 6 rounds: (72, 99)
Peter: I could know the numbers after 7 rounds: (81, 88)
Sandy: I could know the numbers after 8 rounds: (70, 99)
Peter: I could know the numbers after 9 rounds: (77, 90)
Sandy: I could know the numbers after 10 rounds: (72, 95)
Peter: I could know the numbers after 11 rounds: (76, 90)
Sandy: I could know the numbers after 12 rounds: (70, 96)
Peter: I could know the numbers after 13 rounds: (80, 84)
Sandy: I could know the numbers after 14 rounds: (66, 98)
Peter: I could know the numbers after 15 rounds: (77, 84)
remain: 3159 pairs
ふむ。
Mathematica
Next Level Cheryl Birthday Question : math にMathematicaを使った例があった(product側の一部のものだけを出力)。
pairs = Flatten[Table[{x, y, 0}, {x, 1, 99}, {y, x, 99}], 1];
For[i = 0, i < 7, i++;
products = Table[{x[[1]], x[[2]], x[[1]] x[[2]]}, {x, pairs}];
uniqueProducts = #[[1]] & /@
Select[Tally[#[[3]] & /@ products], #[[2]] == 1 &];
pairs = Select[products, ! MemberQ[uniqueProducts, #[[3]]] &];
sums = Table[{x[[1]], x[[2]], x[[1]] + x[[2]]}, {x, pairs}];
uniqueSums = #[[1]] & /@
Select[Tally[#[[3]] & /@ sums], #[[2]] == 1 &];
pairs = Select[sums, ! MemberQ[uniqueSums, #[[3]]] &];
];
products = Table[{x[[1]], x[[2]], x[[1]] x[[2]]}, {x, pairs}];
uniqueProducts = #[[1]] & /@
Select[Tally[#[[3]] & /@ products], #[[2]] == 1 &];
Print[{#[[1]], #[[2]]} & /@
Select[products, MemberQ[uniqueProducts, #[[3]]] &]];
ああ、思う存分使ってみてえなあMathematica。
Array.repeatd_combination
ところで Rubyには Array#product というメソッドがあって、 (1, 1) から(9, 9)まで組をつくるのに
$ ruby -e 'p [*1..9].product([*1..9])'
[[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9],
[2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9],
[3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9],
[4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9],
[5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9],
[6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [6, 7], [6, 8], [6, 9],
[7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7], [7, 8], [7, 9],
[8, 1], [8, 2], [8, 3], [8, 4], [8, 5], [8, 6], [8, 7], [8, 8], [8, 9],
[9, 1], [9, 2], [9, 3], [9, 4], [9, 5], [9, 6], [9, 7], [9, 8], [9, 9]]
とできるのだけど、今回の例のような重複のない組み合わせ にする(たとえば(1,2)と(2,1)を同じとみなして片方だけを生成する) にはどうするのがよいのだろう?
h1 = [*1..N].collect{|n| [n].product([*n..N])}.flatten(1).group_by{_1[0]+_1[1]}
というのを使ったり(group_byはオマケ)
$ ruby -e 'p [*1..9].product([*1..9]).filter{_1[0]<=_1[1]}'
[[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9],
[2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9],
[3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9],
[4, 4], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9],
[5, 5], [5, 6], [5, 7], [5, 8], [5, 9],
[6, 6], [6, 7], [6, 8], [6, 9],
[7, 7], [7, 8], [7, 9],
[8, 8], [8, 9],
[9, 9]]
というのを使ってごにょごにょしたんだけど、 Array#repeated_combination を使えばいいのか。 Array#combination の方しか思い浮かばなかった。
$ ruby -e 'p [*1..9].repeated_combination(2).sort'
[[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9],
[2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9],
[3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9],
[4, 4], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9],
[5, 5], [5, 6], [5, 7], [5, 8], [5, 9],
[6, 6], [6, 7], [6, 8], [6, 9],
[7, 7], [7, 8], [7, 9],
[8, 8], [8, 9],
[9, 9]]
$ ruby -e 'p [*1..9].combination(2).sort'
[[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9],
[2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9],
[3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9],
[4, 5], [4, 6], [4, 7], [4, 8], [4, 9],
[5, 6], [5, 7], [5, 8], [5, 9],
[6, 7], [6, 8], [6, 9],
[7, 8], [7, 9],
[8, 9]]
ちゃんと Array#combination (Ruby 3.1 リファレンスマニュアル) のSEE ALSOに Array#repeated_cimbinationあるのにねえ😓
C
100年後もC言語はきっと生きていて、言語仕様は22C11と名乗るに違いない
— cranebird (@quasicrane) May 15, 2022
wcwidth が居るべきところは locale サブシステムではなくて terminfo サブシステムやろなあ。 https://t.co/17JaKAPXNL
— AoiMoe a.k.aしお兄P (@AoiMoe) May 18, 2022
ISO C locale はもう壊れてるので何らかの方法で捨てられないものか
— AoiMoe a.k.aしお兄P (@AoiMoe) May 18, 2022
wcwidth は ISO C じゃないけど
— AoiMoe a.k.aしお兄P (@AoiMoe) May 18, 2022
-3**2
という記事で
以下次号