From fd9e5533b96b3da0fc9834ed942074a9d96e167d Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 20 Jan 2025 00:44:13 -0500 Subject: fully refactored input processing and completed output formatting. file input and output is now supported --- test.py | 67 ----------------------------------------------------------------- 1 file changed, 67 deletions(-) delete mode 100644 test.py (limited to 'test.py') diff --git a/test.py b/test.py deleted file mode 100644 index 1127e35..0000000 --- a/test.py +++ /dev/null @@ -1,67 +0,0 @@ -def extractValues(color, numValues, isHex = False) : - print(color) - i = 0 - tempValue = '' - extractedValues = [] - - if isHex : - # search for hex values - hexCharacters = ['a', 'b', 'c', 'd', 'e', 'f'] - while i < len(color) : - if (color[i].isnumeric()) or (color[i] in hexCharacters) : - tempValue += color[i] - else : - tempValue = '' - if len(tempValue) == 6 : - extractedValues.append(tempValue) - tempValue = '' - if len(extractedValues) == numValues : - break - i = i + 1 - - if (len(extractedValues) != numValues) and (len(tempValue) == 6) : - extractedValues.append(tempValue) - - else : - # search for decimal values - while i < len(color) : - if color[i].isnumeric() or color[i] == '.' : - tempValue += color[i] - elif len(tempValue) > 0 : - extractedValues.append(tempValue) - tempValue = '' - if len(extractedValues) == numValues : - break - i = i + 1 - - if (len(extractedValues) != numValues) and (len(tempValue) > 0) : - extractedValues.append(tempValue) - - if len(extractedValues) != numValues : - print(f'Could not extract the desired number of values from input. Values requested: {numValues}, values extracted: {len(extractedValues)}, {extractedValues}') - return False - - print(extractedValues) - return - -def main() : - - # hexcolor1 = '123abc' - # hexcolor2 = 'zx123abc def654' - # hexcolor3 = 'test sentence with hex in it: 123456, 654321, abc123, aefacd' - - # extractValues(hexcolor1, 1, True) - # extractValues(hexcolor2, 1, True) - # extractValues(hexcolor2, 2, True) - # extractValues(hexcolor3, 4, True) - - color1 = 'cmy(123, ba12.4, 51 )' - color2 = 't3st 123 456' - color3 = '1.23 word 3,2 1.34' - - extractValues(color1, 3) - - - -if __name__ == '__main__' : - main() \ No newline at end of file -- cgit v1.3.1-4-g156e