-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen_readme.sh
executable file
·52 lines (42 loc) · 1.14 KB
/
gen_readme.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
sed() {
if [ $(uname) == 'Darwin' ];then
gsed $@
else
/usr/bin/env "sed" $@
fi
}
cat > README.md <<EOF
# Blog
[雨过。天晴的博客](https://keep-learning.top)
EOF
cat >> README.md <<EOF
# Progress
\`\`\`
EOF
leetcode stat > /tmp/tmpr
echo "without locked" >> /tmp/tmpr
leetcode stat --no-lock >> /tmp/tmpr
leetcode stat -g >> /tmp/tmpr
sed -i -e 's/^/\t/g' /tmp/tmpr
cat /tmp/tmpr >> README.md
echo "\`\`\`" >> README.md
cat >> README.md <<EOF
# Accecpted
| 序号 | 题名 | 解答 |
|----- |:----:|:----:|
EOF
find ./Accepted -name '*notac*' -delete
for cpp in `ls Accepted | sort -n`;do
IFS="." splited=($cpp)
seqno=${splited[0]}
filename=${splited[1]//-/ }
cmd=''
for x in Of By The To And In From With Without;do
[ ! -z $cmd ] && cmd+='\|'
cmd+='\b'"$x"'\b'
done
cmd='s/'$cmd'/\l&/g'
filename=$(echo $filename | sed 's/ii\b\|^lfu\b\|\bi$\|\bii$\|\biii$\|\biv$\|^\w\|\b\w/\U&/g' | sed "$cmd")
echo "|$seqno | [$filename](https://leetcode.com/problems/${splited[1]}) | [My Answer](https://github.com/KKRainbow/LeetCode/blob/master/Accepted/${cpp}) |" >> README.md
done