update max015,
This commit is contained in:
BIN
T08/deliver/2023-11-09_14-47.png
(Stored with Git LFS)
Normal file
BIN
T08/deliver/2023-11-09_14-47.png
(Stored with Git LFS)
Normal file
Binary file not shown.
1263
T08/deliver/CDS1001T8Report.ipynb
Normal file
1263
T08/deliver/CDS1001T8Report.ipynb
Normal file
File diff suppressed because it is too large
Load Diff
76
T08/deliver/Q2_4.drawio
Normal file
76
T08/deliver/Q2_4.drawio
Normal file
@@ -0,0 +1,76 @@
|
||||
<mxfile host="65bd71144e">
|
||||
<diagram id="gbafj2K8NTiN-hHC4odU" name="Page-1">
|
||||
<mxGraphModel dx="812" dy="945" 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="11" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="2" target="3">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="2" value="Iterate every character" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="200" y="200" width="160" height="60" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="9" value="No" style="edgeStyle=none;html=1;" edge="1" parent="1" source="3" target="8">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="10" value="Yes" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="3" target="7">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<Array as="points">
|
||||
<mxPoint x="520" y="400"/>
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="3" value="Found match<br>in the dictionary ?" style="rhombus;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="200" y="320" width="160" height="160" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="15" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="7" target="12">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<Array as="points">
|
||||
<mxPoint x="520" y="610"/>
|
||||
<mxPoint x="280" y="610"/>
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="7" value="increase character count" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="440" y="520" width="160" height="60" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="14" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="8" target="12">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="8" value="initialize character count = 1" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="200" y="520" width="160" height="60" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="13" value="No" style="edgeStyle=none;html=1;" edge="1" parent="1" source="12">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="280" y="300" as="targetPoint"/>
|
||||
<Array as="points">
|
||||
<mxPoint x="120" y="720"/>
|
||||
<mxPoint x="120" y="300"/>
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="17" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="12" target="16">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="12" value="end of string ?" style="rhombus;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="200" y="640" width="160" height="160" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="22" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="16" target="19">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="16" value="Print output" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="200" y="850" width="160" height="60" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="20" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="18" target="2">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="18" value="Start" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="220" y="100" width="120" height="60" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="19" value="End" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="220" y="960" width="120" height="60" as="geometry"/>
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
BIN
T08/deliver/Q2_4.png
(Stored with Git LFS)
Normal file
BIN
T08/deliver/Q2_4.png
(Stored with Git LFS)
Normal file
Binary file not shown.
5
T08/deliver/input-7-1.txt
Normal file
5
T08/deliver/input-7-1.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
HK RD 2030.0 MMMM
|
||||
HK SF 2000.0 OOCL
|
||||
HK SF 2020.0 MMMM
|
||||
HK RD 2025.0 OOCL
|
||||
-1
|
5
T08/deliver/input-7-2.txt
Normal file
5
T08/deliver/input-7-2.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
HK RD 5030.0 MMMM
|
||||
HK SF 5000.0 OOCL
|
||||
HK SF 6020.0 MMMM
|
||||
HK RD 6025.0 OOCL
|
||||
-1
|
22
T08/deliver/lowest.py
Normal file
22
T08/deliver/lowest.py
Normal file
@@ -0,0 +1,22 @@
|
||||
files = ['./input-7-1.txt', './input-7-2.txt']
|
||||
|
||||
for f in files:
|
||||
with open(f,'r') as fi:
|
||||
lowest_rate = {}
|
||||
|
||||
lines = fi.readlines()
|
||||
for l in lines:
|
||||
if (l != '-1'):
|
||||
[origin_port, destination_port, shipping_rate, carrier_name] = l.strip().split(' ')
|
||||
shipping_rate = float(shipping_rate)
|
||||
|
||||
if (destination_port in lowest_rate.keys()):
|
||||
if shipping_rate < lowest_rate[destination_port]['shipping_rate'] :
|
||||
lowest_rate[destination_port] = {'origin_port': origin_port, 'destination_port': destination_port, 'shipping_rate': shipping_rate, 'carrier_name': carrier_name}
|
||||
else:
|
||||
lowest_rate[destination_port] = {'origin_port': origin_port, 'destination_port': destination_port, 'shipping_rate': shipping_rate, 'carrier_name': carrier_name}
|
||||
|
||||
print(f)
|
||||
for v in lowest_rate.values():
|
||||
print(f"The lowest shipping rate from {v['origin_port']}' to {v['destination_port']} is {v['shipping_rate']}.")
|
||||
print()
|
Reference in New Issue
Block a user