XpandNotes

exploring the intersection of technology and creativity

證明二分圖沒有奇數環(若且唯若)

A graph is bipartite if and only if it has no odd cycle

必要條件: 令 $G$ 為一個 bipartite,因為在 $G$ 中每走過一條邊,就會進入另一組 bipartition,所以要從某一點出發再走回該點,必定要走偶數次,故 $G$ 沒有 odd cycle。 充分條件: 令 $G$ 為無 odd cycle 的圖,並建構 $G$ 的 bipartite,從中選取一個 nontrivial component $H$,再從 $H$ 中選...

Xfce 基本設定

新酷音輸入法 透過 pacman 或 apt 安裝 ibus-chewing。 $ sudo pacman -S ibus ibus-chewing libibus libchewing 新增一個腳本放在 /etc/profile.d $ sudo vim /etc/profile.d/ibus.sh 輸入以下內容以便開機時自動啟用 ibus: 1 2 3 4 GTK_IM_...

C# 動態折線圖

劃出類似 CPU 使用率的動態折線圖 Form1 成員 用途 Chart chart 折線圖物件 int[] xvalue 折線的 x 座標陣列 int[] yvalue 折線的 y 座標陣列 ...

C# Asynchronous Socket

C# 傳統的 Socket 會在斷線時讓系統卡住十幾秒,就算用 try catch 機制也無法避免這個問題。而非同步連線內部的機制就不會讓系統卡住,以下是非同步連線寫出的函式。 1 2 3 4 5 6 7 8 9 10 11 12 13 // Asynchronous Socket public Socket AsyncConnect(string ip, string port) { ...

在 VirtualBox 安裝 Arch Linux

摘要 以下安中步驟主要參考自 youtube,我只是將安裝過程的指令和螢幕截圖下來,如果聽英文沒問題可以直接看影片。對分割、掛載磁碟、設定 Linux 環境很熟悉的人可以直接按照以下摘要的指令安裝: # setfont ter-224b.psf.gz # ping google.com ^C # ls /sys/firmware/efi/efivars # timedatectl set...

Arch Linux 基本設定

終端機字型 在 Arch 官網有一個 Font packages 列表,從中找一個你喜歡的字型,透過 pacman 或 yay 下載,我下載 Terminus。 $ sudo pacman -Syu terminus-font 然後在 /usr/share/kbd/consolefonts/ 就可以發現許多 ter 開頭的字型包,即為剛剛下載的 Terminus 字型。 $ ls ...

用 C++ 實作 Trie

Trie 簡介 Trie,又稱字首樹或字典樹,規則為將單字柴成一個一個字元,每個字元代表一個節點,依照字元在單字中的順序往下長成一棵樹。 Trie 實作方式 首先定義節點物件 node,其必須包含可以往下長的節點 child,在這裡我使用了 STL 的 unordered_map 來實作 child。node 還需要包含一個布林值 is_word 判別從根走到這個節點是否能讀作一個...

Debian 11 筆記

將使用者加入 sudoer 剛安裝好 Debian 時,一定會遇到下 sudo apt ... 卻被告知權限不足的問題,此時必須手動修改 /etc/sudoers 將目前的使用者 (lin) 加入 sudoer。 $ su - # gpasswd -a lin sudo # cd /usr/sbin # ./visudo 此時終端機會用 nano 開啟 sudoer.tmp,將下區塊...

使用 Weasyprint 將 HTML 轉成 PDF

在幫 tldr page 修改 pdf 渲染器時偶然發現 Weasyprint 這個好用的函式庫,以下介紹三種使用方法。首先透過 pip 安裝: $ pip3 install weasyprint 讀取 HTML 檔轉換成自動換頁的 PDF 首先我找了一個 HTML 範例 如下: mystyle.css 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16...

Leetcode #9 Palindrome Number

Description Given an integer x, return true if x is palindrome integer. An integer is a palindrome when it reads the same backward as forward. For example, 121 is palindrome while 123 is not. Ex...