diff options
-rw-r--r-- | .vscode/c_cpp_properties.json | 16 | ||||
-rw-r--r-- | .vscode/launch.json | 40 | ||||
-rw-r--r-- | .vscode/settings.json | 3 | ||||
-rw-r--r-- | .vscode/tasks.json | 23 | ||||
-rw-r--r-- | csci1913/Python/lab1_strap012.py (renamed from csci1913/lab1/lab1_strap012.py) | 0 | ||||
-rw-r--r-- | csci1913/Python/lab2_strap012.py (renamed from csci1913/lab1/lab2_strap012.py) | 45 |
6 files changed, 118 insertions, 9 deletions
diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..18e0c6e --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,16 @@ +{ + "configurations": [ + { + "name": "WSL", + "intelliSenseMode": "gcc-x64", + "compilerPath": "/usr/bin/g++", + "includePath": [ + "${workspaceFolder}/**" + ], + "defines": [], + "cStandard": "c11", + "cppStandard": "c++17" + } + ], + "version": 4 +}
\ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..42a2cbe --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,40 @@ +{
+ // Use IntelliSense to learn about possible attributes.
+ // Hover to view descriptions of existing attributes.
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": "Python",
+ "type": "python",
+ "request": "launch",
+ "program": "${file}",
+ "console": "integratedTerminal"
+ },
+ {
+ "type": "java",
+ "name": "Java",
+ "request": "launch",
+ "mainClass": ""
+ },
+ {
+ "name": "(gdb) Launch",
+ "type": "cppdbg",
+ "request": "launch",
+ "program": "${workspaceFolder}/debug",
+ "args": [],
+ "stopAtEntry": false,
+ "cwd": "${workspaceFolder}",
+ "environment": [],
+ "externalConsole": false,
+ "MIMode": "gdb",
+ "setupCommands": [
+ {
+ "description": "Enable pretty-printing for gdb",
+ "text": "-enable-pretty-printing",
+ "ignoreFailures": true
+ }
+ ]
+ },
+ ]
+}
\ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..615aafb --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.pythonPath": "/usr/bin/python3" +}
\ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..f029853 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,23 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "Build c++", + "type": "shell", + "command": "g++", + "args": [ + "-g", + "-Wall", + "${file}", + "-o", + "debug" + ], + "group": { + "kind": "build", + "isDefault": true + } + } + ] +}
\ No newline at end of file diff --git a/csci1913/lab1/lab1_strap012.py b/csci1913/Python/lab1_strap012.py index 396fda9..396fda9 100644 --- a/csci1913/lab1/lab1_strap012.py +++ b/csci1913/Python/lab1_strap012.py diff --git a/csci1913/lab1/lab2_strap012.py b/csci1913/Python/lab2_strap012.py index 34fbe6a..4e154f7 100644 --- a/csci1913/lab1/lab2_strap012.py +++ b/csci1913/Python/lab2_strap012.py @@ -1,20 +1,47 @@ class Zillion: def __init__(self,digits): self.digits = digits - if (1==1): - try: - int(digits) - except ValueError: - raise RuntimeError + self.List = [] + self.toList() + + def toList(self): + badBoolean=False #Kludge + if len(self.digits) == 0 : + raise RuntimeError #Cannot make a list of nothing + for n in range (0,len(self.digits)): + if self.digits[n] is not ',': + if self.digits[n] is not ' ': + try: + self.List+=[int(self.digits[n])] + badBoolean=True + except ValueError: #Non-comma character in string + raise RuntimeError + if badBoolean is False: #No numbers in string + raise RuntimeError + else: + return self.List + + def increment(self): - return int(self.digits)+1 + length = len(self.List) - 1 + newList = self.List + newList[len(self.List)-1] += 1 + if newList[length]>=10: #Loop to increment all 10s to 0s with carry + for n in range (0,length): + newList[length-n]=0 + newList[length-n-1]+=1 + def isZero(self): - for n in range (0,len(self.digits)): - if str(self.digits)[n] is not '0': + for p in range (0,len(self.List)-1): + if self.List[p] is not 0: return False return True + def toString(self): - return str(self.digits) + string='' + for q in range (0,len(self.List)): + string+=str(self.List[q]) #Make string by concatenation + return string |