-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
120 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
name points error time(us) time per city(us) distance optimal_distance | ||
pr2392,2392,8.560000,15416018.000000,6444.819824,410374.000000,378032.000000 | ||
pcb442,442,8.330000,101219.000000,229.000000,55006.988281,50778.000000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
name points error time(us) time per city(us) distance optimal_distance | ||
pr2392 2392 8.560000 15416018.000000 6444.819824 410374.000000 378032.000000 | ||
pcb442 442 8.330000 101219.000000 229.000000 55006.988281 50778.000000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import math | ||
|
||
def getDistance(a, b): | ||
x_sqr = (a[0] - b[0]) * (a[0] - b[0]) | ||
y_sqr = (a[1] - b[1]) * (a[1] - b[1]) | ||
return math.sqrt(x_sqr + y_sqr) | ||
|
||
def getCost(c, a, b): | ||
return getDistance(c, a) + getDistance(c, b) - getDistance(a, b) | ||
|
||
if __name__ == "__main__": | ||
point = (800.000000, 600.000000) | ||
pointA = (900.000000, 600.000000) | ||
pointB = (850.000000, 520.000000) | ||
print(f"cost for ({pointA}, {point}, {pointB}):\n{getCost(point, pointA, pointB)}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/usr/bin/python3 | ||
|
||
import os | ||
import sys | ||
import time | ||
import subprocess | ||
|
||
COMMAND = "" | ||
|
||
def runCommand(cmd, args): | ||
process = subprocess.Popen( | ||
[cmd] + args, | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.STDOUT | ||
) | ||
|
||
# stdout, stderr = process.communicate() | ||
|
||
# # exit_code = p.wait() | ||
# exit_code = process.returncode | ||
|
||
# # print("Standard Output:\n", stdout.decode()) | ||
# # print("Error Output:\n", stderr.decode()) | ||
# # print("Exit code: ", exit_code) | ||
# time.sleep(1) | ||
# os.system('clear') | ||
|
||
for line in process.stdout: | ||
if line: | ||
print(str(line.strip(), 'utf-8')) | ||
time.sleep(1) | ||
os.system('clear') | ||
|
||
exit_code = 0 | ||
return exit_code | ||
|
||
def main(): | ||
|
||
if len(sys.argv) < 2: | ||
print(f"[Error]: Not command argument provided.\nExiting") | ||
sys.exit(1) | ||
|
||
command = sys.argv[1] | ||
|
||
command_args = sys.argv[2:] | ||
|
||
if command[0:2] == "./": | ||
command = os.path.abspath(command) | ||
|
||
print() | ||
print() | ||
while True: | ||
if runCommand(command, command_args) != 0: | ||
break; | ||
|
||
if __name__ == "__main__": | ||
main() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters