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
AWSTemplateFormatVersion: 2010-09-09 | |
Parameters: | |
EC2InstanceType: | |
Type: String | |
EC2AMI: | |
Type: 'AWS::EC2::Image::Id' | |
Default: 'ami-03d8261f577d71b6a' | |
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
def multi_imperative(n = 12): | |
if(n > 12): | |
return print('maximum number allowed is 12') | |
for i in range(1,n+1): | |
s = '' | |
for j in range(1,n+1): | |
s += '{0:4} '.format(i*j) | |
print(s) | |
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
if (Array.isArray(req.files.picture)) { | |
if (req.files.picture.length > 6) | |
return res.status(400).json({ | |
status: 400, | |
message: `You can't upload more than 6 images at once` | |
}); | |
for (let picture of req.files.picture) { | |
if (!picture.mimetype.includes('image/')) | |
return res.status(400).json({ |
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
// a function that takes two arrays and merge them | |
function merge(arr1, arr2){ | |
let i = 0 | |
let j = 0 | |
let results = [] | |
while (i < arr1.length && j < arr2.length) { | |
if(arr2[j] > arr1[i]) { | |
results.push(arr1[i]) | |
i++ |
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
function anagram (str1, str2) { | |
if (str1.length !== str2.length) return false | |
let frequencyCounter = {} | |
for (let val of str1) { | |
// increment occurence of val in frequencyCounter | |
frequencyCounter[val] = (frequencyCounter[val] || 0) + 1 | |
} | |
for (let val of str2) { | |
if(!frequencyCounter[val]) { | |
return false |
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
{"lastUpload":"2019-07-22T17:21:44.605Z","extensionVersion":"v3.4.1"} |
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
function isPalindrome(str) { | |
// convert string to lowercase | |
str = str.toLowerCase(); | |
// convert string to an array | |
let strArr = str.split(''); | |
// what it will be checked against to eliminitate non alphabetic characters | |
let AlphabetArr = 'abcdefghijklmnopqrstuvwxyz'.split(''); | |
// initialize an empty array | |
let newContainer = [] |
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
const fizzBuzz = (num = 20) => { | |
for(let i = 1; i <= num; i++) { | |
if(i % 15 === 0) console.log('FizzBuzz'); | |
else if(i % 3 === 0) console.log('Fizz'); | |
else if(i % 5 === 0) console.log('Buzz'); | |
else console.log(i) | |
} | |
} | |
fizzBuzz() |
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
// reversing a string with a decrementing forloop | |
function reverse(str) { | |
let st = ""; | |
for(let i = str.length - 1; i >= 0; i--) { | |
st += str[i] | |
} | |
return st | |
} | |
// through a recursion |
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
// with loop | |
function duplicate (arr, n) { | |
let arry = []; | |
for(let i = 0; i < n; i++) { | |
arry = [...arry, ...arr] | |
} | |
return arry | |
} |