2022年12月22日 星期四

神會選擇善良又大氣 且足以承受這份禮物的人

我那善良的爸媽
很快就振作起來

放棄不賺錢的畫家工作
為了照顧從小病不斷的英希姐
他們開始賣起衣服

他們總是真心的說

我的雙胞胎姐姐英希 會來到我們家
是因為我們家通過了神尋找善良之人的考驗

神在送有點病痛和特別的孩子
到世上的時候
會選擇善良又大氣
且足以承受這份禮物的人

<我們的藍調時光, ep14>

2022年12月15日 星期四

彼得原理

彼得原理, Peter Principle,
since 1969

組織或企業的等級制度
人會因為某種特質或特殊技能

令他躍升到他不能勝任的高階職位
最終變成組織的障礙(冗員) 及負資產

鴿籠原理


#鴿籠原理 #抽屜原理 
狄利克雷, Dirichlet,
since, 1842.

如果有n個籠子 n+1隻鴿子
所有鴿子都關在籠子裡
那麼一定至少有一個籠子 有 至少兩隻鴿

or
如果有n個籠子 kn+1隻鴿子
所有鴿子都關在籠子
那麼一定至少有一個籠子 有 至少k+1隻鴿子


2022年12月8日 星期四

蒙提霍爾問題(三門問題)

====
蒙提霍爾問題(Monty Hall problem)
三門問題, 1889
@Marilyn vos Savant

====
假設要求從三道門選擇一道
其中一道門裡面是獎品汽車 其餘是山羊

你不知道門後是什麼
主持人知道

你選擇了其中一扇門
知道答案的主持人 開啟了另一扇有山羊的門
並給予你更換答案的機會

請問選擇更換是優勢嗎?
(應該更換 還是不要呢

====
要換
因為沒有更換得獎的機率是1/3
但是更換得獎的機率是2/3

case1, 你選車, 主持人開羊a/b, 更換後選到羊b/a
case2, 你選羊a, 主持人開羊b, 更換後選到車
case3, 你選羊b, 主持人開羊a, 更換後選到車

選前1/3
選後2/3(1/2?)

====
為何車/羊a, 車/羊b不是兩種..?

因為一開始選擇是三選一
然後用贏車當結論

====
但2/4機率仍然高
不過就是大眾理解的1/2機率了..

2022年11月23日 星期三

carriage return && linefeed

carriage return, 回車, //win
moving cursor to begin of line,
i.e. '\r'

line feed, 換行, //win //Unix
moving one line forward,
i.e. '\n'

2022年11月18日 星期五

敬畏著時間


欲望都太多了
人 對於許多事情的理所當然
更是不敢恭維

人生就是個日曆
默默撕去日曆 有沒有注意上頭的時間呢
有沒有體會日曆剩餘的厚度呢

敬畏著時間
到頭來
就是一眨眼的功夫
如同星河一般

180708

2022年11月7日 星期一

范紐曼型架構

范紐曼型架構
Von Neumann architecture

又稱 馮.紐曼模型
普林斯架構(Princeton architecture

定義:
一種將程式指令記憶體 與 資料記憶體 合併在一起的電腦設計概念架構
(通用圖靈機

因為有將
儲存裝置 與中央處理器 分開的概念
因此依架構設計的計算機又稱「儲存程序電腦」

時間:
1945(1936賓州大學, 摩爾電機學院
1946(艾倫圖靈Pilot ACE


二八法則

巴萊多定律(Pareto's law)
義大利經濟學家
又稱二八法則

定義:
任何東西 最重要的只佔20%
其餘80%是次要的

時間:
19世紀末/20世紀初


2022年10月18日 星期二

A knight in shining armour

A knight in shining armour meant:

Someone who saves you from a difficult or dangerous situation.

I think it gives you cancer, but you find your car faster

- Sebastian: You gonna put that thing to your chin.
Yeah, it makes your head into an antenna.

I think it gives you cancer, but you find your car faster.

- Mia: What?
- Sebastian: I mean, you don't live long, but you get where you're going quicker, so it all evens out.

- Mia: That sounds terrible.
- Sebastian: Just a suggestion.
- Mia: You're.. you're a real, what's the word I'm looking for?
- Sebastian: Knight in shining armor?
- Mia: Weirdo.

<La La Land, 2016>

2022年10月4日 星期二

She understands TV

Jupiter: Turpentine Brandy.
It cools the head and warms the dog bones.
Oracle: It may show tonight.

Boss: Really? Thank you very much.
Oracle: To whom it may concern.

Boss: She sees the future!
King: No. She understands TV.

<Isle of Dogs, 2018>

2022年9月18日 星期日

她的欲望跟我的困境都已經那麼清楚了

友人:
從那天的氣氛看起來
你一副會立刻傳訊息給她的樣子
為什麼你沒有

昌熙:
我說她比得上藝琳
意思是她是會想推著嬰兒車
送小孩去幼稚園的那種女人

我眼裡覺得不錯的女人
有那種程度的慾望也沒關係

但問題是我沒辦法讓她那麼做

這就是我的困境
在不能解決困境的狀態下
一直跟女生交往

下場就是不停的分手

<我的出走日記, 나의 해방일지, ep.5>

我好像知道老人為什麼喜歡橫越馬路了

琦貞:
我要保持速度一直走
一停下來就走不動了

我好像知道老人為什麼喜歡橫越馬路了
一旦停下來就走不動了
要一直走才行

<我的出走日記, 나의 해방일지, ep.5>

那人類如果要一直感到喜悅 不就要一直生小孩 生到死為止嗎

慧淑:
你們生了小孩就會知道
自己不用吃飯也會飽

每天都很迷人 懂嗎
會變得天下無敵
誰都贏不了你
誰能贏得了當媽媽的人

但你們居然都不懂這些 真受不了

昌熙:
你生了我們
享受了兩三年的歡愉

之後就辱罵不離口

你要我們繼續繼承這種生活方式嗎

那人類如果要一直感到喜悅
不就要一直生小孩 生到死為止嗎

<我的出走日記, 나의 해방일지, ep.5>

每個人都一樣在走向死亡 我不懂大家為什麼都這麼開心

美貞:
每個人都一樣在走向死亡
(다 무덤으로 가는 길인데

我不懂大家為什麼都這麼開心
(뭐 그렇게 신나고 좋을까

有時候我甚至覺得
那些失魂落魄的人

說不定比那些若無其事 日足順遂的人
還要腳踏實地

我不知道自己被困在哪裡
但我很想掙脫

我希望我的人生
可以真的幸福快樂起來

直到有一天我能夠大嘆
“這才是人生阿 這才是活著的感覺”

<我的出走日記, 나의 해방일지, ep.4>

只要沉浸在愛裡就不會覺得累

琦貞:
真想痛快地剃個光頭

不是, 我的頭髮
從來就沒有加分的效果

為什麼要因為女性象徵這種理由無法捨棄
還要每天早上起來辛苦地洗頭
然後吹到手酸

我覺得自己被這頭毫無意義的頭髮困擾了一輩子
痛痛快快地剃掉
我就不會有無謂的期待

我已經累到連頭上有頭髮都覺得很煩

振宇:
這就是為什麼我會不停地付出愛

只要沉浸在愛裡就不會覺得累

<我的出走日記, 나의 해방일지, ep.4>

物以類聚是一種科學

因為同一種人才會互相打交道
物以類聚是一種科學
(끼리끼리는 과학이거든

但我要離開這裡
我才不要跟她物以類聚

我也想跟和藹可親又有修養的人共事
但為什麼我不行呢

這代表我還不夠有修養

為什麼
因為物以類聚是一種科學

<我的出走日記, 나의 해방일지, ep.4>

2022年9月16日 星期五

就是那些眼神讓我們感到疲倦 生病

美貞:
眼神彷彿在說
“你不夠好”
(넌 부족해

讓人覺得自己變得渺小
像個微不足道的人

就是那些眼神讓我們感到疲倦 生病
(우리를 지치고 병들게 했던 건 다 그런 눈빛들이었다

為了找出自己是值得被愛的

而一頭栽進去

最後那些關係只會不斷讓人體悟到自身的難堪

<我的出走日記, 나의 해방일지, ep.3>

而不是因為我發現自己是個不怎麼樣的男人

昌熙:
是她先開始的
我從她的眼神看出了端倪

透露出覺得我沒什麼 讓人厭惡又心灰意冷的眼神

跟女人交往久了
她們就會流露出一種眼神
這傢伙沒什麼特別的 我該怎麼跟他分手
我該找什麼藉口來逼他”

是阿 我知道我自己不怎麼樣
但相處久了 就會知道我很有趣 不無聊
但不管我怎麼哄都沒有用 那還有其他辦法嗎

女人想分手 我就成全她

從那天起就吵得天翻地覆
我只能把分手原因
塑造成我自己去看電影
或是她大半夜跟其他男人傳訊息

而不是因為我發現自己是個不怎麼樣的男人
(절대로 내가 별 볼 일 없는 인간인 거
그게 들통나서 헤어지는 게 아니라

<我的出走日記, 나의 해방일지, ep.3>

接起來的女人

琦貞:
以前我跟朋友討論過
什麼是男女之間的最高境界這類話題

我想起小時候
在歷史課本上看過一個故事

妻子衝上前去用裙子接住丈夫被斬首的頭顱

小時候只覺得殘忍 也無法理解
但隨著年紀增長就覺得
是我也會接, 不, 是必須接起來

不能讓頭顱掉在地上
當然要跑去用裙子接起來

不然
一, 逃跑
二, 昏倒
三, 接起來, 你會選哪一種女人

<我的出走日記, 나의 해방일지, ep.3>

모든 관계가 노동이에요눈, 뜨고 있는 모든 시간이 노동이에요

美貞:
我做不到
我太累了

我累了
我不知道是從哪裡開始出了問題
但我就是累了

所有的人際關係
(모든 관계가
都像是在工作
(노동이에요
清醒的每個瞬間
(눈 뜨고 있는 모든 시간이 
都在勞動
(노동이에요

什麼事都沒發生
也沒有任何人喜歡我

<我的出走日記, 나의 해방일지, ep.2>

因為你不會用話語迷惑別人 我才會喜歡你的 所以你說過的每一句話都很珍貴

賢雅:
人只要到達某個點
就會開始用話語展現出魅力

一旦開始享受別人的目光
聚焦在自己吐出的話上

就回不了頭了

你覺得我說過的話裡
有哪句是真的有意義嗎
一句也沒有

所以我希望你
永遠不要到達那個臨界點

因為你不會用話語迷惑別人 我才會喜歡你的
所以你說過的每一句話都很珍貴

<我的出走日記, 나의 해방일지, ep.2>

與其因為你不在身邊而感到辛苦疲憊 因為想著你而獲得力量是不是更難能可貴呢

美貞:
只要想像和你一起坐在這裡工作
那麼就連這種糟糕的事情也會變得美好
這樣 我就能堅持下去

我在演戲 演一個被愛的女人
(연기하는 거예요, 사랑받는 여자인 척

演一個沒有缺點的女人

現在的我正愛著某個人
正得到某個人的支持

所以我會試著想像這是個舒適的狀態
“我早已和你一起過著幸福的日子“
我抱持著這種想法

與其因為你不在身邊而感到辛苦疲憊
(당신 없이 있던 시간에 지치고 힘들었던 것보단

因為想著你而獲得力量是不是更難能可貴呢
(당신을 생각하면서 힘을 냈다는 게 더 기특하지 않나요?

<我的出走日記, 나의 해방일지, ep.1>

2022年9月9日 星期五

2022年9月6日 星期二

Moist Maker

- You see my sister makes these amazing turkey sandwiches.
Her secret is, she puts a, an extra slice of gravy soaked bread in the middle

I call it the Moist Maker.

Anyway, I-I put my sandwich in the fridge over here…

- Oh, you know what?
I-I'm sorry. I, I-I-I believe I ate that.

- You ate my sandwich?

- It was a simple mistake. It could happen to anyone.

- Oh-oh really?
Did you confuse it with your own turkey sandwich with a Moist Maker?

- ...No.

- Do you perhaps seeing a note on top of it?

- There may have been a-a joke or a limerick of some kind.

- That said it was my sandwich!

- Now-now calm down.
Come look in my office, some of it my still be in the trash.

- What?

- Well, it was quite large. I-I-I-I-I had to throw most of it away.

- You-you-you-you threw my sandwich away!
MY SANDWICH?!!!

<Friends, s05ep9, The One with Ross's Sandwich, 1998>

2022年9月4日 星期日

[失智預防]

[失智預防]
====

逃避恐懼
灰白質表面神經萎縮

蘋果型身材
腰圍比臀圍粗 高風險

三溫暖預防
慢跑血流92, 三溫暖210

洗澡後擦乾身體
熱蒸氣十分鐘
or
40/41度熱水沖泡十分鐘

30度冷水沖涼30秒

[免疫力][腰痛膝蓋痛][失眠]


[免疫力特輯][小腸絨毛]
====

----
蛋白質(起司, 牛肉
麩胺酸

----
70歲以上
每天攝取蛋白質75g

----
味噌湯+生蛋, 6.2g


[消除腰痛膝蓋痛]
====
抖腳


[失眠]
====
筆記紀錄法

2022年8月30日 星期二

Did no one come to save me just because they missed me?

He needs the Pearl.
Captain Turner needs the Pearl,

and you felt guilty,
and you and your Brethren Court.

Did no one come to save me just because they missed me?

<Pirates of the Caribbean: At World's End, 2007>

Make 'em wonder why you're still smiling

Claire: You're an artist, man.
Your job is to break through barriers.
Not accept blame and bow and say thank you, I'm a loser, I'll go away now. Oh, Phil's mean to me, whaa, whaa, So what.

Drew: I don't cry.

Claire : You want to be really great?
Then have the courage to fail big and stick around.

Make 'em wonder why you're still smiling. 

That's true greatness to me.
But don't listen to me, I'm a Claire.

<Elizabethtown, 2005>

在階級中晉升不僅能激勵個人 也可以鞏固結構 確保階級的永續發展

家庭:
人是在權威結構中成長的
從出生開始 就一直受到父母的管教約束
因此養成對成人權威的尊敬

父母的訓示也是道德命令的來源
然而 當父母要求孩子服從道德命令時
父母其實做了兩件事:
一是提出內容要孩子遵守
二是訓練孩子要服從權威的命令


制度環境:
孩子一離開家 馬上就被轉移到「權威」的系統制度裡
也就是學校

孩子學習到組織架構裡發揮功用
孩子行動受到老師約束
但同時老師也受到校長 校方的規訓與管理

學生學習到桀驁不馴無法被權威接受 反而會遭來責罵
服從 才是唯一恰當回應權威的方式

年輕人在二十歲之前都在權威裡擔任從屬的角色學校畢業後找工作 或是軍中服役 亦是如此


獎賞:
權威經驗 總是要持續面對獎賞結構
凡是服從權威的人都能獲得獎賞
反之則是懲罰

其中最巧妙的 莫過於 獎賞是個人在階級中晉升
不僅能激勵個人 也可以鞏固結構 確保階級的永續發展


2022年8月23日 星期二

位元 -2022

位元組次方單位:

//十進位:二進位

kilobyte(kB), 10^3 : kibibyte(KiB), 2^10
megabyte(MB), 10^6 : mebibyte(MiB), 2^20
記憶體/多媒體

gigabyte(GB), 10^9 : gibibyte(GiB), 2^30
記憶體/硬碟

terabyte(TB), 10^12 : tebibyte(TiB), 2^40
硬碟

petabyte(PB), 10^15 : pevibyte(PiB), 2^50
網路硬碟/伺服器農場

exabyte(EB), 10^18 : exibyte(EiB), 2^60
網路硬碟/網際網路總容量

zettabyte(ZB), 10^21 : zebibtye(ZiB), 2^70

yottabtye(YB), 10^24 : yobibyte(YiB), 2^80

2022年8月13日 星期六

The point isn't to push the bad stuff away, it's to make room for it, live with it.

People have all kinds of sides to them, Mei, and some sides are messy.

The point isn't to push the bad stuff away,
it's to make room for it, live with it.
Mei, erase it if you want, but this side of you..
made me laugh.

We've all got an inner beast.
We've all got a messy, loud, weird part of ourselves hidden away.
And a lot of us never let it out. But I did.
How about you?

<Turning Red, 2022>

2022年7月30日 星期六

Now, you've got yourself a castle.

Take a look at a castle, any castle.
Now, break down the elements that make it a castle.

Location. Protection. Garrison.
Flag.

The only difference between this castle and all the rest
is they were built to keep people out.

This castle was built to keep people in.

----
A great general once said,

You tell your men, "you're soldiers. That's our flag."
 
You tell them, "Nobody takes our flag.
Raise your flag so it flies high where everyone can see it."

Now, you've got yourself a castle.

<Irwin, Yates, The Last Castle, 2001>

A rifle driven into the ground, with a helmet on top, and some tags. And that is the tribute that this man has earned.

Some may think to be remembered in this way would be a disgrace to a soldier.

But this is not disgrace.
The greatest monuments to fallen man
are not made in marble.

They're deep in the sea, deep in the jungles, on foreign battlefields,
a rifle driven into the ground, with a helmet on top, and some tags.

And that is the tribute that this man has earned.

<Irwin, The Last Castle, 2001>

Because, make no mistake about it, Mr. Irwin, they are the enemy.

No soldier has ever died needlessly under my command, Mr. Irwin.
See, I, too, share the burden of command.

You may not think that I've ever set foot on a battlefield, but that's because you've never sat behind this desk.

My men and I are vastly outnumbered.
We spend every day behind enemy lines.
Because, make no mistake about it, Mr. Irwin,

they are the enemy.

<Winter, The Last Castle, 2001>

2022年7月29日 星期五

I'm going home, and God willing, I'm going to sit on the porch and play dominos with my grandson

When you're doing combat duty, after awhile, life just becomes snapshots.
Most of them horrible. But not all of them.

I saw an old man sitting on a bombed-out porch, playing a game of dominos with I presume is his grandson.

When I saw that I thought, you know, it's my turn. So, gentlemen. I'm done.

I'm not fighting for anyone or anything anymore. I'm doing my time here, I'm going home,

and God willing, I'm going to sit on the porch and play dominos with my grandson, who I've never met.

<Irwin, The Last Castle, 2001>

2022年7月28日 星期四

Fifty-fifty.

You thought we could be decent men 
in an indecent time. 
But you were wrong.

The world is cruel,
and the only morality in a cruel world
is chance.

Unbiased, unprejudiced...
Fair.

His son's got the same chance she had.
Fifty-fifty.

<Two-face Harvey, The Dark Knight, 2008>

2022年7月11日 星期一

If you go to Troy, glory will be yours. But you will never come back, and I shall never see you again.

If you stay in Larissa, you will find peace.
You will find a wonderful woman,
and you will have sons and daughters, who will have children.
And they'll all love you and remember your name.

But when your children are dead, and their children after them, your name will be forgotten...

If you go to Troy, glory will be yours.
They will write stories about your victories in thousands of years.
And the world will remember your name.

But if you go to Troy, you will never come back.
For your glory walks hand-in-hand with your doom. And I shall never see you again.

<Troy, 2004>

2022年7月5日 星期二

Human beings are a disease, a cancer of this planet. You’re a plague and we ...are the cure.

Every mammal on this planet instictively develops a natural equilibrium with the surrounding environment,
but you humans do not.

You move to an area and you multiply and multiply until every natural resource is consumed.
The only way can survive is to spread to another area.

There is another organism on this planet that follows the same pattern.
Do you know what it is?

A virus.

Human beings are a disease,
a cancer of this planet.
You’re a plague and we 
...are the cure.

<The Matrix, 1999>

2022年7月3日 星期日

熾天使 -聖天使 墮天使

熾天使

[聖天使]
----
米迦勒, Michael (總領天神/ 彌額爾/ 聖彌格/ 天使長

加百列, Gabriel (聖加俾額爾/ 上帝之手/ 神訊/ 死亡天使

拉斐爾, Raphael (聖拉斐爾/ 治癒/ 力天使君主/ 生命之樹守護者

烏列爾, Uriel (烏列/ 優禮/ 知識哲學/ 神之光

沙利葉, Sariel (月之天使/ 邪眼/ 雙重身份

梅塔特隆, Megatron (火之天使/ 代理

聖德芬, Sandalphon (高大, 聖歌, 力量 美麗 生命

巴拉斯基, Barachiel (閃電/ 白玫瑰

亞必迭, Abdiel

雷米爾, Ramiel



[墮天使]
----
路西法, Lucifer /*傲慢*/ (明日之星/ 光使者

別西卜, Beelzebub /*暴食*/ (蒼蠅王/ 疾病/ 魔王鬼王

薩麥爾, Samael /*憤怒*/ (嚴厲/ 天軍

阿撒茲勒, Azazel /*嫉妒*/ (山羊/ Nephilim/ 火湖

阿斯莫德, Asmodeus /*色慾*/ (獨佔女子/ 魔神/ 制裁/ 淫欲公子

貝利爾/彼列, Belial (分辨真偽/ 挑撥/ 無賴/ 毀滅/ 巴比倫

亞斯塔祿, Astaroth (天后/ 巴力之妻/ 地獄大公/ 怠惰

亞伯汗, Abraham (扭曲/ 夢世界/ 空間


天階 -天使

天階 -天使

----
上三級:
熾天使, Seraphim, Seraph - 六翼, 紅面火焰身
(撒拉弗, 燃燒之蛇, 六翼四足的火焰巨龍 或巨蛇

智天使, Cherubim
(基路伯, 天童/嬰兒, 只有腦袋

座天使, Ophanim/ Thrones
(理性, 顧問, 調和所有對峙的事物

----
中三級:
主天使, Dominions/ Kyriotetes
(權天使, 主宰, 管理

力天使, Virtues
(高潔 美德, 神蹟, 德天使, 戰爭天使

能天使, Powers/ Exusial
(異能天使, 理性權威, 有序, 維護心中平衡

----
下三級:
權天使, Principalities/ Archai
(率領, 掌管保衛國家, 政治, 軍事, 經濟

大天使, Archangels
(天使長, 總理

天使, angels
(中介, 羽翼, 光暈, 使者



七宗罪 -惡魔

====
七宗罪 -惡魔

====
傲慢, Lucifer, 路西法

墮天使之首/ 伊甸園之蛇
魔獸: 獅鷲

====
嫉妒, Azazel, 阿撒茲勒

疾病之王/ 墳墓
魔獸: 薩提爾/羊男

====
憤怒, Samael, 薩麥爾

憤怒化身/ 暴怒化身
魔獸: 獨角獸

====
怠惰, Belphegor, 貝爾芬格

魔神/ 沒加入戰爭天使/ 狂歡的狡辯者
魔獸: 不死鳥

====
貪婪, Mammon, 瑪門

財寶 貪婪/ 錯誤之神
魔獸: 哥布林

====
爆食, Beelzebub, 別西卜

蒼蠅之王/ 鬼王
魔獸: 克爾柏洛斯/ 塞伯拉斯/ 地獄犬

====
色慾, Asmodeus, 阿斯莫德

激怒與色慾/ 魔神始祖
魔獸: 魅魔


所羅門七十二柱魔神

1. 巴爾, 君王, Baal (至上四柱 (墮落七天使
2. 阿加雷斯, 公爵, Agares
3. 瓦沙克, 親王, Vassago
4. 薩米基納, 侯爵, Samigina
5. 馬爾巴士, 統領, Marbas
6. 華利佛, 公爵, Valefor
7. 阿蒙, 侯爵, Amon
8. 巴巴托斯, 公爵, Barbatos
9. 拜蒙, 君王, Pain (至上四柱

10. 帕爾, 統領, Buer
11. 古辛, 公爵, Fusion
12. 西迪, 親王, Sitri
13. 貝雷特, 君王, Belieth
14. 烈拉金, 侯爵, Leraje
15. 艾利歐格, 公爵, Eligos
16. 桀派, 公爵, Zepar
17. 布提斯, 統領, Boris
18. 巴欽, 公爵, Barthin

19.塞列歐斯, 公爵, Sallos
20. 普爾森, 君王, Purson
21. 莫拉格斯, 統領, Marax
22. 因波斯, 親王, Ipos
23. 艾尼, 公爵, Aini
24. 納貝里士, 侯爵, Naberius
25. 格刺希亞拉波斯, 統領, Glasya-Labolas
26. 擘內, 公爵, Bune
27. 柏諾貝, 伯爵, Ronove

28. 貝烈, 公爵, Berith
29. 亞斯塔祿, 大公, Astaroth (至上四柱 (墮落七天使
30. 弗內烏斯, 侯爵, Forneus
31. 佛拉士, 統領, Foras
32. 阿斯莫德, 君王, Asmodeus (至上四柱 (色慾
33. 嘉波, 親王, Gaap
34. 弗法, 伯爵, Furfur
35. 馬加錫亞, 侯爵, Marchosias
36. 斯托拉斯, 親王, Stolas

37. 菲尼克斯, 侯爵, Phenex
38. 漢帕, 伯爵, Halphas
39. 瑪帕, 統領, Malphas
40. 拉默, 伯爵, Raum
41. 弗加洛, 公爵, Focalor
42. 拜帕, 公爵, Vepar
43. 斯伯納克, 侯爵, Sabnock
44. 沙克斯, 侯爵, Shax
45. 拜恩, 君王, Vine

46. 畢弗隆斯, 伯爵, Bifrons
47. 化勒, 公爵, Uvall
48. 哈加堤, 統領, Haagenti
49. 克羅賽爾, 公爵, Crocell
50. 佛爾卡斯, 騎士, Furcas
51. 拜朗/巴拉姆, 君王, Balam
52. 安洛先, 公爵, Alloces
53. 凱姆, 統領, Caim
54. 毛莫, 公爵, Murmur

55. 歐洛博司, 親王, Orobas
56. 吉蒙里, 公爵, Gremory
57. 歐塞, 統領, Ose
58. 亞米, 統領, Amy
59. 歐利昂, 侯爵, Orias
60. 瓦布拉, 公爵, Vapula
61. 撒共, 君王, Zagan
62. 瓦拉克, 統領, Volac
63. 安朵斯, 侯爵, Andras

64. 浩瑞士, 公爵, Haures
65. 安德雷安富, 侯爵, Andrealphus
66. 錫蒙利, 侯爵, Cimejes
67. 安度西亞, 公爵, Amdusias
68. 貝利亞爾/彼列, 君王, Belial (墮落七天使
69. 單卡拉比, 侯爵, Decarabia
70. 系爾, 親王, Seere
71. 但他林, 公爵, Dantalion
72. 安杜馬里, 侯爵, Andromalius


所羅門七十二柱魔神 -等級

帝王, PrinceofDarkness
大公, GreatDukes
幕僚, Ministers
將軍, Generals
王, Kings
公爵, Dukes
侯爵, Marquis
伯爵, Earl's
總統, Presidents
公子, Princes
惡魔, Devil's
使魔, Imps

If sweet, sweet God loves you so, then I will make you worthy of his love.

You're handed this precious gift, right?
Each one of you granted redemption from the Creator.
Murderers, rapists and molesters...
all of you, you just have to repent,

and God takes you into his bosom.

In all the world's, in all the universe, no other creature can make such a boast, save man.
It not fair.

If sweet, sweet God loves you so,
then I will make you worthy of his love.

So..
I'll bring you pain,
I'll bring you horror,
so that you may rise above it.

So that those of you who survive this reign of hell on Earth, will be worthy of God's love.

<Constantine, 2005>

2022年7月1日 星期五

Good receives all the praise and adulation while evil is sent to quiet time in the corner.

That's when I learned a very hard lesson.
Good receives all the praise and adulation.

While evil is sent to quiet time in the corner.

Was it my destiny? Maybe it was.
Being bad is the one thing I'm good at.
If I was the bad boy, then I was going to be the baddest boy of them all.

<Megamind, 2010>

2022年6月25日 星期六

until one of us dies, leaving the other one old and $50 richer

The entire institution of gift-giving makes no sense.
Let's say I go out and I spend $50 on you.
It's a laborious activity because I have to imagine what you need where you know what you need.

I could simplify things, just give you the $50 directly..
and then you could give me $50 on my birthday and so on...

until one of us dies, leaving the other one old and $50 richer.

And I ask you, is it worth it?

<The big bang theory s01ep16, The peanut reaction>

2022年6月19日 星期日

I suggest Rock, Paper, Scissors, Lizard, Spock.

- Anecdotal evidence suggests that in the game
Rock, Paper, Scissors
players familiar with each other will tie 75 to 80 percent of the time..
due to the limited number of outcomes.

I suggest
Rock, Paper, Scissors, Lizard, Spock.

- It's very simple.
Scissors cuts paper, paper covers rock,

Rock crushes lizard,
Lizard poisons Spock,
Spock smashs scissors,
Scissors decapitates lizard,
Lizard eats paper,
Paper disporves Spock,
Spock vaporizes rock,

and as it always has, rock crushes scissors.

<The Big Bang Theory, s02ep8, The Lizard-Spock expansion>

2022年6月17日 星期五

Little Miss Grown-Ups-Don't-Play-With-Toys.

You hypocrite.
Little Miss Grown-Ups-Don't-Play-With-Toys.

If I went into that apartment right now, would I not find Beanie babies?
Are you not an accumulator of Care Bears and My Little Ponies?
And who's that Japanese feline I see frolicking on your shorts?
Hello hello Kitty.

<The Big Bang Theory, s01ep14, The Nerdvana Annihilation>

2022年6月12日 星期日

情境義務 與焦慮

行為的重複迫使受試者產生結合的力量
當受試者不斷進行電擊 他必須合理化自己的行為

如果他中途終止實驗 他不得不跟自己解釋
「到目前為止我做的都是錯得 我認知到所以終止」
反之 如果他繼續下去
就能確保先前的行為無誤
隨後的行動化解了不安

焦慮的根源 是人不斷將社會生活基本規則內化成自己的一部分
最基本的就是服從權威

一旦「冰融」
也就是做到不服從後
這種壓力 焦慮 恐懼全部不翼而飛

責任感的喪失

只要能控制人們詮釋世界的方式 就能控制他們的行為
一個行為從某個視角觀看也許可憎 但從另個視角觀看就理由充足

人們傾向接受由正當性權威提供的行動定義

轉變代理人心態最大的影響是
人只對指揮他的權威負責
而不對權威下達的行為負責

下屬感到羞恥或自豪
完全取決於自己是否是當執行權威交代的任務

進入權威系統

轉變成代理人的第二個心態是進入系統
光是察覺權威還不夠 權威必須與我們有關聯性

跨過門檻進入權威的領域後 就會受權威影響
在實驗室裡進行的實驗 受試者覺得實驗者「擁有」空間
自己在空間裡行為必須適切

社會總是盡可能讓民眾「自願」進入各種體制
自願服從正當性的權威
制裁不服從的主要力量
來自於自願者本身

制裁的力量不在於外在強制
來自於自願者本身對角色的「承諾」

自願者的服從具有內化的基礎 不仰賴外在來源

權威的察覺

轉變成代理人心態的第一個條件是察覺到正當性的權威
當人們察覺某人在特定環境裡擔任社會控制的角色
這個人就是眾人眼中的權威

一旦離開特定的環境
權威不一定仍是權威

就像機師對乘客的權威僅限於飛機上
權威獲得的是規範性的支持
大家共同的預期 認為在某種情境下總會有進行社會控制的人存在

權威的力量不是個人的特質
而是源於眾人眼中他在社會結構中的位置

Leonard. I still don't care

Leonard: Regardless, I have a chance at a real relationship with Leslie.
I'm not gonna pass that up for some hypothetical future happiness with the woman who may or may not want me to be happy..
with the woman who is currently making me happy.

Shaldon: Leonard.
Leonard: Yeah?

Sheldon: I still don't care.

<The Big Bang Theory, s01ep5, The hamburger postulate>


2022年6月4日 星期六

服從的能力就像語言能力


人不是孤立的 人總是在階級結構中扮演一定功能
我們在鳥類 兩棲 哺乳類身上發現支配結構

而在人類身上發現權威結構
人類的權威結構不是指體態 體力上的對抗 而是象徵

有組織的團體 可以藉由階級組織獲得巨大優勢
面對外在威脅 物種競爭的威脅 以及團體內部可能的分崩離析

社會組織的優勢不僅在外在目標的追求
也可能表現在內部的穩定 與成員的和諧
藉由界定成員的地位 將組織內部的摩擦降低

====
我們生來就有服從的「潛力」
這種潛力與社會價值互動後 使我們成為服從的人

有機體需要具備語言能力 才能擁有某種高度特定的心智結構
服從的能力就像語言能力
就像接觸必要社會環境才能產生說話的人 服從亦是如此

<服從權威, obedience to authority: an experiment view, >

2022年6月1日 星期三

it's all just corn flakes.

Morty: Consider the leprechaun.

Michael: What?

Morty: The one in the cereal commercials.

Michael: 'They're magically delicious'?
That guy?

Morty: He's always chasing the pot of gold, but when he gets there, at the end of the day,

it's all just corn flakes.

Michael: "Huh?"

Morty: You don't know the metaphor?

<Click, 2006>

2022年5月21日 星期六

人生也是外力與內力的對抗 只要有足夠的內力就能撐過去

東勳:所有建築物都是內力與外力的對抗
風 荷重 震動

內力總是要比外力強壯

人生
也是外力與內力的對抗
無論發生什麼事
只要有足夠的內力就能撐過去

至安:人生的內力是什麼

東勳:我小時候有個聰明的朋友
大家都覺得他會成為社區的大人物
但那傢伙大學畢業沒多久
就突然剃光頭入寺出家了

當時他的父母氣極了
整個社區震驚不已

他離開的時候說過這些話
他要成為 沒有擁有任何東西的人

大家一輩子都為了 想要擁有東西而吃足苦頭
為了讓別人看看自己是怎樣的人 拼命生活
卻不知道自己擁有什麼

即使他擁有了想要的東西
當那些讓他感覺安全的事物
以及讓他有自我價值的東西

開始出現裂痕的話

他會承受不住 然後崩潰

那些他自我價值的東西
那些他以為支撐著自己的東西
其實不是他真正的內力

<我的大叔, ep.8>

2022年5月20日 星期五

但他即使失敗了也還是若無其事的樣子 讓我更喜歡他了

宥拉:人類一輩子都害怕失敗
因此活在恐懼中
至少我是如此

起初導演失敗的時候我真的很開心
但他即使失敗了
也還是若無其事的樣子

讓我更喜歡他了

原來失敗也沒關係
根本不是什麼大事
原來就算失敗了 也能夠幸福
他讓我安心下來了

這個社區感覺很爛
大家好像也都一敗塗地
但我沒有看到絲毫的不幸 我發誓

所以我喜歡你
因為你讓我很安心

<我的大叔, ep.7>

現實就是地獄 你以為這裡是天堂嗎

東勳:公司就是這樣的地方
不是看誰工作能力比較差
看不順眼的會先被開除

至安:要是我 我會去跟上頭告狀
讓對方先被炒魷魚

東勳:你覺得給予壞人懲罰
內心會很痛快吧

你試試看

最後你也會受到牽連
不是只有那傢伙遭殃

東勳:現實就是地獄
你以為這裡是天堂嗎

我來到地獄應該是有原因的
受完處罰應該就可以走了

<我的大叔, ep.7>

2022年5月15日 星期日

好希望AI時代趕快來

宥拉:好希望AI時代趕快來
AI演戲最好了 也最會讀書了
AI也很擅長當律師 法官 醫生

當人不會在自以為是
如果能夠不再自以為是
該能有多自由呢

人只需要 愛人就好了

在這個擠滿自以為是的人的世界
我真的受夠了

我 沒有一件事是擅長的
感覺快要死了

<我的大叔, ep.6>

無論聽到什麼關於你的事 我都會裝作不知道

東勳:面對知道自己受傷的人
會很不自在 會不想見到對方

只要不說出來就好 那樣就不重要了
只要不知道就好 那樣就不重要了

至安:如果那樣 你就會深陷恐懼
直到秘密被對方知道為止

“誰知道了?”
“還有誰知道?”
 每次你見到人時就會想
 “他什麼時候會知道呢 會不會已經知道了呢”

有時候我會想
與其一輩子過得那麼不安

還不如被公布在光化門的電子螢幕上

讓全世界的人都知道

東勳:我會裝作不知道的
無論聽到什麼關於你的事

我都會裝作不知道

<我的大叔, ep.6>

你以為很親的話就不會罵對方了嗎 難道人只有一個面貌嗎

東勳:人都在背後說壞話
你以為很親的話就不會罵對方了嗎
難道人只有一個面貌嗎
我也會在背後罵人哪 罵就罵 那又怎樣

如果你聽到有人在罵別人
不要轉達給當事人 當作不知道就好
對你們年輕人來說 
也許把一切說出來才是友情

但大人不會這麼做
裝作不知道 是義氣 也是禮貌
如果你說了
那個人就會躲著你

<我的大叔, ep.6>

重如千斤的是你的心

東勳:山上很平和嗎

我拖著重如千斤的身體
心不甘情不願地去上班

謙德:你的身體再重也不過一百二十斤

重如千斤的是你的心

<我的大叔, ep.5>

-잘 사는 사람들은 좋은 사람되기쉬워 -生活好的人 容易成為好人

할머니: 좋은 사람이지? 좋은 사람 같아.
奶奶:(他看起來是好人 好像是的)

지안:잘 사는 사람들은 좋은 사람되기쉬워.
至安:生活好的人 容易成為好人

<我的大叔, ep.5>

Every meaningful experience must be packaged and delivered to you to watch at a distance

She only postponed her defeat.
And while she postpones her defeat, you eats chips and watch her confront problems..

that you are too lazy to deal with.

Superheros are part of your brainless desire,
to replace tire experience with simulation.

You don't talk, you watch talk shows.
You don't play games, you watch game shows.

Travel, relationship, risk..
every meaningful experience must be packaged and delivered to you to watch at a distance.

So that you can remain ever sheltered, ever passive, ever ravenous consumers..
who can't bring themselves to rise from their couches, break a sweat, and participate in life.

You want superheros to protect you..
and make yourselves ever more powerless in the process.

So that the system can keep stealing from you
smile at you all the while.

So go ahead, send your supers to stop me.
Grab your snacks, watch your screens, and see what happens.

You are no longer in control.

<超人特攻隊2, Incredibles 2, 2018>

等解決了足夠的問題 你就能回家了

當一切都越來越糟時 你只能堅強的面對
這就是我如何解決這個問題的

你要嘛屈服, 要嘛反抗, 就是這樣
你只要開始, 進行計算
解決一個問題
解決下一個問題
解決下下個問題

等解決了足夠的問題 你就能回家了

<絕地救援, The Martian, 2015>

2022年5月14日 星期六

無論你要做什麼 都不應該當著對方家人的面

東勳:我也曾經向人下跪
被人打過巴掌
被人罵過

但那時候我很慶幸
我的家人完全不知情

我還能裝作沒事
買吃的回家
若無其事的吃晚餐

沒什麼大不了的
無論我受到什麼羞辱
只要我家人不知情就沒事

無論你要做什麼
都不應該當著對方家人的面

如果你在他家人面前糟蹋他

那麼
你就算被殺了也不奇怪

<我的大叔, ep4>

2022年5月13日 星期五

反正我的人生要完蛋了 哭有什麼用

東勳:你就放寬心跟她離婚吧

尚勳:我是絕對不會離婚的

我不只沒錢 還全身病痛
等到媽過世 奇勳結婚後

我就會變成獨居老人

就算是出去撿廢紙資源回收
應該有夠兩個人勉強生活

要是讓她看到我每個月
穩定賺100萬韓回來的樣子

她一定會跟我複合的

我打算在那之前

盡量風流的過日子
哇 風流的日子呢

反正我的人生要完蛋了
哭有什麼用
只會害媽傷心而已

<我的大叔, ep3>

他總是比較偏向良心 這種人最可憐了

奇勳:真是可憐的三兄弟

尚勳:為什麼是三兄弟 東勳他哪裡可憐了

奇勳:奇怪的是我從以前就覺得
二哥是我們裡面最可憐的了

野心與良心之間
他總是比較偏向良心
這種人最可憐了

<我的大叔, ep1>

不會紅的 少了一樣東西 女人

尚勳:你不要再執著拍不了的動作片了
拍恐怖片吧

名為 「大叔」 的恐怖片

中年大叔被裁員
做生意把資遣費賠光
被離婚
變成沒有錢的乞丐

老母親的喪禮沒有半個人來弔唁
半夜睡到一半咳嗽 結果閃到腰
在床上躺了了三天
都沒有人來找他

不對
早上醒來喝水 拿杯子的時候 閃到腰
眼珠都沒辦法動
就保持著同個姿勢直到太陽下山

不覺得很恐怖嗎

奇勳:我們這個圈子有不成文規定
自己的故事只有自己覺得有趣

尚勳:這個不一樣 大叔最近正夯正紅著

東勳:不會紅的 
少了一樣東西


女人

<我的大叔, ep1>

2022年5月2日 星期一

服從權威 -接近受害者

我們如何解釋受害者離受試者越近 服從的比例便隨著下降?

1. 同理心的提示
視覺上的提示與受害者的痛苦結合起來
可能會在受試者心中產生情感反應
使他更完整的掌握受害者的體驗

2. 認知領域的否定與窄化
遠端回饋窄化了認知
讓受試者可以將受害者拋諸腦後
當受害者接近受試者時 受試者會越來越難以忽略受害者

3. 互惠領域
顯然 從暗處傷人會比明處傷人要容易的多
在受害者的注視下 受試者會產生羞恥與罪惡感
從而增加不服從權威的可能性

我們“羞恥的別過頭去” 或是“羞恥的避開對方”
這麼做是為了減輕內心的不適
把接受槍決的人雙眼矇住 顯然是減少受刑者的恐懼
但也是為了減少行刑隊的壓力

4.行動與結果合一
在遠端回饋時 受試者不容易看出自己的行為 與受害者的痛苦之間的連結
近端回饋時 獲得比較完整的統一性

5. 起初的團體組成
當受害者更靠近受試者時
受害者更有機會拉攏受試者一起對抗實驗者

受試者也不需要獨自面對實驗者
他眼前就有一個盟友 空間關係潛在的改變了聯盟關係

6. 習得的行為傾向
同窩出生的老鼠總是鮮少打鬥
(動物)是從什麼都不做當中 學會了什麼都不做
這種現象我們稱作被動抑制

這個原則在教導個人學習和平共處上有重要意義
人可以單純藉由不與人打鬥來學會不與人打鬥



2022年4月29日 星期五

Lego time lapse


Lego time lapse:
----
https://www.google.com/amp/s/www.pro-lapse.com/how-to-shoot-a-lego-time-lapse-video/amp/

Time-Lapse calculate:
----
https://www.pro-lapse.com/time-lapse-calculator/?_gl=1*jdhck0*_ga*YW1wLURMWUVwUWxJbEZVbnJZTDd4VWJTMDNkN085OGdIQW4yUWNYSHNzMmNVQW5KR21RSzdFTGV3M08zNl9wTVN2bzI.




2022年4月19日 星期二

那些年我們追的韓劇韓綜 -2020

12月
====
Seoul connects u: g-idle
Seoul connects u: oh my girl


11月
====
百日的郎君
Bvndit roadview trip


10月
====
Bu:QUEST of itzy
轄區現場


9月
====
Weeekly we clear
我的大叔


8月
7月
6月
====
今生是第一次


5月
====
Let's go your with bvndit
Bvndit dingo 엄마의 영상편지


4月
3月
====
愛的迫降


2月
1月
====
金秘書為何那樣
德魯納酒店

love playlist season 3
playlist. Just one bite
playlist. In seoul
playlist. W.H.Y

2022年4月13日 星期三

1038, binary search tree to greater sum tree

1038, binary search tree to greater sum tree
====
tree, BST

====
試想一下一個BST: [4,1,6]
GreaterSum就是 [4+6, 1+4+6, 6], 也就是固定先加總右子 >>> 再來node >>> 再來左子

1. 如何開始: root開始, 照右>中>左

2. 如何結束: 當!node就return, 終究走完

====
class Solution {
public:
  TreeNode* BstToGst(TreeNode* root){
    int sum=0
    SumNode(root, &sum)
    return root
  }
  void SumNode (TreeNode* node, int& sum){
    if(node == NULL) return

    SumNode(node->right, sum)
    sum+=node->val
    node->val = sum
    SumNode(node->left, sum)
  }
}

938, range sum of BST

938, range sum of BST
====
tree, BST
DFS
BFS

====
DFS:
1. 如何開始: 先從root開始
每次都加
node(如果符合range則node->value 否則0), 
node->left, 
node->right

2. 如何結束: 如果本身!node 就return 0

====
class Solution {
public:
  int rangeSumBST(TreeNode* root, int L, int H){
    if(!root) return 0
    return (root->val >= L && root->val <=H ? root->val : 0) + rangeSumBST(root->left, L, H) + rangeSumBST(root->right, L, H)
  }
}

====
BFS:
1. 如何開始: root加到queue, 每次加左子右子

2. 如何停止: queue空

====
class Solution {
public:
  int rangeSumBST(TreeNode* root, int L, int H){
    queue<TreeNode*> pq
    int sum=0
    pq.push(root)
    while(!pq.empty()){
      TreeNode* cur = pq.front
      pq.pop()
      if(cur->val >= L && cur->val <= H)
        sum+=cur->val
      if(cur->left) pq.push(cur->left)
      if(cur->right) pq.push(cur->right)
    }//while pq.empty

  return sum
  }
}

2022年4月11日 星期一

1315, Sum of nodes with even-vlaues grandparent

====
1315, Sum of nodes with even-vlaues grandparent
====
tree,
DFS,
BFS

====
DFS:
1. 照順序 從root檢查 root's parent/grandparent
加總sum(global
左子/右子樹加入dfs

2. 如何起始:root, Null, Null
如何停止:檢查左子右子是否空 才扔DFS

----
class Solution {
public:
  int sum=0
  int sumEvenGradparent(TreeNode* root){
    dfs(root, null, null)
    return sum
  }
  void dfs(TreeNode* node, TreeNode* parent, TreeNode* grandpa){
    if(!root) return
    if(grandpa && grandpa->val%2==0)
      sum += root->val
    if(node->left) dfs(node->left, node, parent)
    if(node->right) dfs(node->right, node, parent)
  }
}

====
BFS:
1. 如何起始:q.push(root)
如何停止:
for整個程式->while q.empty時停止
for加總->如果node為空就return 0, 不然就return node->val

2. q.push左子 右子
應該在while !q.empty內

但是在node->val%2外
因為目的是走過/檢查過所有的node, 因此不侷限在%2的case
----
class Solution{
public:
  int sum=0
  int func(TreeNode* root){
    return root? root->val : 0
  }
  int sumEvenGrandparent(TreeNode* root){
    if(!root) return
    queue<TreeNode*> q
    q.push(root)
    while(!q.empty()){
      TreeNode* node = q.front()
      q.pop()
      if(node->val%2==0){
        if(node->left){
          sum+= func(node->left->left) + func(node->left->right)
        }
        if(node->right){
          sum+= func(node->right->left) + func(node->right->right)
        }
      }//if even

      if(node->left) q.push(node->left)
      if(node->right) q.push(node->right)
    }//while q.empty
    return sum
  }

}

2022年4月10日 星期日

1302, Deepest leaves sum

====
1302, Deepest leaves sum
====
tree
DFS, BFS

====
DFS:
1. 題目給一個TreeNode
從(root, 0//lvl, depth)開始DFS

2. 懶人法, vec<int>sum[i] 紀錄每i層depth的total
在DFS中

如果sum size等於傳入的lvl, 則表示這層depth第一次加入到sum, 所以sum.push_back

否則, 表示已經有index 'lvl', 加入到sum[lvl]
//初始root 0, sum size也零, sum.push_back == sum[0]
//root右子樹 1, sum size卻是2, 表示有左子樹加入過了, 合併到sum[lvl] == sum[1]

3. 最終return vector最後一個元素 == sum.back

----
class Solution {
public:
  vec<int> sum
  int deepestLeaveSum(TreeNode* root){
    dfs(root, 0)
    return sum.back()
  }
  void dfs(TreeNode* node, int lvl){
    if(sum.size() == lvl)
      sum.push_back(node->val)
    else
      sum[lvl] += node->val

    if(node->left) dfs(node->left, lvl+1)
    if(node->right) dfs(node->right, lvl+1)
  }
}

====
BFS:
1. 題目給一個TreeNode
依照lvl/depth加入queue, pop all並加總

2. 懶人法, 當queue不等於空
把sum清空
並且元素pop all並加總//for, 這樣就會得到每一層的sum

如果還有左子右子, push到queue
如果queue空, 表示最後一層leave做完了, return當次/最終sum

----
class Solution {
public:
  int sum
  int deepestLeaveSum(TreeNode* root) {
    queue<TreeNode*> q
    q.push(root)
    while(!q.empty()){
      sum=0
      int qlen = q.size()
      for(int i=0, i<qlen, i++) {
        TreeNode* node = q.front()
        q.pop()
        sum+=node->val

        if(node->left) q.push(node->left)
        if(node->right) q.push(node->right)
      }//for qlen
    }//while q.empty

    return sum
  }
}

2022年4月6日 星期三

785, is graph bipartite

785, is graph bipartite
====
coloring,
bipartition,
BFS

====
1. 同886, 給予一個vec<vec<int>>graph
限制不同屬的規則(dislike)

新增一個vec<int>color
0初值, 1,-1兩類

新增一個queue q處理每次的相關元素

2. while(!q.empty) 檢查所有元素規則
for cur, 當次元素
for nei, cur元素的graph規則
如果color[nei] != 0則skip

如果color[nei]=0, 未走訪 => 看color[nei] 與color[cur]
分兩類
如果分不了兩類, false

如果走完, q空都沒有failed, 則true

====
class Solution {
public:
  bool isBipartite(vec<vec<int>>&graph) {
    int n= graph.size()
    vec<int> color(n,0)
    queue<int> q

    for(int i=0, i<n, i++){
      if(color[i] != 0)
        continue
      color[i]=1
      for( q.push(i), !q.empty(), q.pop()) {
//這種寫法?!

        int cur=q.front()
        for( int nei: graph[cur]) {
          if(color[nei] == 0) {
            q.push(nei)
            color[nei] = color[cur]==1 ? -1 : 1
          }
          if(color[nei] == color[cur])
            return false

        }//graph[cur].size

      }//!q.empty()
    }//for n
    return true
  }

}

886, possible bipartition


886, possible bipartition
====
Coloring
Bipartition

====
1. 與union類似(?
給予一個vec<vec<int>> dislike的rule, 跟N個元素
->
新增一個vec<vec<int>> graph, 紀錄需要走訪的關係
//類似於union的input

新增一個color(N, 0)
0未走訪, 1,2兩類

新增一個queue處理當次graph元素的所有關係
//?


2. while(!q.empty) 檢查所有元素規則
for u, 當次元素
for v, u元素的graph規則
如果color[v] != 0則skip

如果color[v]=0, 未走訪 => 看color[u] 與color[v]
分兩類
如果分不了兩類, false

如果走完, q空都沒有failed, 則true

====
class Solution {
public:
  bool possibleBipartition(int N, vec<vec<int>&dislike) {

  vec<vec<int>>graph(N, vec<int>())
  queue<int> q
  vec<int> color(N, 0)

  for( i=0, i< dislike.size(), i++ ){
    u= graph[i][0] -1
    v= graph[i][1] -1
    graph[u].push_back(v)
    graph[v].push_back(u)
  }

  for( i=0, i<N, i++){
    if(color[i] != 0)
      continue

    q.push(i)
    color[i]=1 //起始

    while( !q.empty() ){
      u= q.front()
      q.pop()
      for( k=0, k<graph[u].size, k++ ){
        v= graph[u][k]

        if(color[v]==0){
          q.push(v)
          color[v] = color[u]==1 ? 2 : 1
        }
        if(color[v]==color[u])
          return false
      }//for graph[u].size
      
    }//while

  }//for N
  return true
  }

}


2022年3月31日 星期四

210, Course Schedule 2


210, Course Schedule 2
====
Topological sort

====
1. 給予一個node_number, 一個規則preReq vec<vec<>>
建立一個graph vec<vec<>>來紀錄topo //父子關係

2. 建立一個indegree
根據先後的規則 for紀錄每個node的深度
//聰明, 深度加在preReq的頭元素, 原則越多越深
//深度為0就是必須第一個走在前面的

3. 建立一個Queue nodes 存放走訪的點的順序,
//深度為0 加入queue

一個Int visit紀錄走過的點的數量, 判斷最終走過的點是不是全部點數量
//不是 則有cycle

4. 每當queue不為空
pop, push_back到ret
->
當次元素pop掉後, 去graph找接著的topo元素是哪些
->
這些topo元素, indegree -1
如果degree變0, 表示接著可以處理了, 加入queue

====
vec<int> findOrder(int numCourse, vector<pair<int, int>>& prerequest){

vec<vec<int>> graph(numCourse, vec<int>() )
vec<int> indegree(numCourse, 0)
queue<int> nodesQ
int visited=0
vec<int> ret

for( auto eq: prerequest ){
  graph[eq.second].push_back( eq.first )
  indegree[eq.first]++
}

for( int n, n<numCourse, n++)
  if(indegree[n] == 0)
    nodeQ.push(n)

while(!nodeQ.empty()){
  visited++

  int nid = nodeQ.front()
  nodeQ.pop()
  ret.push_back(nid)

  for( auto topo:graph[nid] ){
    indegree[topo]--
    if(indegree[topo]==0)
      nodeQ.push(topo)
  }

}//while empty

return visited==numCourse ? ret : vec<int>()
}



2022年3月24日 星期四

蘿莉銘

蘿莉銘

身不在高,米四就行,胸不在大,有型則靈,斯是蘿莉,為吾是侵。
洋裝貓耳朵,小嘴大眼睛。短髮很俏麗,長髮也飄逸。可以給糖果,玩親親。
無八卦之亂耳,無血拼之勞行。學校游泳室,公園小涼亭。
吾自云:能萌就行

2022年3月1日 星期二

Others can read the ingredients on a chewing gum wrapper and unlock the secrets of the universe

Some people can read War and Peace and come away thinking 
it's a simple adventure story. 
Others can read the ingredients on a chewing gum wrapper and unlock the secrets of the universe.

<Lex Luthor, Gene Hackman as Lex Luthor - Superman, 1978>

2022年2月28日 星期一

Because Love is the best thing we do.

It was a twisting, turning road that led to the end of the aisle,
and not everything along the way was perfect.

To be honest,
not everything to follow would be perfect either.
But what is?

Here is the secret, kids:
None of us can vow to be perfect.

In the end, all we could do is promise to love each other with everything we've got.

Because Love is the best thing we do.

<How I Met Your Mother, s09ep22, The End of the Aisle>

2022年2月27日 星期日

You will be shocked kids, when you discover how easy it is in life to part ways with people forever.

And that's how it go, kids.
The friends, neighbors, drinking buddies
and partners in crime you love so much when you're young,

as the years go by, you just lose touch.

====
You will be shocked kids,
when you discover how easy it is in life to part ways with people forever.

That's why, when you find someone you want to keep around, you do something about it.

<How I Met Your Mother, s9ep21, Gary Blauman>

Rally

Kids, no matter how hard it try,
even the best of us go a little too wild sometimes.

And in those moments, we all need someone who loves us to help us rally.

Even if that means lying once in a while.

<How I Met Your Mother, s09ep18, Rally>

Even when people roll their eye or call you crazy. Even then. Especially then!

If you're looking for the word that means caring about someone
beyond all rationality and wanting them to have everything they want,
no matter how much it destroy you, it's love.

And when you love someone, you just, you don't stop, ever.

Even when people roll their eye or call you crazy. Even then. Especially then!

You don't give up. Because if I could give up...
if I could just take the whole world's advice
and move on and find someone else, that wouldn't be love.

That would be... some other disposable thing that is not worth fighting for.

<How I Met Your Mother, s09ep17, Sumrise>

It's like the first lottery ticket I ever bought was, kaboom, jackpot, and I'm pretty sure I'm not going to win again

Tracy: I'm on permanent hiatus in the love department.
I guess I'm old-fashioned.
I believe that each of us only gets one. And I got mine already.

I was in love with somebody a long time ago,
and he died.

It's like the first lottery ticket I ever bought was,
kaboom, jackpot, and I'm pretty sure I'm not going to win again.

<How I Met Your Mother, s09ep16, How Your Mother Met Me>

A simple "yes" would've sufficed

Barney: You guys can't still see where Marshall slapped me, can you?

Ted: Your face looks like a "don't walk" signal.

Robin: Your face looks like a photo negative of the Hamburger Helper box.

Ted: A palm reader could tell Marshall's future by studying your face.

Robin: The phrase "talk to the hand cause the face ain't listening", doesn't work for you
cause the hand is on your face.

Barney: ...A simple "yes" would've sufficed.

<How I Met Your Mother, s09ep15, Unpause>

2022年2月24日 星期四

YOU'RE GOD DAMN RIGHT I DID!

- You want answers?

- I want the TRUTH!
- YOU CAN'T HANDLE THE TRUTH!

- Son, we live in a world that has walls,
and those walls have to be guarded by men with guns.

Who's gonna do it? You?
You, Lt. Weinberg?
I have a greater responsibility than you could possibly fathom.

You weep for Santiago and you curse the Marines. You have that luxury.
You have the luxury of NOT knowing what I know.

That Santiago's death, while tragic,
probably saved lives.
And my existence, while grotesque and incomprehensible to you, "saves lives".

You don't want the truth
because deep down in places you don't talk about at parties,
you want me on that wall.
You need me on that wall.

We use words like honor, code, loyalty.
We use these words as the backbone of a life spent defending something.
You use them as a punchline.

I have neither the time nor the inclination to explain myself to a man
who rises and sleeps under the blanket of the very freedom that I provide,
and then questions the manner
in which I provide it!

I would rather you just said "thank you"
and went on your way,
Otherwise, I suggest you pick up a weapon and stand a post.
Either way, I don't give a DAMN what you think you are entitled to!

- Did you order the code red?
- I did the job I...

- Did you order the Code Red?
- YOU'RE GOD DAMN RIGHT I DID!

<A Few Good Man, 1992>

2022年2月21日 星期一

Great. Then every decision you make from here on out, should be in service of that.

- Let me save you a few years.
Even if it sounds completely crazy..
What is it you want to do with your life?

- I want to end poverty.
- Great.
Then every decision you make from here on out, should be in service of that.

<How I Met Your Mother, s09ep16, How Your Mother Met Me>

2022年2月15日 星期二

207, Course schedule

207, Course schedule
====
Topological sort
Coloring

====
1. 給予一個n node number
一個vec<pair<int,int>>prerequest規則

2. prerequest表明<i,j>(有向圖)
如果要access i, 必須先有j
如果規則互斥(產生cycle) 則false

可能有很多方式
可用DFS 可用BFS 可用coloring

3. Coloring比較單純
生成一個map<int, vec<int>> adj來填入規則 //hashMap
->
adj[1].push_back(0)

生成一個vec<int> visited(n,0)來紀錄
如果走的過程中有碰到任何已經拜訪過的
則有cycle, false

否則true

====
class Solution{
public:
bool isCycle(vec<int>visited, vec<vec<int>>adj, int id){

  if visited[id] == 1 return true
  if visited[id] == 0{
    visited[id]=1
    for auto edge:adj[id]
    if isCycle(visited, adj, edge) return true
  }
  visited[id]=2 //?
  return false
}


bool canFinished(int n, vec<vec<int>>& pre){
  map<int, vec<int>> adj
  for auto edge: pre
    adj[edge[1]].push_back(edge[0])

  vec<int> visited(n, 0)
  for auto prule: adj{
    if(isCycle(visited, adj, prule.first)) return false
  }//
return true
}

};

1091, Shortest path in binary matrix

1091, Shortest path in binary matrix
====
BFS,
Shortest path,
Path existed

====
1. 題目給予vec<vec<int>>matrix
從左上 欲走到右下
路徑上只能是0 可以走八個方向

2. 一個queue< pair<int,int>>做BFS
一個vec<vec<bool>> visited記錄走過

3. 起點是左上
找它的鄰近加入queue

紀錄每次queue.size

而後每次找鄰近 且 matrix[][]==0 加入queue

4. 每次round++
當有座標碰到右下
return round(左上)

====
class Solution {
public:
int shortestPathBinaryMatrix(.vec<vec<int>>& grid ){

  int m= grid.size(), n= grid[0].size()
  if( grid[0][0]!=0 || grid[m-1][n-1]!=0 ) return -1

  queue< pair<int,int>> pq
  pq.push({1,0}), pq.push({0,1}), pq.push({1,1})

  vec<vec<bool>> visited=(m, vec<bool>(n, false))
  int res=1 //第一輪
  while(!pq.empty()){
    int qSize= pq.size()
    for(int t-qSize){
      auto qFront= pq.front()
      pq.pop()
      int x= qFront.first
      int y= qFront.second
      
      if(x==m-1 && y==n-1) return res+1 //第n輪加上右下+1

      if(x>=0 && y>=0 && x<m && y<n && !visited[x][y] && grid[x][y]==0){
        visited[x][y]=true
        pq.push({x-1,y-1}), pq.push({x-1,y}), pq.push({x-1,y+1})

        pq.push({x,y-1}), pq.push({x,y+1})

        pq.push({x+1,y-1}), pq.push({x+1,y}), pq.push({x+1,y+1})
      }//if
    }//for qSize
    res++

  }//while q.empty
  return -1
}
};

994, rotting oranges

====
994, rotting oranges
====
BFS,
Shortest path,
Path existed
====
1. 給予一個箱子
'0'代表空
'1'代表好的
'2'代表爛的橘子

每分鐘爛的會向四個方向腐爛
求最大(久)箱子內還有好的

2. 起點是爛的->爛的(2) 座標/pair加入queue
隨後加入找好的(1)
但是要把它變爛(2)才 座標/pair加入queue

3. 多一個int fresh紀錄剩餘的好的
每次BFS加入記得扣掉

多一個int res紀錄第幾輪
return res
//剛開始的BFS還沒開始感染
//所以放在while裡面即可

4. 四個方向化成一個vector
vec<int> for={-1, 0, 1, 0, -1}
//只要1234, 2345 pair就好

====
class Solution{
public:
int orangesRotten( vec<vec<int>>& grid ){
  int m= grid.size(), n= grid[0].size()
  int fresh=0
  queue< pair<int,int>> q

  for i-m
    for j-n
      if grid[i][j] == 2
        q.push(<i-1,j>), q.push(<i+1,j>), q.push(<i,j-1>), q.push(<i,j+1>);
      if grid[i][j] == 1
        fresh++

  vec<vec<bool>> visited(m, vec<bool>(n, flase))
  int res=-1
  while( !q.empty() ){
    int qSize= q.size()
    while(qSize--){
      auto fq= q.front()
      q.pop()

      int x= fq.first
      int y= fq.second
      if(x>=0 && y>=0 && x<m && y<n && !visited[x][y] && grid[x][y]==1){
        visited[x][y]=true
        grid[x][y]=2
        q.push(<x-1,y>), q.push(<x+1,y>), q.push(<x,y-1>), q.push(<x,y+1>);
      }//if

    }//q.size
    res++
  }//q.empty

if(res==-1) return 0
if(fresh>0) return -1 //有橘子永遠不爛 莫急
}
};


2022年2月14日 星期一

問題類似的模式 奇摩子缺差很多

碰到難解的問題
尋求幫忙&討論
這是求助高手

看到關鍵字
一直下放問題要求解答&實驗
這是owner/打雜工

====
先不論做事這端人數多寡
類似的模式
奇摩子缺差很多

但卻取決於對方端怎麼處理

2022年2月6日 星期日

奧林帕斯十二神

奧林帕斯十二神
====
宙斯, Ζεύς/ Zeus
天空 雷霆之神
霹靂, 鷹, 橡樹, 節杖, 天平

希拉,  Ἥρα/ Hera
婚姻 家庭女神
孔雀, 石榴, 冠冕, 杜鵑, 獅子, 犢牛

波塞頓, Ποσειδών/ Poseidon
海洋 地震 海嘯之神
馬, 公牛, 海豚, 三叉戟

狄蜜特, Δημήτηρ/ Demeter
生育 農業 自然 季節女神
罌粟, 小麥, 火炬, 豬

雅典娜, Αθηνά/ Athena
智慧 技藝 戰爭 戰略女神
貓頭鷹, 後蛇, 橄欖樹

阿波羅, Απόλλων/ Apollō
太陽 光明 藝術之神
太陽, 豎琴, 弓箭, 烏鴉, 海豚, 天鵝, 狼, 鼠

阿蒂蜜絲, Ἄρτεμις/ Artemis
狩獵 孕育 月亮女神
月亮, 犢鹿, 獵犬, 犢熊, 蛇, 柏樹, 弓箭

阿瑞斯, Ἀρης/ Ares
戰爭 暴力 血腥之神
野豬, 蛇, 狗, 禿鷹, 矛盾

阿芙羅黛蒂, Αφροδίτη/ Aphrodite
愛 美 慾望女神
鴿子, 鳥, 蘋果, 蜜蜂, 天鵝, 番石榴, 玫瑰

赫菲斯托斯, Ἡφαιστος/ Hephaestus
工匠 火 鍛造之神
火, 砧, 斧頭, 驢, 錘子, 火鉗, 鵪鶉

荷米斯, ʽἙρμῆς/ Hermes
傳令神 冥界引導者
旅行 竊盜 體育 道路交叉邊界 商業之神
手杖, 翼鞋, 翼盔, 鶴, 龜

赫斯提亞, Εστία/ Hestia
火炬 家務 家庭女神
火炬

戴歐尼修斯, Διόνυσος/Dionysos
酒 慶典 狂歡之神
葡萄, 常春藤, 酒杯, 虎, 豹, 海豚, 山羊

2022年2月4日 星期五

Yeah. I don't speak virgin either.

- When a woman puts on an engagement ring, is like when Bilbo Baggins wears the One Ring in The Hobbit.

- Okay, can you say that again but not in nerd?

- Sure. The ring is like the cloak that Harry Potter wears to sneak around Hogwarts.

- Yeah. I don't speak virgin either.

<How I Met Your Mother, s08ep14, Ring Up>

You're gonna get endless requests to play some game that has something to do with gangsters and farming.

Robin: It's like the 15-time my dad has sent me a friend request. I'm just gonna hit 'accept'

Marshall: You don't want to see what's behind that door.
Robin: What are you talking about?

Ted: He's talking about my mom's 2000-word review of 'Fifth Shades of Grey'.
And 14 of those words were "vulva".

Marshall: You're gonna get endless requests to play some game that has something to do with gangsters and farming.

<How I Met Your Mother, s08ep13, Band or DJ?>

1162, As far from land as possible

====
1162, As far from land as possible
====
BFS,
Shortest path
Path existed
====
1. 目標是water, '0'
能有與
起點land, '1'能有的最長距離

2. 
定義一個queue<pair<int,int>>存放座標
BFS第一輪找的是起點->從'1'開始上下左右加第一輪BFS

3. 當queue不為空
front && pop座標
如果符合條件 //!visited && 是目標'0'
=>
visited true/ update cost/ 加入上下左右BFS

4. 當最遠的座標找到 會結束
=>
最遠的座標 在上一輪會將上下左右加入queue
=>
新的一輪 for step++
=>
都不符合條件 pop
一直都沒有符合條件的座標 所以都沒有加入queue
=>
while queue空了 跳出
=>
這次的step無作用
step-1才是預期

====
class Solution{

public:
int maxDistance( vec<vec<int>>& matrix ){
  int m= matrix.size(), n= matrix[0].size()
  vec<vec<bool>> visited= (m, vec<bool>(n, false))
  queue<pair<int,int>> pq
  for i-m
    for j-n
      if matrix(i,j) == 1
        pq.push(i-1,j)
        pq.push(i+1,j)
        pq.push(i,j-1)
        pq.push(i,j+1)

  int step=0
  while(!pq.empty()){
    step++
    int size=pq.size()
    for t-size{
    int x= pq.front().first
    int y= pq.front().second
    pq.pop()
    if( x>=0 && y>=0 && x<m && y<n && matrix(x,y)==0 && !visited(x,y) ){
      visited(x,y) = true
      pq.push(x-1,y)
      pq.push(x+1,y)
      pq.push(x,y-1)
      pq.push(x,y+1)
    }//if
    }//for
  }//while

  return step==1? -1: step-1
}
};

2022年2月3日 星期四

Oh, let's just bone a bunch so I'm another year older and still single?

Woman over 30 don't joke when it comes to commitment.

No 32-year-old woman is happy taking thing slow.
Trust me, Victoria has got friends from high school posting pictures of second babies on Facebook.

And you think your girlfriend all like, "Oh, let's just bone a bunch so I'm another year older and still single"?
Bitch, please.

<How I Met Your Mother, s08ep5, The Autumn of Break-Ups>

542, 01_matrix

====
542, 01_matrix
====
BFS,
Shortest path
Path existed
====
1. 題目希望將給予的matrix
化成
每個單元離它最近的'0'的距離

2. BFS用的是queue, 因為用了座標
所以用queue< pair<int,int> >來紀錄加入queue的座標

3. 從(0,0)開始做BFS
當queue不為空的時候
-> pop單元
-> 針對pop的動作處理BFS //加入新的單元
//新增step or cost

4. Visited是必須的
產生一個vec<vec<bool>>visited來紀錄已經處理過的單元
以免單元間產生無窮迴圈
->
當沒有visited
符合題目條件
則處理
BFS //push

====
class Solution{

public:
vec<vec<int>> updateMatrix( vec<vec<int>>&matrix ){
  int m= matrix.size()
  int n= matrix[0].size()
  queue<pair<int,int>> pq

  for i-m
    for j-n
      if(matrix(i,j) == 0){
      //先從'0'開始 因為第一次與零的距離是“0”
      //之後逐漸加一
        pq.push({i-1, j});
        pq.push({i+1, j});
        pq.push({i, j-1});
        pq.push({i,j-1});
        //上下左右加入queue //所有第一層的node
      }

  int step=0
  vec<vec<bool>> visited(m, vec<bool>(n, false) )
  while( !pq.empty() ){
  step++
  int size= pq.size() //紀錄當前的queue size來控制當次需要做多少次
  for(i=0; i<size; i++){
    auto Front= pq.front()
    int x=Front.first
    int y=Front.second
    pq.pop()

    if(x>=0&& y>=0&& x<m&& y<n&& !visited(x,y)&& matrix(x,y)==1){
      //開始找‘1’,因為開始要填1到0的距離
      visited(x,y)=true
      matrix(x,y)=step
      //因為拜訪過了 且當前的距離已經填入
      pq.push({x-1, j});
      pq.push({x+1, j});
      pq.push({i, y-1});
      pq.push({i,y-1});
      //第n次層的上下左右 加入queue

    }//if
  }//for
  }//while

}
};

2022年2月2日 星期三

Then it's baby's turn to be crazy.

- She's pregnant.
She gets to be crazy. You have to be the sane one.

- So what, I don't get to be crazy again til the baby comes?

- No. Then it's baby's turn to be crazy.

- Then when do I get to be crazy again?

- Never.

<How I Met Your Mother, s07ep21, Now We're Even>

Every time I go out and have an awesome night and you're not there, that's another hundred points in my column

I'm talking about the game of life, Ted.
Scoreboard. Better wardrobe: 75 points.
Apartment on a higher floor: 90 points.
Longer name: 110 points.

Every time I go out and have an awesome night and you're not there,
that's another hundred points in my column.

So, yeah, I'm in the lead.
<How I Met Your Mother, s07ep21, Now We're Even>

2022年2月1日 星期二

Top10 things Marshall said on his wedding night

Marshall: It's hard for the little guy to perform under pressure.
Barney: "Top10 things Marshall said on his wedding night."

Kevin: Whoa! It was small, but I think I felt something.
Robin: "Top10 things Lily said on her wedding night."

Marshall: Stop laughing at it, Lily.
(All): Top10 things Marshall said on his wedding night!!

<How I Met Your Mother, s07ep16, The Drunk Train>

Oh, God. This is parenthood, isn't it?

Every 30 seconds, there's another crisis that needs to be dealt with, and I have to deal with it.
This is..

Oh, God. This is parenthood, isn't it?
<How I Met Your Mother s07ep15, The Burning Beekeeper>

802, Find eventual safe states

====
802, Find eventual safe states
====
DFS,
cycle find

有向/無向圖找cycle不一樣
有向需要三個顏色(還沒看過/ 還在看/ 已經看完
無向需要兩個顏色(visited/ un-visited

過程中有碰到訪問過/看過的node
就是有cycle

====
a)
1. 題目給予一個graph
定義一個int dp(n, 0)初值

0, 還沒看過
-1,還在看
1,已經看完

2. DFS一進去
先將dp[i]=-1 //還在看
然後針對graph[i][]一一DFS檢查
如果有false則return false

3. 如果graph[i][]跑完 都沒看到cycle 
//如果沒有看到dp==-1, i.e還在看

則dp[i]=1, i.e已經看完
return true
else
return dp[i]==1

4. main一個for跑DFS
如果false,就不加入結果
否則是安全的,加入

====
class Solution{

public:
bool DFS( vec<vec<int>>&graph, vec<int>&dp, int i){
  if ( dp[i] ) //-1 ->false, 1 ->true
    return dp[i]==1

  dp[i]=-1
  for auto t:graph[i].begin; t!=graph[i].end; t++
    if ( !DFS( graph, dp, *t ) )
      return false

  dp[i]=1
  return true;
}
vec<int> eventualSafe( vec<vec<int>>&graph ){
  int n=graph.size()
  vec<int> res
  vec<int> dp(n, 0)
  for i-n
    if( DFS( graph, dp, i )
      res.push_back(i)

  return res
}
}

733, Flood Fill

====
733, Flood Fill
====
DFS,
from each un-visited node/island problems

====
1. 題目給予一個vec<vec<int>>M
一個起始的座標
以及變更的新數值

2. 定義一個vec<vec<bool>>visited
DFS( M, visited, i, j, m, n, new )走過上下左右的同值/同於起始 的所有node

====
class Solution{

void DFS( vec<vec<int>>& matrix, vec<vec<bool>>&visited, int i, int j, int m, int n, int old, int new){
  if( i<0 || j<0 || i>=m || j>=n || matrix(i,j)!=old || visited(i,j) ) return;

  visited(i,j)= true;
  matrix(i,j)= new;
  DFS( matrix, visited, i-1, j, m, n, matrix(i,j), new)
  DFS i+1
  DFS j-1
  DFS j+1

}

vec<vec<int>> FloodFill( vec<vec<int>>& matrix, int x, int y, int newColor ){
  int m= matirx.size(), n= matrix[0].size()
  vec<vec<bool>> visited= (m, false)

  if matrix(x,y)!=newColor
    DFS( matrix, visited, x, y, matrix(x,y), newColor)

  return matrix
}

2022年1月31日 星期一

Silenzio, Bruno.

Silenzio, Bruno.

<Luca, 2021>

early-relationship chicken

Kids, early in any relationship
there's a phase where you don't say no to anything.
Because you want to seem interesting, adventurous, and open-minded.
I called it early-relationship chicken.
<How I Met Your Mother, s07ep14, 46mins>

2022年1月30日 星期日

The best you can hope for is to have some good company

I did finally make it up here to the house later that week,
only to find that a falling oak tree had landed in the living room.
If we'd been there, it would have crushed us like bugs.

You see, kids, there's no way of knowing for sure where the safest place is,
so the best you can hope for is to have some good company.

<How I Met Your Mother, s07ep9, Disaster Averted>

2022年1月29日 星期六

That moron should not be making big life decisions right now

Lily is only agreeing to all this
because of pregnancy brain.
Her brain is marinating in a cocktail of hormones, mood swings and jacked-up nesting instincts.

I mean, yes, right now Lily is a goodness bestowing the miracle of life,
but damn, she dumb.

That moron should not be making big life decisions right now.

<How I Met Your Mother, s07ep8, The Slutty Pumpkin Returns>

So, yes, we saw the iceberg, we warned the Titanic.But you all just steered for it anyway. Because you want to sink

Imagine, if you glimpsed the future
and you're frightened by what you saw,
what would you do with that information?

You would go to..
Who? Politicians? Captains of industry?
And how would you convince them?
With data? Facts?

The only facts they won't challenge are the ones that keep the wheels greased and the dollars rolling in.

----
The probability of widespread annihilation kept going up.
The only way to stop it was to show it.
To scare people straight.

Because what reasonable human being wouldn't be galvanized by the potential destruction of everything they have ever known or loved?

----
But how do you think this vision was received?

How do you think people responded to the prospect of imminent doom?

They gobbled it up like a chocolate eclair.

They didn't fear their demise, they repackaged it. It can be enjoyed as video games, as TV shows, books, movies.

The entire world wholeheartedly embraced the apocalypse.

Meanwhile, your Earth was crumbling all around you.
You've got simultaneous epidemics of obesity and starvation. Explain that one.

Bees and bufferflies start to disappear.
The glaciers melt.
Algae blooms all around you.
The coal mine canaries are dropping dead,

...and you won't take the hint!

In every moment, there is the possibility of a better future. But you people won't believe it.

And because you won't believe it,
you won't do what is necessary to make it a reality.
So you dwell on this terrible future, and you resign yourselves to it. For one reason,

because that future doesn't ask anything of you today.

So, yes, we saw the iceberg, we warned the Titanic.
But you all just steered for it anyway, full steam ahead.
Why?

Because you want to sink.
You gave up.

<Tomorrowland, 2015>

There are two wolves, and they're always fighting. One is darkness and despair, the other light and hope. Which one wins

There are two wolves, and they're always fighting.
One is darkness and despair, the other light and hope.
Which one wins?

The one you feed.

<Tomorrowland, 2015>

I just know that bitch is gonna take the last whole wheat-everything bagel

All my friends from high school, they're here with their wives, their kids.
Me? My date for the night is a sticky magazine.

I used to believe in destiny, you know.
I'd go to the bagel place, see a pretty girl in line, reading my favorite novel,
whistling the song that's been stuck in my head all week, and I'd think:
"Hey, maybe she's the one"

Now I think, "I just know that bitch is gonna take the last whole wheat-everything bagel."

----
It's just every day I think I believe a little less..
And thats sucks..

<How I Met Your Mother, s07ep1, The Best Man>

841, Keys and rooms

====
841, Keys and rooms
====
DFS,
for each unvisited node/island problems

====
1. 題目給予固定長度n的房間 以及房間內含的鑰匙
題目定義第一間是沒有鎖的=>DFS開始的地方
生成一個n的visited

2. DFS走過所有的鑰匙
最終for檢查visited
如果還有房間un-visited則false

====
class Solution{
public:
void DFS( vec<vec<int>>&rooms, vec<bool>&visited, int node){
  visited[node]=true
  for auto k:rooms[node]
    if( !visited[k] )
      DFS( rooms, visited, k )
}

bool VisitedRoom( vec<vec<int>>& rooms ){
  int n=rooms.size()
  vec<bool> visited(n, false)
  DFS( rooms, visited, 0 )

  int i=0
  for i-n
    if !visited[i] return false
  return true
}  

2022年1月28日 星期五

1254, Number of closed islands

====
1254, Number of closed islands
====
DFS from each unvisited node/island problem

====
a)
----
1. 題目給予一個vec<vec<char>>的網絡(grid
生成一個vec<vec<bool>>的visited
來表示這個node是不是檢查過了
//因為DFS有上下左右 可能先前被查過了

2. (看題目)定義DFS的行為:
DFS( grid, visited, i, j, m, n )
->
如果超界, 如果是'0', 如果造訪過了 return
else, 
visited改成true
這個node的上下左右去做DFS

3. 回到main(看題目)定義main的行為:
for for grid
如果是'1', 如果還沒造訪過
DFS( grid, visited, i, j, m, n )
count++
//因為DFS會做完, 能連到的都連完了, 才跳出
//就找到一個island
//如果for又找到 應該又是全新的island 故重新算重新加

====
class Solution{

void DFS( vec<vec<int>>&grid, vec<vec<bool>>&visited, int i, j, m, n){
  if i<0 || j<0 || i>=m || j>=n || visited(i,j) || grid(i,j)!='1'
    return

  visited(i,j)=true
  DFS( grid, visited, i-1, j, m, n)
  DFS(i+1
  DFS(j-1
  DFS(j+1
}

public:
int closedIsland (vec<vec<int>>&grid){
  int m=grid.size()
  int n=grid[0].size()
  vec<vec<bool>> visited(m, vec<bool>(n, false))

  int count=0
  for i-m
    for j-n
      if( grid [i][j] == '1' && !visited[i][j] ){
        DFS( grid, visited, i, j, m, n)
        count++
      }
  return count
}
};


2022年1月26日 星期三

1376, Time needed to inform all employees


====
1376, Time needed to inform all employees
====
DFS,
Time taken to reach all nodes, or share info to all graph nodes

====
1. 題目給予一個vec<int> manager
=>
生成一份vec<vec<int>> children
or
map<int, vec<int>> children
children用意在紀錄node擁有的child
(可視為hash map

2. 因為children會紀錄所mana<->child關係
所以從root(題目給的headID) 開始DFS
會走過所有node

3. 題目給予一個 vec<int>informTime
定義一個resource 為最終total結果

每次DFS,
一個current為加上目前informTime[i]的時間

每次DFS 比較max(resource, current)
最終return resource

====
class Solution{
int DFS( vec<vec<int>>&child, int node, vec<int>&time){
if child[node].size == 0
  return 0
  //本次node沒有children, time沒有增加, return

int ans= time[node]
int tempMax= 0

for(auto c: child[node]){
  tempMax = max( tempMax, DFS( child, c, informTime)
//如果child有多個 會停在for裡面
//當有找到更大的結果 會丟給tempMax
//當次還沒return就不會被清零
//清零用意只是紀錄當次node子集裡的最大
}

return ans+tempMax
//結果等於 當前的time[node] 
//加上
//子集裡面最大的time
}
public:
int numOfMinute( int n, int headID, vec<int>& manager, vec<int>& informTime){

vec<vec<int>> children(n)
for int i=0; i<n; i++
  if manager[i] != -1
    children[ manager[i] ].push_back(i)

return DFS( children, headID, informTime )
}

2022年1月25日 星期二

130, Surrounded regions


130, Surrounded regions
====
DFS boundary
====
1. 題目是說被1包圍的0 可以被翻牌
=>
沒有碰到邊界的0 可以被翻牌
(有連結到)碰到邊界的0無法被翻牌

2. 從邊界開始找有沒有0
當找到邊界為0, 對它的做DFS(上下左右)
找到的0, 先把它變更符號e.g.#

3. for, for go through
剩下的0是可以翻成1的
剩下的#是不能翻的 翻回0

====
class Solution{
public:
  void surroundRegion(vec<vec<char>>&board){
    int m=board.size(), n=board[0].size()
    for int i=0; i<m; i++
      if board[i][0] == 'o'
        DFS(board, i, 0, m, n)
      if board[i][n-1] == 'o'
        DFS(board, i, n-1, m, n)

    for int j=0; j<n; j++
      if board[0][j] == 'o'
        DFS(board, 0, j, m, n)
      if board[m-1] == 'o'
        DFS(board, m-1, j, m, n)

    for i-n
      for j-n
        if board[i][j] == 'o'
          board[i][j] = 'x'
        if board[i][j] == '#'
          board[i][j] = 'o'
}
void DFS(vec<vec<char>>board, int i, j, m, n){
  if i<0 || j<0 || i>=m || j>=n || board(i,j)!='o'
    return
  board(i,j) = '#'
  DFS(i-1, j, m, n)
  DFS(i+1, j, m, n)
  DFS(i, j-1, m, n)
  DFS(I, j+1, m, n
}

2022年1月24日 星期一

990, satisfiability of equality equation


====
990, satisfiability of equality equation

====
Union_find
====
1. root單元是“字母” 不是給予eq.size
//eq.size是formula size

字母-“a"的差距
即可化為單元vec<int>

2. vec<string> eq
eq[0], [3]是字母單元
eq[1]是判斷

3. go through eq兩次
第一次先處理等於
如果eq[1]=='=' 則root[ep(0)] = root[eq(0)]

二次處理不等於
如果eq[1]=='!'
但是先前的等於eq 讓單元root相等, 則flase

====
class Solution {
vector<int> root[26]
public equationPossible(vec<string>& equations) {
  
  for 0<26; root[i] = i
  for string eq:equations
    if eq[1] == '='
      root[ find(root, eq[3] -'a') ] = find(root, eq[0] -'a')
  for string eq:equations
    if eq[1] == '!'
      if find(root, eq[3] -'a') == find(root, eq[0] -'a') 
        return false
  return true
}
find(vec<int>root, int x){
  if root[i] == x
    return x
  return find(root, root[x])
}

2022年1月23日 星期日

Graduation goggles

It's graduation goggles.
Like with highschool. It's four years of bullies,
making fun of the kids with branches,
even after the branches come off and they can walk just fine.

But then on graduation day, you suddenly get all Misty because you realize you're never gonna see those jerks again.

====
The point is, you can't trust graduation goggles.
They're just misleading as beer goggles,
bridesmaid goggles,
and "that's just a bully outdated cell phone in his front pocket" goggles.

<How I Met Your Mother, s06ep20, The exploding meatball sub>

2022年1月22日 星期六

He'll never get to see how I turn out

He'll never get to see how I turn out.
My dad.

I used to always tell him about that I was gonna be an environmental lawyer.
But he never got to see the version of me that was anything but a corporate stooge.

Lily, if we have a baby right now.
That is just it for me.
The cement will dry out, and I will be stuck at GNB, forever.

<How I Met Your Mother, s06ep17, Garbage Island>

1319, Number of operations to make network connected


====
1319, Number of operations to make network connected

====
Union find
====
1. 給予n台電腦, matrix of connection
所以matrix size至少要大約等於n-1

2. 給予root(n)紀錄單元root
如果有描述的link, root[y] = x

3. 如果有相同的root
(redundant (count++

====
class Solution:
vec<int> root(n)

public makeConnected(int n, vec<vec<int>>& con){

  int count=0, cable=con.size()

  if cable < n-1
    return -1
  else
    for i-n root[i] = I
    for i-n
      int x = getRoot(con[i][0])
      int y = getRoot(con[i][1])
      if x == y
        count++
      else
        root[y] = x
      return count

int getRoot(int i)
  if root[i] == I
    return i
  return getRoot(root[i])

947, Most stones remove with same row or column


====
947, Most stones remove with same row or column

====
1. 給予n個stones(雖然每個是座標)
因此給予一個root[n] 存放stone的root
//不要被座標混淆

2. 一樣初值n 假設每個stone單元都是獨立

3. for, for go through
每個stone, 與其他後順序的stone, 檢查座標
如果相同則root[j] = I
//是stone順序 //不要被座標混淆

最後for go through root
如果root[i] == i, (表示一個交集)加count

4. result為全部n 減去集合的count(=redundant

====
class Solution {
public removeStone(vec<vec<int>>& stone)
  int n= stone.size(), count= 0
  vec<int> root(n)
  for i-n root[i] = i
  for i; i<n; i++
    for j=i+1; j<n; j++
      if stone[i][0] == stone[j][0] ||
        stone[i][1] == stone[j][1]
          root[j] = i

  for i-n
    if root[i] == i count++
  return n-count


2022年1月21日 星期五

684, Redundant connection

====
684, Redundant connection

====
Union find
====
1. 使用一個list來紀錄每個單元的root
起始值都-1

2. for每個edge的點一,點二去找Root

如果(新的一輪edge(x, y))x_root== y_root,
則是redundant, return edge

else, root[y]= x_root

====
class Solution {
public:

vec<int> root(2000, -1)
vec<int> findRedundant(vec<vec<int>>& M){
  
  for(int i=0; i<root.size(); i++) root[i] = i

  for(auto edge:M)
    int x = findRoot(edge[0])
    int y = findRoot(edge[1])

    if(x == y) return edge
    else
      root[y]= x

int findRoot(int i)
  if root[i] == i
    return i
  return findRoot(root[i])




If God is all powerful, He cannot be all good.

I've figured it out way back, 

if God is all powerful, He cannot be all good. And if He's all good then He cannot be all powerful.

And neither can you be. They need to see the fraud you are.

<Lex Luthor, Batman v Superman, 2016>

2022年1月19日 星期三

547, Number of provinces


====
547, Number of provinces/省

====
Union find
====
1. 使用一個list: Root紀錄每個單元的 _root
2. 預設一個group為n
(即一開始每個單元都是獨立的 可視為n的獨立集合

3. for gothrough每個link/M(I,j)
如果
M(I,j)== 1, i_root!= j_root, 則把Root[j]= i_root, group--
(找到一個單元是可以被包含的

====
class Solution:
public findProvince(vec<vec<int>>M)
  int n=M.size(), group=n
  vec<int> Root
  for i-n: Root[i]=i
  for i-n:
    for j-n:
      if M[i][j]==1
        int p1 = getRoot(Root, i)
        int p2 = getRoot(Root, j)
        if (p1 != p2)
          group--
          Root[p2] = p1

int getRoot(vec<int>&Root, int i)
  if(Root[i]!=i)
    Root[i] = Root[ Root[i] ]
    i=Root[i]
  return i