This commit is contained in:
louiscklaw
2025-01-31 19:28:21 +08:00
parent ce9a4aa9b3
commit 72bacdd6b5
168 changed files with 939668 additions and 0 deletions

9
askjyee/gitUpdate.sh Executable file
View File

@@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -ex
git add .
git commit -m 'update,'
git push

6
askjyee/notes.md Normal file
View File

@@ -0,0 +1,6 @@
---
tags: app-inventor
---
# askjyee

View File

@@ -0,0 +1,46 @@
1) 按⏺REC掣開始錄音限時10sec
(錄音進行中⏺️中間白點會轉成紅色並整個按鈕會閃動就更好)
2) 按▶️可以重聽錄音
3) 如不滿意錄音結果可以按🆖或⏺REC重新錄制
4) 如滿意結果,可以按🆗然後在同一頁 或按➡️轉到下一頁開始設定時間
計時器⏱一共7個每一個前面放置一個小方格供用家剔選。剔選的話代表要執行不剔選的話不會執行。
5) ⏱1號計時器設定為0~30分鐘用家可自行設定所需時間 (本計時器執行時不會重播先前錄制好的話音)
6) ⏱2號計時器設定長度為90分鐘 (啟動後在10~80分鐘期間每隔5分鐘重復播放1組錄音共16組每組含3次重播1組共30秒完成)
7) ⏱3號計時器設定長度為90分鐘 (啟動後在15~70分鐘期間每隔5分鐘重復播放1組錄音共12組每組含3次重播1組共30秒完成)
8) ⏱4號計時器設定長度為90分鐘 (啟動後在40~75分鐘期間每隔5分鐘重復播放1組錄音共8組每組含3次重播1組共30秒完成)
9) ⏱5號計時器設定長度為90分鐘 (啟動後在40~65分鐘期間每隔5分鐘重復播放1組錄音共6組每組含3次重播1組共30秒完成)
10) ⏱6號計時器設定長度為90分鐘 (啟動後在30~65分鐘期間每隔5分鐘重復播放1組錄音共8組每組含3次重播1組共30秒完成)
11) ⏱7號計時器設定長度為90分鐘 (啟動後在10~25分鐘期間每隔5分鐘重復播放1組錄音共4組每組含3次重播1組共30秒完成)
注意除⏱1號計時器外其他6個計時器是有規定的。只有剔選了排在前面的計時器才可以剔選(或叠加)排在後面的計時器。
12) 完成時間設置後可以按▶開始順次序執行從⏱1號計時器到⏱2~7號計時器重播錄制語音的工作
13) 期間用家可以隨時按⏹️停止繼續執行整個程式 (本程式並不設置暫停功能)
14) 用家決定結束本程式的話可以按🏃🏼EXIT離開
舉個例:
2號計時器設定長度為90分鐘 (啟動後在10~80分鐘期間每隔5分鐘重復播放1組錄音共16組每組含3次重播1組共30秒完成)
我唔知我理解有冇錯,
我數到係會播 13 次 (組?)
我想問下 16 組係點數出黎?
你呢個黎計我諗我唔會用 app inventor 去做
於我黎講我會建議寫個簡單 app
個 app 會有兩頁,
第一頁係 (錄音+計時器)
第二頁係設定 (給手戶微調用)
如果唔係改邏輯 (計時器邏輯) 的話就可以用設定頁去改
一般黎計報價會大約 HKD1200 ~ HKD1400
你諗諗先,
想要 app 參考畫面的話可以睇睇呢個帖:
https://www.carousell.com.hk/p/1192889425

Binary file not shown.

BIN
averyleung/2023-10-11_10-08.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
averyleung/2023-10-11_10-24.png (Stored with Git LFS) Normal file

Binary file not shown.

7
averyleung/gitUpdate.bat Normal file
View File

@@ -0,0 +1,7 @@
git status .
@pause
git add .
git commit -m"update averyleung,"
start git push

36
averyleung/notes.md Normal file
View File

@@ -0,0 +1,36 @@
Q:
1. 加簡中版本
2. Logo置中 選擇放左logo下面一至排開
3. 搜尋酒品後的字體顯示
4. 酒莊背景的版排改至一眼睇晒
A:
1. 加簡中版本
- 圖書館
- 簡體中文未有頁
- 展览-活动
- 簡體中文為吉頁
- https://www.goyahk.com/展览-活动/?lang=zh-hans
- 相集
- 簡體中文為吉頁
- https://www.goyahk.com/相集/?lang=zh-hans
- 巴罗洛葡萄酒
- 格式未對齊繁中 / 英文
- https://www.goyahk.com/巴罗洛葡萄酒/?lang=zh-hans
- 酒庄背景
- 內容格式未對齊繁中
- 右上菜單未對齊繁中
- https://www.goyahk.com/about-wineries/?lang=zh-hans
- 酒莊背景
- 內容未有 (13個酒莊)
- 右上 menu 未對齊
- footer 未對齊
2. 想問一下 logo 係指 1 定 2 ? 定其他地方嘅 logo ?
![](./2023-10-11_10-08.png)
3. 你係咪指 1 同 2 之間嘅分別?
![](./2023-10-11_10-24.png)

Binary file not shown.

View File

@@ -0,0 +1,43 @@
<mxfile host="65bd71144e">
<diagram id="jUaFL9_61w-NF607VE0Q" name="Page-1">
<mxGraphModel dx="1130" dy="797" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<mxCell id="6" style="edgeStyle=none;html=1;" parent="1" source="2" target="3" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="2" value="Count letter occurence" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="330" y="240" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="7" style="edgeStyle=none;html=1;" parent="1" source="3" target="4" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="3" value="find the letter with most occurence,&lt;br&gt;assign it to k" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="330" y="340" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="21" value="" style="edgeStyle=none;html=1;" parent="1" source="4" target="13" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="4" value="decrypt file using the guessed k" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="330" y="440" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="16" value="" style="edgeStyle=none;html=1;" parent="1" source="11" target="15" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="11" value="Start" style="ellipse;whiteSpace=wrap;html=1;rounded=1;strokeColor=default;" parent="1" vertex="1">
<mxGeometry x="330" y="60" width="120" height="40" as="geometry"/>
</mxCell>
<mxCell id="13" value="End" style="ellipse;whiteSpace=wrap;html=1;rounded=1;strokeColor=default;" parent="1" vertex="1">
<mxGeometry x="330" y="540" width="120" height="40" as="geometry"/>
</mxCell>
<mxCell id="17" value="" style="edgeStyle=none;html=1;" parent="1" source="15" target="2" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="15" value="Open file to read&lt;br&gt;(i.e. ./wiki_e.txt)" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="330" y="140" width="120" height="60" as="geometry"/>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>

BIN
banson_hker/deliver/diagram/decrypt_file.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@@ -0,0 +1,104 @@
<mxfile host="65bd71144e">
<diagram id="jUaFL9_61w-NF607VE0Q" name="Page-1">
<mxGraphModel dx="2055" dy="1449" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<mxCell id="25" value="Yes" style="edgeStyle=none;html=1;" parent="1" source="21" target="24" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="39" value="No" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" parent="1" source="21" target="38" edge="1">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="570" y="310"/>
</Array>
</mxGeometry>
</mxCell>
<mxCell id="21" value="Alphabat ?" style="rhombus;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="320" y="270" width="80" height="80" as="geometry"/>
</mxCell>
<mxCell id="27" value="" style="edgeStyle=none;html=1;" parent="1" source="24" target="26" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="24" value="Get offset according letter case&lt;br&gt;&lt;br&gt;i.e.&lt;br&gt;capital letter &quot;M&quot; will use &quot;A&quot; as offset&lt;br&gt;small letter &quot;m&quot; will use &quot;a&quot; as offset" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="250" y="385" width="220" height="110" as="geometry"/>
</mxCell>
<mxCell id="29" value="" style="edgeStyle=none;html=1;" parent="1" source="26" target="28" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="26" value="subtract letter ascii code (i.e. &quot;M&quot;) &lt;br&gt;to offset selected above(i.e. &quot;A&quot;)&lt;br&gt;&amp;nbsp;&lt;br&gt;apply guessed k" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="250" y="530" width="220" height="80" as="geometry"/>
</mxCell>
<mxCell id="31" value="" style="edgeStyle=none;html=1;" parent="1" source="28" target="30" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="28" value="wrap around if &lt;br&gt;less than 0 / more than 26 &lt;br&gt;by getting the remainder" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="250" y="650" width="220" height="70" as="geometry"/>
</mxCell>
<mxCell id="33" value="" style="edgeStyle=none;html=1;" parent="1" source="30" target="32" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="30" value="get letter back after shifting" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="250" y="760" width="220" height="60" as="geometry"/>
</mxCell>
<mxCell id="32" value="Append to decrypted message" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="300" y="850" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="34" value="End" style="ellipse;whiteSpace=wrap;html=1;rounded=1;strokeColor=default;" parent="1" vertex="1">
<mxGeometry x="300" y="1050" width="120" height="40" as="geometry"/>
</mxCell>
<mxCell id="40" style="edgeStyle=none;html=1;entryX=1;entryY=0.5;entryDx=0;entryDy=0;" parent="1" source="38" target="32" edge="1">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="570" y="880"/>
</Array>
</mxGeometry>
</mxCell>
<mxCell id="38" value="number will not encrypt, append directly" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="510" y="410" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="41" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="42" target="44">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="42" value="Start" style="ellipse;whiteSpace=wrap;html=1;rounded=1;strokeColor=default;" vertex="1" parent="1">
<mxGeometry x="300" y="20" width="120" height="40" as="geometry"/>
</mxCell>
<mxCell id="43" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="44" target="46">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="44" value="loop through message by every letter" style="whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="300" y="90" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="45" value="" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="46" target="21">
<mxGeometry relative="1" as="geometry">
<mxPoint x="360" y="250" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="46" value="get one character" style="whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="300" y="180" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="47" value="" style="edgeStyle=none;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" edge="1" parent="1" target="49" source="32">
<mxGeometry relative="1" as="geometry">
<mxPoint x="360" y="940" as="sourcePoint"/>
</mxGeometry>
</mxCell>
<mxCell id="48" value="Yes" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="49" target="34">
<mxGeometry relative="1" as="geometry">
<mxPoint x="400" y="1050" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="50" value="No" style="edgeStyle=none;html=1;entryX=1;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="49" target="46">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="680" y="980"/>
<mxPoint x="680" y="210"/>
</Array>
</mxGeometry>
</mxCell>
<mxCell id="49" value="End of message ?" style="rhombus;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="320" y="940" width="80" height="80" as="geometry"/>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>

BIN
banson_hker/deliver/diagram/decryption.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@@ -0,0 +1,55 @@
<mxfile host="65bd71144e">
<diagram id="jUaFL9_61w-NF607VE0Q" name="Page-1">
<mxGraphModel dx="1329" dy="938" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<mxCell id="6" style="edgeStyle=none;html=1;" parent="1" source="2" target="3" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="2" value="Generate file name according to user input&lt;br&gt;(i.e. ./wiki_e.txt)" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="330" y="259" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="7" style="edgeStyle=none;html=1;" parent="1" source="3" target="4" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="3" value="open the file want to write&amp;nbsp;&lt;br&gt;(i.e. ./wiki_e.txt)" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="330" y="363" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="19" value="" style="edgeStyle=none;html=1;" parent="1" source="4" target="18" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="4" value="clear file content" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="330" y="467" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="14" value="" style="edgeStyle=none;html=1;" parent="1" source="5" target="13" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="5" value="write the encrpted content" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="330" y="676" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="16" value="" style="edgeStyle=none;html=1;" parent="1" source="11" target="15" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="11" value="Start" style="ellipse;whiteSpace=wrap;html=1;rounded=1;strokeColor=default;" parent="1" vertex="1">
<mxGeometry x="330" y="60" width="120" height="40" as="geometry"/>
</mxCell>
<mxCell id="13" value="End" style="ellipse;whiteSpace=wrap;html=1;rounded=1;strokeColor=default;" parent="1" vertex="1">
<mxGeometry x="330" y="790" width="120" height="40" as="geometry"/>
</mxCell>
<mxCell id="17" value="" style="edgeStyle=none;html=1;" parent="1" source="15" target="2" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="15" value="Get content from user inputted file&lt;br&gt;(i.e. ./wiki.txt)" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="330" y="154" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="20" value="" style="edgeStyle=none;html=1;" parent="1" source="18" target="5" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="18" value="Generate encrypted content" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="330" y="571" width="120" height="60" as="geometry"/>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>

BIN
banson_hker/deliver/diagram/encrypt_file.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@@ -0,0 +1,98 @@
<mxfile host="65bd71144e">
<diagram id="jUaFL9_61w-NF607VE0Q" name="Page-1">
<mxGraphModel dx="2260" dy="1594" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<mxCell id="16" value="" style="edgeStyle=none;html=1;" parent="1" source="11" target="15" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="11" value="Start" style="ellipse;whiteSpace=wrap;html=1;rounded=1;strokeColor=default;" parent="1" vertex="1">
<mxGeometry x="310" y="20" width="120" height="40" as="geometry"/>
</mxCell>
<mxCell id="46" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="15" target="45">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="15" value="loop through message by every letter" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="310" y="90" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="25" value="Yes" style="edgeStyle=none;html=1;" parent="1" source="21" target="24" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="39" value="No" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="21" target="38" edge="1">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="580" y="310"/>
</Array>
</mxGeometry>
</mxCell>
<mxCell id="21" value="Alphabat ?" style="rhombus;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="330" y="270" width="80" height="80" as="geometry"/>
</mxCell>
<mxCell id="27" value="" style="edgeStyle=none;html=1;" parent="1" source="24" target="26" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="24" value="Get offset according letter case" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="310" y="390" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="29" value="" style="edgeStyle=none;html=1;" parent="1" source="26" target="28" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="26" value="get distance between from letter to &quot;A&quot; or &quot;a&quot;" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="310" y="490" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="31" value="" style="edgeStyle=none;html=1;" parent="1" source="28" target="30" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="28" value="wrap around if &lt;br&gt;less than 0 / more than 26 &lt;br&gt;by getting the modules&lt;br&gt;&lt;br&gt;apply shifting" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="270" y="580" width="200" height="100" as="geometry"/>
</mxCell>
<mxCell id="33" value="" style="edgeStyle=none;html=1;" parent="1" source="30" target="32" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="30" value="get letter back after shifting" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="310" y="710" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="42" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="32" target="41">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="32" value="append to encrypted message" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="310" y="810" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="34" value="End" style="ellipse;whiteSpace=wrap;html=1;rounded=1;strokeColor=default;" parent="1" vertex="1">
<mxGeometry x="310" y="1020" width="120" height="40" as="geometry"/>
</mxCell>
<mxCell id="40" style="edgeStyle=none;html=1;entryX=1;entryY=0.5;entryDx=0;entryDy=0;" parent="1" source="38" target="32" edge="1">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="580" y="840"/>
</Array>
</mxGeometry>
</mxCell>
<mxCell id="38" value="number will not encrypt, append directly" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="520" y="390" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="43" value="Yes" style="edgeStyle=none;html=1;" edge="1" parent="1" source="41" target="34">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="44" value="No" style="edgeStyle=none;html=1;entryX=1;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="41" target="45">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="680" y="940"/>
<mxPoint x="680" y="210"/>
</Array>
</mxGeometry>
</mxCell>
<mxCell id="41" value="End of message ?" style="rhombus;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="330" y="900" width="80" height="80" as="geometry"/>
</mxCell>
<mxCell id="47" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="45" target="21">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="45" value="get one character" style="whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="310" y="180" width="120" height="60" as="geometry"/>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>

BIN
banson_hker/deliver/diagram/encryption.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@@ -0,0 +1,93 @@
<mxfile host="65bd71144e">
<diagram id="jUaFL9_61w-NF607VE0Q" name="Page-1">
<mxGraphModel dx="1883" dy="1328" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<mxCell id="25" value="Yes" style="edgeStyle=none;html=1;" parent="1" source="21" target="24" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="39" value="No" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="21" target="38" edge="1">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="530" y="470"/>
</Array>
</mxGeometry>
</mxCell>
<mxCell id="21" value="Alphabat ?" style="rhombus;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="280" y="430" width="80" height="80" as="geometry"/>
</mxCell>
<mxCell id="27" value="" style="edgeStyle=none;html=1;" parent="1" source="24" target="26" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="24" value="get the ascii code of all letter" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="260" y="570" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="29" value="" style="edgeStyle=none;html=1;" parent="1" source="26" edge="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="320" y="810" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="26" value="add 1 to the value indexed by the letter above" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="260" y="680" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="56" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="38" edge="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="320" y="810" as="targetPoint"/>
<Array as="points">
<mxPoint x="530" y="770"/>
<mxPoint x="320" y="770"/>
</Array>
</mxGeometry>
</mxCell>
<mxCell id="38" value="number will not encrypt, skipping this step" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="470" y="590" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="43" value="" style="edgeStyle=none;html=1;" parent="1" target="21" edge="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="319.9999999999998" y="380" as="sourcePoint"/>
</mxGeometry>
</mxCell>
<mxCell id="45" value="" style="edgeStyle=none;html=1;" parent="1" source="46" target="48" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="46" value="Start" style="ellipse;whiteSpace=wrap;html=1;rounded=1;strokeColor=default;" parent="1" vertex="1">
<mxGeometry x="260" y="70" width="120" height="40" as="geometry"/>
</mxCell>
<mxCell id="47" value="" style="edgeStyle=none;html=1;" parent="1" source="48" target="49" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="48" value="setup a array of 26 to collect result&lt;br&gt;initialize them all to 0" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="260" y="130" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="60" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="49" target="59">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="49" value="loop through message by every letter" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="260" y="210" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="50" value="End" style="ellipse;whiteSpace=wrap;html=1;rounded=1;strokeColor=default;" parent="1" vertex="1">
<mxGeometry x="260" y="940" width="120" height="40" as="geometry"/>
</mxCell>
<mxCell id="54" value="Yes" style="edgeStyle=none;html=1;" parent="1" source="52" target="50" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="57" value="No" style="edgeStyle=none;html=1;entryX=1;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="52" target="59">
<mxGeometry relative="1" as="geometry">
<mxPoint x="420" y="390" as="targetPoint"/>
<Array as="points">
<mxPoint x="670" y="850"/>
<mxPoint x="670" y="350"/>
</Array>
</mxGeometry>
</mxCell>
<mxCell id="52" value="End of message ?" style="rhombus;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="280" y="810" width="80" height="80" as="geometry"/>
</mxCell>
<mxCell id="59" value="get one letter" style="whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="260" y="320" width="120" height="60" as="geometry"/>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>

BIN
banson_hker/deliver/diagram/letter_statistics.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
banson_hker/deliver/sc/decryption_demo.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
banson_hker/deliver/sc/encryption_step1.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
banson_hker/deliver/sc/encryption_step2.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
banson_hker/deliver/sc/home.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
banson_hker/deliver/sc/message_len_short_demo.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
banson_hker/deliver/sc/quit_demo.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@@ -0,0 +1,196 @@
#!/usr/bin/env python
import os,sys
ORD_a = ord('a') # 97
ORD_A = ord('A') # 65
def shift_cipher_encrypt(plaintext, key):
# apply encryption to text with given key
encrypted_message = ''
for char in plaintext:
if char.isalpha():
ascii_offset = ORD_A if char.isupper() else ORD_a # Determine ASCII offset based on uppercase or lowercase letter
# the comment shown below are the pseudo code, it demonstrate the ideas only
# let say the input is 'the' // without quote
# find distance of target character with reference to A or a
# i.e. t - a = 19 , h - a = 7 , e - a = 4
distance = ord(char) - ascii_offset
# [19,7,4] + [8,8,8] (key) = [27, 15, 12]
# Shift the character by adding the key and taking modulo 26 to wrap around
# [27,15,12] % [26,26,26] = [1,15,12] // get modules
shifted_distance = (distance + key) % 26
# [1,15,12] + [97,97,97] = [98,112,109]
# chr(98) , chr(112) , chr(109) = 'bpm'
shifted_char = chr(shifted_distance + ascii_offset)
# so: the -> bpm
encrypted_message += shifted_char
else:
# consider integer case, retain
encrypted_message += char
return encrypted_message
def shift_cipher_decrypt(ciphertext, key):
plaintext = ""
for char in ciphertext:
if char.isalpha():
ascii_offset = ORD_a if char.islower() else ORD_A # Determine ASCII offset based on lowercase or uppercase letter
# Calculate the distance of the target character from a or A
distance = ord(char) - ascii_offset
# apply shift, get the remainder of 26
shifted_distance = (distance - key) % 26
# Convert back to ASCII
decrypted_char = chr(shifted_distance + ascii_offset)
plaintext += decrypted_char
else:
# If it is not an alphabetic character, retain as is.
plaintext += char
return plaintext
def count_letter_e(txt_in):
# reserved function for demonstration purpose
occurence = 0
for char in txt_in:
if char.isalpha():
if char.lower() == 'e':
occurence += 1
return occurence
def count_most_occurrence_letter(txt_in):
# letter e, as stated have the most occurrence in the message by statistics.
# as 'Shift Cipher' is a encryption by letter shifting, the letters have good chance
# to have the most occurrence too in the encrypted text.
output = [0] * 26 # bucket for 26 letters
for char in txt_in:
if char.isalpha():
output[ord(char.lower()) - ORD_a] += 1
# output contains the statistics of paragraph letter by letter
return output
def find_max_occurrence(char_occurrences):
# get the letter of the most occurrences. i.e. m
# by subtract between this letter to e, k can be guess
# find max occurrence and its index
max_idx = char_occurrences.index(max(char_occurrences))
# subtract it with index of e -> 4
return max_idx - 4
def encrypt_file(file_path, key=8):
# open a file and apply encryption
output_file = file_path.replace('.txt','_e.txt')
# convert it to integer
key = int(key)
# open source file (plaintext)
with open(file_path,'r') as fi:
temp = ''.join(fi.readlines())
# open target file (encrypted text)
with open(output_file,'r+') as fo:
fo.truncate(0)
fo.writelines([shift_cipher_encrypt(temp, key)])
print(f'encryption done and file saved to {output_file}')
return
def decrypt_file(file_path):
# will open an encrypted file and decrypt it by a guessed key
with open(file_path,'r') as fi:
# beginning of the process
# read file and join the lines all
lines = fi.readlines()
e_temp = ''.join(lines)
characters_distribution = count_most_occurrence_letter(e_temp)
print('')
print('distribution of letters in encrypted text (case insensitive, from a to z)')
print(characters_distribution)
print('')
guess_k = find_max_occurrence(characters_distribution)
print(f'guessed k: {guess_k}')
print('')
print('decrypted text:')
decrypted_text = shift_cipher_decrypt(e_temp, guess_k)
print(decrypted_text)
while True:
# show menu
print()
print("1. Encrypt File")
print("2. Decrypt File")
print("q. quit")
print()
option = input("Select an option (1/2/q): ")
if option == "1":
# run if user want to encrypt file
# check if user entered a file
user_not_enter_file = True
while user_not_enter_file:
file_path = input("Enter the path of the file to encrypt: ")
if len(file_path) > 0:
if os.path.exists(file_path):
user_not_enter_file = False
else:
print('sorry but the file not exist')
else:
print('please enter a file path')
# check if user entered a key
user_not_enter_key = True
while user_not_enter_key:
key = input("Enter the key(k) to encrypt: ")
if (len(key) > 0):
user_not_enter_key = False
else:
print('please enter a key(k)')
if os.path.exists(file_path):
encrypt_file(file_path, key)
print('encryption done')
else:
print("File does not exist.")
elif option == "2":
# run if user want to decrypt file
file_path = input("Enter the path of the file to decrypt: ")
if os.path.exists(file_path):
decrypt_file(file_path)
print('decryption done')
else:
print("File does not exist.")
elif option.lower() == "q":
print('quitting bye ...')
break
else:
print('')
print('ERROR !')
print('please enter either [1/2/q]')
input("press a key to continue ...")
print('')
print("Exiting...")

View File

@@ -0,0 +1 @@
python ./shift_cipher_encrypter.py

View File

@@ -0,0 +1,8 @@
Ref: https://en.wikipedia.org/wiki/Hong_Kong
Hong Kong was established as a colony of the British Empire after the Qing Empire ceded Hong Kong Island in 18411842. The colony expanded to the Kowloon Peninsula in 1860 and was further extended when the United Kingdom obtained a 99-year lease of the New Territories in 1898. Hong Kong was briefly occupied by Japan from 1941 to 1945 during World War II. The whole territory was transferred from the United Kingdom to China in 1997. Hong Kong maintains separate governing and economic systems from that of mainland China under the principle of "one country, two systems".[f]
Originally a sparsely populated area of farming and fishing villages,[18][19] the territory is now one of the world's most significant financial centres and commercial ports. Hong Kong is the world's fourth-ranked global financial centre, ninth-largest exporter, and eighth-largest importer. Its currency, the Hong Kong dollar, is the eighth most traded currency in the world. Home to the second-highest number of billionaires of any city in the world, Hong Kong has the largest concentration of ultra high-net-worth individuals. Although the city has one of the highest per capita incomes in the world, severe income inequality exists among the population. Despite having the largest number of skyscrapers of any city in the world, housing in Hong Kong has been well-documented to experience a chronic persistent shortage.
Hong Kong is a highly developed territory and has a Human Development Index (HDI) of 0.952, ranking fourth in the world. The city has the second highest life expectancy in the world, and a public transport rate exceeding 90%.
around 261 words

View File

@@ -0,0 +1,4 @@
Jwx: zllhk://wf.oacahwvas.gjy/oaca/Zgfy_Cgfy
sjgmfv 261 ogjvk

View File

@@ -0,0 +1,7 @@
git status .
@pause
git add .
git commit -m"update banson_hker,"
start git push

View File

@@ -0,0 +1,9 @@
..86.2.1.
3.157.8..
.6.....29
5..8.1.36
.3..6..5.
68.9.5..1
95.....4.
..4.965.3
.1.2.46..

View File

@@ -0,0 +1,9 @@
..8..15..
.4.37..1.
5.19..2.4
7...9.18.
.2.1.6.5.
.15.8...3
9.4..23.8
.8..43.2.
..68..7..

View File

@@ -0,0 +1,9 @@
398421576
642375819
571968234
763594182
829136457
415287693
954712368
187643925
236859741

View File

@@ -0,0 +1,9 @@
.3.8...9.
...2...13
..27.645.
.63......
7.......9
......86.
.945.86..
17...4...
.5...2.7.

View File

@@ -0,0 +1,9 @@
437851296
685249713
912736458
863927145
741685329
529413867
294578631
176394582
356182974

View File

@@ -0,0 +1,9 @@
1.7....95
...58...7
598.1...6
...6...21
2.31.76.9
81...5...
3...2.964
4...73...
98....3.2

View File

@@ -0,0 +1,9 @@
127364895
634589217
598712436
749638521
253147689
816295743
375821964
462973158
981456372

View File

@@ -0,0 +1,9 @@
.8.1.7.9.
...3.4...
3.9...6.1
..87.91..
1.......7
..48.62..
4.5...8.2
...9.2...
.2.4.1.3.

View File

@@ -0,0 +1,9 @@
582167394
617394528
349528671
258739146
163245987
974816253
495673812
731982465
826451739

View File

@@ -0,0 +1,9 @@
52...17..
3..78...5
.....91..
..2.6...4
.1.....9.
7...2.6..
..93.....
8...94..3
..35...67

View File

@@ -0,0 +1,9 @@
526431789
391786425
478259136
932165874
615847392
784923651
169372548
857694213
243518967

View File

@@ -0,0 +1,9 @@
.691.5..2
..2473...
.8.6.....
..5...719
.........
416...5..
.....8.9.
...7412..
2..9.637.

View File

@@ -0,0 +1,9 @@
769185432
152473968
384629157
825364719
937512846
416897523
571238694
693741285
248956371

View File

@@ -0,0 +1,9 @@
..21.6...
.4....15.
75...32..
2.63...9.
....8....
.1...23.7
..38...12
65.....4.
...6.97..

View File

@@ -0,0 +1,9 @@
832156974
649728153
751493268
286374591
397581426
514962387
973845612
165237849
428619735

View File

@@ -0,0 +1,9 @@
57.....21
..98..7..
2..9.7...
9...3.17.
....1....
.61.9...4
...5.4..6
..7..32..
84.....17

View File

@@ -0,0 +1,9 @@
578346921
439821765
216957438
984635172
725418693
361792854
192574386
657183249
843269517

View File

@@ -0,0 +1,9 @@
.951.387.
.........
37.....65
..97.86..
.6..5..2.
..49.65..
12.....49
.........
.538.721.

View File

@@ -0,0 +1,9 @@
495163872
681572493
372489165
519728634
867354921
234916587
128635749
746291358
953847216

View File

@@ -0,0 +1,9 @@
.9.1.7.8.
...6.2...
4.3...6.1
..23.85..
3.......9
..72.14..
7.5...2.4
...7.4...
.1.8.5.9.

View File

@@ -0,0 +1,9 @@
596147382
871632945
423589671
142398567
358476129
967251438
785963214
239714856
614825793

View File

@@ -0,0 +1,9 @@
798642315
321579864
465318729
547821936
139467258
682935471
956783142
274196583
813254697

View File

@@ -0,0 +1,9 @@
..3..15..
.4.39..8.
6.15..4.3
8...3.96.
.7.1.2.5.
.64.5...7
4.8..32.9
.3..18.4.
..29..6..

View File

@@ -0,0 +1,9 @@
.8.2....4
...6...27
23.8.....
.5.12.9.8
.........
1.3.48.7.
.....2.89
46...5...
7....3.6.

View File

@@ -0,0 +1,9 @@
986271354
541639827
237854196
654127938
872396541
193548672
315462789
469785213
728913465

View File

@@ -0,0 +1,9 @@
.4.8.5.6.
..27.41..
5.......2
..3.7.4..
9.......6
..7.5.3..
3.......4
..86.15..
.9.2.7.3.

View File

@@ -0,0 +1,9 @@
741825963
632794185
589163742
263978451
954312876
817456329
376589214
428631597
195247638

View File

@@ -0,0 +1,9 @@
8...1.29.
.9.86.1..
.....4...
.52...3.4
6.......9
4.1...85.
...4.....
..8.27.3.
.39.8...2

View File

@@ -0,0 +1,9 @@
864715293
395862147
217394568
952678314
683541729
471239856
726453981
148927635
539186472

View File

@@ -0,0 +1,9 @@
..21...69
6..5.....
.8.......
..9.4..5.
.576.928.
.6..1.3..
.......4.
.....2..7
83...71..

View File

@@ -0,0 +1,9 @@
572183469
693574812
184926573
319248756
457639281
268715394
725361948
941852637
836497125

View File

@@ -0,0 +1,9 @@
.6...2...
4..16.35.
8.1....9.
.92.4....
...3.7...
....8.62.
.4....7.3
.73.95..2
...6...4.

View File

@@ -0,0 +1,9 @@
369852471
427169358
851734296
192546837
586327914
734981625
945218763
673495182
218673549

View File

@@ -0,0 +1,9 @@
.....7..4
86..4.1..
...5.6..8
...38.5..
7.8...9.3
..2.59...
3..1.2...
..9.3..71
1..9.....

View File

@@ -0,0 +1,9 @@
513897264
867243195
924516738
691384527
758621943
432759816
375162489
289435671
146978352

View File

@@ -0,0 +1,9 @@
.....43.2
52.81...9
.9.......
6.1..29..
2.......6
..76..4.5
.......6.
3...46.78
1.87..7..

View File

@@ -0,0 +1,9 @@
716594382
523817649
894263751
681452937
245379816
937681425
479128563
352946178
168735294

View File

@@ -0,0 +1,9 @@
..7...6..
..93.67..
4...9...1
.769.154.
.........
.384.216.
7...8...6
..12.73..
..5...2..

View File

@@ -0,0 +1,9 @@
357814692
189326754
462795831
276931548
514678923
938452167
723589416
691247385
845163279

View File

@@ -0,0 +1,9 @@
.1..4.2.9
...8.9.73
.........
.29..4.1.
...1.5...
.8.7..43.
.........
34.6.8...
1.6.7..85

View File

@@ -0,0 +1,9 @@
813547269
452869173
967231854
729384516
634125798
581796432
278953641
345618927
196472385

View File

@@ -0,0 +1,9 @@
..8.14...
..39..1..
...5...86
..23..4.9
.5.....3.
6.9..85..
71...5...
..4..36..
...82.7..

View File

@@ -0,0 +1,9 @@
928614357
563987142
147532986
872351469
451769238
639248571
716495823
284173695
395826714

View File

@@ -0,0 +1,9 @@
293481576
547396182
681527493
825734961
379162854
164859327
458673219
936218745
712945638

View File

@@ -0,0 +1,9 @@
5.6...2..
.41.326..
.8.1.6.9.
13.6...4.
...815...
.2...3.56
.5.2.8.1.
..274.56.
..7...8.9

View File

@@ -0,0 +1,9 @@
7.5...8..
.46.781..
.3.4.9.5.
4.93...1.
...791...
.5...4.78
.7.9.2.8.
..285.74.
..9...3.2

View File

@@ -0,0 +1,9 @@
725613894
946578123
831429657
497385216
268791435
153264978
674932581
312856749
589147362

View File

@@ -0,0 +1,9 @@
576984231
941532687
283176495
135627948
694815372
728493156
359268714
812749563
467351829

View File

@@ -0,0 +1,9 @@
98.2...76
34.5.69..
..6..7..8
6.....48.
8..4.5..1
.73.....9
2..3..7..
..98.4.25
15...9.63

View File

@@ -0,0 +1,9 @@
981243576
347586912
526197348
615932487
892475631
473618259
268351794
739864125
154729863

View File

@@ -0,0 +1,9 @@
.57...9..
...18...7
1....2..6
..43.7.6.
.7..5..4.
.2.9.47..
8..2....4
6...15...
..9...21.

View File

@@ -0,0 +1,9 @@
257436981
463189527
198572436
584327169
976851342
321964758
815293674
642715893
739648215

View File

@@ -0,0 +1,9 @@
..3...1..
.5.2.8.7.
46.....25
..67.98..
8.......3
..54.12..
63.....17
.1.3.2.9.
..4...5..

View File

@@ -0,0 +1,9 @@
723954186
159268374
468173925
246739851
891526743
375481269
632895417
517342698
984617532

View File

@@ -0,0 +1,9 @@
.7...4.6.
1.46.2..7
2.5..39.8
9...48...
.48...31.
...12...9
5.14..8.6
8..2.91.4
.9.5...2.

View File

@@ -0,0 +1,9 @@
379854261
184692537
265713948
912348675
648975312
753126489
521437896
837269154
496581723

View File

@@ -0,0 +1,9 @@
..8..27..
.4.63..2.
7.68..1.4
6...8.91.
.1.7.6.8.
.97.4...3
1.5..43.2
.6..71.5.
..95..6..

View File

@@ -0,0 +1,9 @@
538412796
941637528
726859134
654283917
213796438
897145263
185964372
462371859
379528641

View File

@@ -0,0 +1,9 @@
.4.2.7.8.
9.......7
..34.82..
.5.836.9.
.1.....5.
.8.145.6.
..69.18..
8.......5
.7.5.2.3.

View File

@@ -0,0 +1,9 @@
145297683
928613549
763458219
257836491
614729358
389145762
536971824
892364175
471582936

Binary file not shown.

View File

@@ -0,0 +1,712 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//gteet the user
void greetintmessage(void);
//state the rules of playing the game
void rules(void);
//ask the user to select level
int levelchoosing(void);
//verify the correctness of input(length and range)
int verifyinput(void);
//Put content of cell filled with 0 to be a space
void initboard(void);
//print out the game board
void printboard(void);
//fill in some numbers as tips for user by open a sudoku file
int generatecontent(int);
//verify the correctness of option choenn(length and range)
int verifyoption(void);
//accept input from user and modify the array accorgingly
//also it checks wether the number is allowed to place at the cell or not
void acceptinput(void);
//enter row and check allowance
int enterrow(void);
//enter column and check allowance
int entercolumn(void);
//give hints to user when requested
void givehint(int);
//delete inputed number before
void deletenumber(int);
//check whether the user has finished the game
//by testing wether all the blankets are filled with number
//return '1' when all the cell is filled
//'o' when not yet finished
int checkgameend(void);
//check if the numbers in each row are unique and digits 1-9 are present
//after the user had finished the game
int checkrow(void);
//compare the elements in the same row to check uniqueness
//used inside int checkrow
int comparerow(int,int a);
//check if the numbers in each column are unique and digits 1-9 are present
//after the user had finished the game
int checkcolumn(void);
//compare the elements in the same column to check uniqueness
//used inside int checkcolumn
int comparecolumn(int,int a);
//print out the correct solution if the user'solution is not correct
void printsolution(int);
//congratulation message to the user if solution is correct
void congratulation(void);
//ask wether the user want to play another game
int playothergame(void);
//array used to store value of the game
int gameboard[9][9];
//The following is the main part of this program
main()
{
int level,option;//variable for receive levelchoosing
int randnum;//variable for receive random number from generatecontent
int crow,ccol;//variables for receive results from checkrow and checkcolumn
greetintmessage();
rules();
do{
level = levelchoosing();
initboard();
printf("=================================================================\n\n");
randnum = generatecontent(level);
do{
printboard();
printf("1.Enter number\n2.Give hints to current board\n3.Delete input before\n4.Generate new board\n5.Solution to current board\n");
printf("Your choice: ");
option = verifyoption();
if(option == '1')
{
printf("\nPlease choose the grid you want and input number.");
acceptinput();
system("CLS");
}
else if(option == '2')
{
givehint(randnum);
}
else if(option == '3')
{
printf("\nPlease choose the grid you want to delete:");
deletenumber(randnum);
}
else if(option == '4')
{
randnum = generatecontent(level);
system("CLS");
}
else
{
printf("\nCorrect solution is:\n");
printsolution(randnum);
}
}while(checkgameend() != 1);
if(option != '5'){
//after the user have completed the sudoku
printf("Great!You have completed the sudoku!\n");
printf("Let's check the answers now........\n\n");
//check solution
printboard();
crow = checkrow();
ccol = checkcolumn();
if(crow == 1 && ccol == 1)
{
congratulation();
}
else
{
printf("\nSorry,your solution is not correct.\n");
printf("The correct solution should be: \n");
printsolution(randnum);
}
}
}while(playothergame() == 1);
}
/*The following is the detail part of all funtions*/
/*gteet the user*/
void greetintmessage()
{
printf("\n+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n");
printf("%18cWelcome to play S-U-D-O-K-U game!\n",' ');
printf("+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n");
printf("\n");
}
/*state the rules of playing the game*/
void rules()
{
printf("%32cRules :\n",' ');
printf("\n%5cFill in all the cells so that every column, row and 3 x 3\n",' ');
printf("%5cboxes contains each of the digits 1 to 9 without repetition.\n",' ');
}
/*ask the user to select level*/
int levelchoosing()
{
char input[10];
printf("\n=================================================================\n");
printf("Please choose the level you want( 1-easy 2-medium 3-hard ) : ");
do{
scanf("%s",input);
if ((strlen(input) != 1) || !( (input[0]<'4') && (input[0]>'0') ))
{
printf("Input out of range!Input again please: ");
}
} while ((strlen(input) != 1) || !( (input[0]<'4') && (input[0]>'0') ));
printf("You have choose level %d\n",input[0]-48);
printf("Game start!\nChoose the following options please.\n");
return input[0];
}
/*verify the correctness of input(length and range)*/
int verifyinput()
{
char input[10];
do{
scanf("%s",input);
if ((strlen(input) != 1) || !( (input[0]<'2') && (input[0]>='0') ))
{
printf("Input out of range!Input again please: ");
}
} while ((strlen(input) != 1) || !( (input[0]<'2') && (input[0]>='0') ));
return input[0];
}
/*Put content of cell filled with 0 to be a space*/
void initboard()
{
int i,j;
for(i = 0;i < 9;i++){
for(j = 0;j < 9;j++){
gameboard[i][j] = ' ';
}//for i
}//for j
}
/*print out the game board */
void printboard()
{
char space = ' ';
char separator[] = "+- - - -+- - - -+- - - -+";
char row = 'a';
int i, j;
printf("%20c 1 2 3 4 5 6 7 8 9\n",space);
for (i=0;i<9;i++)
{
if(i%3 ==0)
{
printf("%20c%s\n",space,separator);
}
printf("%18c%c | %c %c %c | %c %c %c | %c %c %c |\n",space,row+i,gameboard[i][0],gameboard[i][1],gameboard[i][2],gameboard[i][3],gameboard[i][4],gameboard[i][5],gameboard[i][6],gameboard[i][7],gameboard[i][8]);
}
printf("%20c%s\n",space,separator);
}
/*fill in some numbers by open a sudoku file*/
int generatecontent(level)
{
int i,j,randnum;
char readchar,filename[20],string[10] = ".txt";
FILE *fp;
srand(time(NULL));
//randomly genereta a game for users according to their request level
if(level == '1')
{
randnum = (rand() %10) + 1;
sprintf(filename,"%d%s",randnum,string);//group number and string together
}
else if(level == '2')
{
randnum = (rand() %10) + 11;
sprintf(filename,"%d%s",randnum,string);
}
else if(level == '3')
{
randnum = (rand() %10) + 21;
sprintf(filename,"%d%s",randnum,string);
}
//open file
fp=fopen(filename,"r");
if(fp==NULL)
{
printf("cannot open the file!\n");//when failed to open file
exit(1);
}
//read character from the file
readchar = fgetc(fp);
while(readchar != EOF) {
for(i=0;i<9;i++)
{
for(j=0;j<=9;j++)
{
gameboard[i][j] = readchar;
readchar = fgetc(fp);
}//for i
}//for j
}//for while loop
fclose(fp);
return randnum;
}
/*verify the correctness of option chosen(length and range)*/
int verifyoption(void)
{
char option[10];
do{
scanf("%s",option);
if ((strlen(option) != 1) || !( (option[0]<'6') && (option[0]>'0') ))
{
printf("Input out of range!Input again please: ");
}
}while((strlen(option) != 1) || !( (option[0]<'6') && (option[0]>'0') ));
return option[0];
}
//accept input from user and modify the array accorgingly
//accept input from user and modify the array accorgingly
//it checks wether the number is allowed to place at the cell or not*/
void acceptinput()
{
int i , j,row, col, number;
char input[20];
int count1 = 0,count2 = 0;
int startingrow,startingcol;
//repeatly ask to do input if the cell being chosen is occupied
do{
//ask to enter column
col = entercolumn() - 49;
//ask to enter row
row = enterrow() - 97;
//check wether the cell chosen is already filled or not
//if yes,print warning message
//if not,fill the cell with number assigned by user
if (gameboard[row][col] !='.')
{
printf("The cell is already occupied!\n");
printf("Input again please.");
}
}while(gameboard[row][col] !='.');
//ask to enter number
printf("Which number(1-9)do you want to type in? ");
do {
scanf("%s",input);
if ((strlen(input) != 1) || !( (input[0]<='9') && (input[0]>'0') ))
{
printf("Input out of range! Input again please: ");
}
} while ((strlen(input) != 1) || !( (input[0]<='9') && (input[0]>'0') ));
number = input[0];
//checks wether the number is allowed to place at the cell or not
//check row and cloumn
//by testing wether the same number is presented
for(i = 0;i < 9;i++)
{
if(gameboard[row][i] == number)
{
count1++;
}
if(gameboard[i][col] == number)
{
count1++;
}
}
//check 3x3 boxes
//check by dividing the game board into 9 small boxes
//after detecting which small box the chosen grid lying on
//it test wether same number is presented in other grids within the same box
if(row < 3)
{
startingrow = 0;
}
else if((row > 2) && (row < 6))
{
startingrow = 3;
}
else if((row > 5) && (row < 9))
{
startingrow = 6;
}
if(col < 3)
{
startingcol = 0;
}
else if((col > 2) && (col < 6))
{
startingcol = 3;
}
else if((col > 5) && (col < 9))
{
startingcol = 6;
}
for(i = 0;i < 3;i++)
{
for(j = 0;j < 3;j++)
{
if(gameboard[startingrow+i][startingcol+j] == number)
{
count2++;
}
}
}
//assign value to the cell
if((count1 == 0) && (count2 == 0))
{
gameboard[row][col] = number;
}
else
{
printf("=================================================================\n");
printf("Sorry,input number is repeated either in row,column or 3x3 box\n");
printf("Do you really want to input(1-yes 0-no)? ");
input[0] = verifyinput();
if(input[0] == '1' )
{
gameboard[row][col] = number;
}
}
//restore value of two counter
count1 = 0;
count2 = 0;
}
//enter row and check allowance
int enterrow(void)
{
char input[10];
printf("Which row do you want to choose(e.g.a)? ");
do {
scanf("%s",input);
if ((strlen(input) != 1) || !( (input[0]<'j') && (input[0]>='a') ))
{
printf("Input out of range! Input again please: ");
}
} while ((strlen(input) != 1) || !( (input[0]<'j') && (input[0]>='a') ));
return input[0];
}
//enter column and check allowance
int entercolumn(void)
{
char input[10];
printf("\nWhich column do you want to choose(e.g.1)? ");
do {
scanf("%s",input);
if ((strlen(input) != 1) || !( (input[0]<='9') && (input[0]>'0') ))
{
printf("Input out of range! Input again please: ");
}
} while ((strlen(input) != 1) || !( (input[0]<='9') && (input[0]>'0') ));
return input[0];
}
//give hints to user when requested
void givehint(randnum)
{
int i,j,row,col;
char space = ' ';
char readchar,filename[20],string[10] = "s.txt";
FILE *fp;
//ask to enter column
col = entercolumn() - 49;
//ask to enter row
row = enterrow() - 97;
sprintf(filename,"%d%s",randnum,string);
fp=fopen(filename,"r");
if(fp==NULL)
{
printf("cannot open the file!\n");
exit(1);
}
readchar = fgetc(fp);
while(readchar != EOF) {
for(i=0;i<9;i++)
{
for(j=0;j<=9;j++)
{
if(i ==row && j == col)
{
if(gameboard[row][col] == '.')
{
gameboard[i][j] = readchar;
printf("=================================================================\n");
}
else
{
printf("=================================================================\n");
printf("%23c####################\n",space);
printf("%23cNumber is presented!\n",space);
printf("%23c####################\n",space);
}
}
readchar = fgetc(fp);
}//for i
}//for j
}//for while loop
fclose(fp);
}
//delete inputed number before
void deletenumber(randnum)
{
int i,j,row,col;
char space = ' ';
char readchar,filename[20],string[10] = ".txt";
FILE *fp;
//ask to enter column
col = entercolumn() - 49;
//ask to enter row
row = enterrow() - 97;
sprintf(filename,"%d%s",randnum,string);
fp=fopen(filename,"r");
if(fp==NULL)
{
printf("cannot open the file!\n");
exit(1);
}
readchar = fgetc(fp);
while(readchar != EOF) {
for(i=0;i<9;i++)
{
for(j=0;j<=9;j++)
{
if(i ==row && j == col)
{
if(readchar == '.' && gameboard[row][col] != '.')
{
gameboard[row][col] = '.';
printf("=================================================================\n");
}
else if(readchar == '.' && gameboard[row][col] == '.')
{
printf("=================================================================\n");
printf("%21c#######################\n",space);
printf("%21cNothing can be deleted!\n",space);
printf("%21c#######################\n",space);
}
else
{
printf("=================================================================\n");
printf("%8c########################################################\n",space);
printf("%8cThe number can't be cancelled.It is provided originally!\n");
printf("%8c########################################################\n",space);
}
}
readchar = fgetc(fp);
}//for i
}//for j
}//for while loop
fclose(fp);
}
/*check whether the user has finished the game
by testing wether all the blankets are filled
with number*/
//return '1' when all the cell is filled
//'o' when not yet finished
int checkgameend()
{
int i,j;
int counter = 0;
for(i = 0;i < 9;i++){
for(j = 0;j < 9;j++){
if(gameboard[i][j] != '.'){
counter ++;
}
}//for i
}//for j
if(counter == 81)
{
return 1;
}
else
{
return 0;
}
}
//check if the numbers in each row are unique and digits 1-9 are present
int checkrow(void)
{
int i,j;
int sum,counter1 = 0,counter2 = 0,counter3 = 0;
for(i = 0;i < 9;i++)
{
sum = (gameboard[i][0]+gameboard[i][1]+gameboard[i][2]+gameboard[i][3]+gameboard[i][4]+gameboard[i][5]+gameboard[i][6]+gameboard[i][7]+gameboard[i][8])-48*9;
if(sum == 45)
{
counter1 ++;
}
}
//check uniqueness
for(i = 0;i < 9;i++){
for(j = 1;j < 9;j++){
counter3 = comparerow(i,j);
counter2 += counter3;
counter3 = 0;
}//for j
}//for i
if((counter1 == 9) && (counter2 == 324))//The total combination in comparison is 324(36x9)
{
return 1;
}
else
{
return 0;
}
}
//compare the elements in the same row to check uniqueness
//used inside int checkrow
int comparerow(i,a)
{
int j,counter = 0;
for(j = a;j < 9;j++)
{
if(gameboard[i][a-1] != gameboard[i][j])
{
counter ++;
}
else
{
printf("More than one %c are found in row %d!\n",gameboard[i][a-1],i+1);
}
}
return counter;
}
//check if the numbers in each column are unique and digits 1-9 are present
int checkcolumn(void)
{
int i,j;
int sum,counter1 = 0,counter2 = 0,counter3 = 0;
for(i = 0;i < 9;i++)
{
sum = (gameboard[0][i]+gameboard[1][i]+gameboard[2][i]+gameboard[3][i]+gameboard[4][i]+gameboard[5][i]+gameboard[6][i]+gameboard[7][i]+gameboard[8][i])-48*9;
if(sum == 45)
{
counter1 ++;
}
}
//check uniqueness
for(i = 0;i < 9;i++){
for(j = 1;j < 9;j++){
counter3 = comparecolumn(i,j);
counter2 += counter3;
counter3 = 0;
}//for j
}//for i
if((counter1 == 9) && (counter2 == 324))//The total combination in comparison is 324(36x9)
{
return 1;
}
else
{
return 0;
}
}
//compare the elements in the same column to check uniqueness
//used inside int checkcolumn
int comparecolumn(i,a)
{
int j,counter = 0;
for(j = a;j < 9;j++)
{
if(gameboard[a-1][i] != gameboard[j][i])
{
counter ++;
}
else
{
printf("More than one %c are found in column %d!\n",gameboard[a-1][i],i+1);
}
}
return counter;
}
/*print out the correct solution if the user'solution is not correct*/
void printsolution(randnum)
{
int i,j;
char readchar,filename[20],string[10] = "s.txt";
FILE *fp;
sprintf(filename,"%d%s",randnum,string);
fp=fopen(filename,"r");
if(fp==NULL)
{
printf("cannot open the file!\n");
exit(1);
}
readchar = fgetc(fp);
while(readchar != EOF) {
for(i=0;i<9;i++)
{
for(j=0;j<=9;j++)
{
gameboard[i][j] = readchar;
readchar = fgetc(fp);
}//for i
}//for j
}//for while loop
fclose(fp);
printboard();
}
/*congratulation message to the user if solution is correct*/
void congratulation()
{
char space = ' ';
printf("%8c+++++++++++++++++++++++++++++++++++++++++++++++++++\n",space);
printf("%8cCONGRATULATION!!You have done the sudoku correctly!\n",space);
printf("%8c+++++++++++++++++++++++++++++++++++++++++++++++++++\n",space);
}
/*ask wether the user want to play another game*/
int playothergame()
{
char input[10];
printf("=================================================================\n");
printf("Do you want to play another game(1-yes 0-no)? ");
input[0] = verifyinput();
if(input[0] == '1')
{
return 1;
}
else if(input[0] == '0')
{
return 0;
}
}

5
banson_hker/meta.md Normal file
View File

@@ -0,0 +1,5 @@
---
tags: [SBA, python]
---
# banson_hker

22
banson_hker/package.json Normal file
View File

@@ -0,0 +1,22 @@
{
"name": "daniel_jo_assignment_student",
"version": "1.0.0",
"description": "",
"main": "index.js",
"directories": {
"doc": "docs"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"gitUpdate": "git add . && git commit -m\"update banson_hker,\" && git push"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@fortawesome/free-solid-svg-icons": "^6.2.1",
"@fortawesome/react-fontawesome": "^0.2.0",
"bootstrap": "^5.2.3",
"react-bootstrap": "^2.6.0"
}
}

Binary file not shown.

View File

@@ -0,0 +1,19 @@
1.如果淨係放嗰個txt file佢唔識encrypt 後output 個encrypt後嘅document .即係我如果delete咗wiki_e.txt佢唔識自己再output。需要人手開一個新txt document
詳情可以睇 Problem1.mp4
2. 1.如果篇文有兩個相同(無論係相同或者多過)字數嘅Alphabet 出現 呢個時候個program就會encrypt錯。例如將「people 」呢隻字打到200字 「P」同「E」嘅數量係一樣
所以encrypt完之後變出嚟嘅亂碼 再decrypt唔會變返「People」所以要搵解決方法做到點樣先可以知道decrypt gen出嚟嘅key(k)係準確。
詳情可以睇Problem2 (Alphabet E is the same with P).mp4 Problem 2( Alphabet P is more than E and the guess of Key is error).mp4
阿sir指定話要將呢個problem寫入report睇下點樣solve同埋點解會出現呢個情況. Thanks very much
3.個Guildline要求無論係Uppercase定LowerCase都要直接將佢變成Uppercase但係只有文字轉Uppercase標點符號同埋spaces唔會改變。
即係gen出嚟嘅亂碼會係全大階。 咁係唔係即係delete咗Lowercase段code就得
4.要加多個flow chart喺report入面係整合曬成個program.
Thanks a lot for helping me.!!!!!!

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1 @@
aaaaa

Some files were not shown because too many files have changed in this diff Show More