This file contains hidden or 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
| errorScanAndModify = (item, flag, data) => { | |
| let expectedFlags; | |
| switch(item){ | |
| case 'projects': | |
| expectedFlags = ['name', 'n', 'url', 'u', 'git', 'g', 'date', 'd']; | |
| break; | |
| case 'gitHub': | |
| case 'blog': | |
| case 'portfolio': |
This file contains hidden or 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
| argumentParser = arguments => { | |
| const acceptedUpdateItems = ['gitHub', 'blog', 'portfolio', 'story', 'projects', 'certifications']; | |
| let error; | |
| let output = argumentSplitter(arguments); | |
| let item = output.item; | |
| // initial check to ensure the update item is valid | |
| if(!~acceptedUpdateItems.indexOf(item)) return `invalid update item [\`${item}\`]\n Use \`/update help\` for a list of available update items.`; |
This file contains hidden or 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
| router.post('/update', (req, res) => { | |
| const respond = require('./tools/respond'); | |
| const update = require('./tools/update'); | |
| const body = req.body; | |
| const arguments = body.text; | |
| if(tools.verify.slash(body.token)){ | |
| if(~arguments.indexOf(' ')){ |
This file contains hidden or 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
| function conditionalRecursion(n) { | |
| if (n < 2) return n; | |
| return conditionalRecursion(n - 1) + conditionalRecursion(n - 2); | |
| } | |
| const tests = [ | |
| [1, 3, 5, 7], | |
| [0, 1, 1, 2], | |
| [2, 4, 6, 8], | |
| [0, 1, 2, 3], |
This file contains hidden or 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 works | |
| def printHelloWorld(): | |
| print('hello word') | |
| def returnPrintHelloWorld(): | |
| return print('hello world') # output: syntax error | |
| """ | |
| To answer the original question: Why do you use a return statement on the return 5 |
This file contains hidden or 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
| """ | |
| The goal here is to gather the user's first and last name using the input() command | |
| and then to print the user's initials | |
| We also want to make sure that those inputs are valid alpha characters because nobody | |
| except for an impostor robot would have a name with numbers in it! INPUT VALIDATION TIME | |
| To accomplish this we need to "sanitize" the input before it is passed along to the rest | |
| of the codebase |
This file contains hidden or 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
| # Write your own unit tests and testing environment | |
| def unit_test(function_to_test, test_input, expected_output): | |
| function_output = function_to_test(test_input) | |
| try: | |
| assert function_output == expected_output | |
| print(unit_test_response(True, test_input, function_output, expected_output)) | |
| except AssertionError: | |
| print(unit_test_response(False, test_input, function_output, expected_output)) | |
| def unit_test_response(correct, test_input, function_output, expected_output): |
This file contains hidden or 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
| # performs a single unit test | |
| # accepts a function to test, a test case input and its corresponding expected output | |
| def unit_test(function_to_test, test_input, expected_output): | |
| try: # try something (whatever is in the code block) | |
| function_output = function_to_test(test_input) | |
| except Exception as error: # if it DOES NOT work then catch the error using the except keyword | |
| # Exception is a general "catch-all" exception | |
| # catch the Exception and store the error message as a variable called error | |
| print("Error occurred with test input: [{0}] value: {1}\nError Message: {2}\nCorrect the error and try again.\n" |
This file contains hidden or 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
| def unit_test(function_to_test, test_input, expected_output): | |
| try: | |
| number_of_inputs = len(test_input) | |
| if type(test_input) == list: function_output = function_to_test(test_input) | |
| elif number_of_inputs == 1: function_output = function_to_test(test_input) | |
| elif number_of_inputs == 2: function_output = function_to_test(test_input[0], test_input[1]) | |
| elif number_of_inputs == 3: function_output = function_to_test(test_input[0], test_input[1], test_input[2]) | |
| except Exception as error: | |
| print("Error occurred with test input: [{0}] value: {1}\nError Message: {2}\nCorrect the error and try again.\n" |
This file contains hidden or 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
| """ | |
| Problem Statement: | |
| Calculate the hourglass sum for every hourglass in the 2D array, then print the maximum hourglass sum. | |
| """ | |
| """ | |
| Approach: | |
| A B C |