Files
leetcode-go/.tmp_fix_table1.ps1
T

36 lines
1.5 KiB
PowerShell

$filepath = 'D:\Obsidian\leetcode-go\basic\队列实现.md'
$content = [System.IO.File]::ReadAllText($filepath, [System.Text.Encoding]::UTF8)
$lines = $content -split "`n"
# Table 1: replace lines at indices 102-112 (0-based)
$table1 = @(
'| 操作 | 状态 head → tail | 实际存储 [0..4] | head | tail | len | cap |',
'|------|-----------------|-----------------|------|------|-----|-----|',
'| 初始 | — | ───── | 0 | 0 | 0 | 5 |',
'| Inqueue(1) | head→tail | 1──── | 0 | 1 | 1 | 5 |',
'| Inqueue(2) | head→··tail· | 12─── | 0 | 2 | 2 | 5 |',
'| Inqueue(3) | head→···tail· | 123── | 0 | 3 | 3 | 5 |',
'| Dequeue() | ·tail→···tail· | ─23── | 1 | 3 | 2 | 5 |',
'| Dequeue() | ···tail→··tail· | ──3── | 2 | 3 | 1 | 5 |',
'| Inqueue(4) | head→···tail→ | ──34─ | 2 | 4 | 2 | 5 |',
'| Inqueue(5) | head→····tail→ | ──345 | 2 | 5 | 3 | 5 |',
'| Dequeue() | ···tail→···tail | ───45 | 3 | 5 | 2 | 5 |'
)
$newLines = @()
for ($idx = 0; $idx -lt $lines.Length; $idx++) {
if ($idx -ge 102 -and $idx -le 112) {
# Skip these lines (being replaced by table1)
continue
} elseif ($idx -eq 102) {
foreach ($line in $table1) {
$newLines += $line
}
} else {
$newLines += $lines[$idx]
}
}
[System.IO.File]::WriteAllText($filepath, ($newLines -join "`n"), [System.Text.Encoding]::UTF8)
Write-Output "Table 1 fixed. Total lines: $($newLines.Count)"