Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
557 commits
Select commit Hold shift + click to select a range
424c4d1
cc30 commonCharacters
mixelpixel Aug 21, 2017
9221f5e
cc31 fizzBuzzTesting √
mixelpixel Aug 21, 2017
ab7fcb9
added "test suite"
mixelpixel Aug 21, 2017
d4aa2d5
idem
mixelpixel Aug 21, 2017
d90544b
idem
mixelpixel Aug 21, 2017
c896ea6
cc31 fizzBuzzTesting √
mixelpixel Aug 21, 2017
73e450f
cc31 fizzBuzzTesting √
mixelpixel Aug 21, 2017
38b3f31
assert and expect √
mixelpixel Aug 22, 2017
1951eff
why eslint no likey describe & it ?
mixelpixel Aug 22, 2017
5b4f19e
idem
mixelpixel Aug 22, 2017
03d2a68
Merge branch 'master' of https://github.com/LambdaSchool/CS1-Code-Cha…
mixelpixel Aug 22, 2017
1a3026a
cc32 longestRun
mixelpixel Aug 22, 2017
3da2be5
cc31 fizzBuzzTesting √
mixelpixel Aug 22, 2017
793f342
cc32 longestRun w.i.p.
mixelpixel Aug 22, 2017
df8e878
cc31 fizzbuzzTesting solution w/Jest
mixelpixel Aug 22, 2017
f9e6eab
cc32 longestRun - w.i.p.
mixelpixel Aug 23, 2017
d617a76
cc32 longestRun √
mixelpixel Aug 23, 2017
7fa7bda
Merge branch 'master' of https://github.com/LambdaSchool/CS1-Code-Cha…
mixelpixel Aug 23, 2017
008c863
cc33 breadthFirstSearch
mixelpixel Aug 23, 2017
5e5c85a
cc32 longestRun √
mixelpixel Aug 23, 2017
3c8f3d3
Merge branch 'master' of https://github.com/LambdaSchool/CS1-Code-Cha…
mixelpixel Aug 24, 2017
6f90fc6
cc34 vowelCount
mixelpixel Aug 24, 2017
14e6001
cc34 vowelCount √
mixelpixel Aug 24, 2017
502cfd6
cc34 vowelCount √
mixelpixel Aug 24, 2017
f3a72c6
cc34 vowelCount √
mixelpixel Aug 24, 2017
c10d0cf
cc33 breadthFirstSearch solution
mixelpixel Aug 24, 2017
9da482c
Merge branch 'master' of https://github.com/LambdaSchool/CS1-Code-Cha…
mixelpixel Aug 25, 2017
968c7df
cc35 meanMedianMode
mixelpixel Aug 25, 2017
41e8181
cc34 vowelCount √
mixelpixel Aug 25, 2017
2b98041
cc34 vowelCount √
mixelpixel Aug 25, 2017
61f3cfe
cc34 vowelCount √
mixelpixel Aug 25, 2017
bb50f3f
cc34 vowelCount solution
mixelpixel Aug 25, 2017
8cb299b
cc35 meanMedianMode
mixelpixel Aug 28, 2017
2103c25
cc36 sumOfDigits √
mixelpixel Aug 28, 2017
eace5cc
cc36 sumOfDigits √
mixelpixel Aug 28, 2017
d0e70d3
cc35 meanMedianMode √
mixelpixel Aug 28, 2017
11a253b
cc35 meanMedianMode - solution
mixelpixel Aug 28, 2017
c9c3682
cc35 meanMedianMode √
mixelpixel Aug 28, 2017
408f401
cc37 armstrongNumbers √
mixelpixel Aug 29, 2017
791ab72
cc37 armstrongNumbers √
mixelpixel Aug 29, 2017
0799f92
cc38 reverseNumber √
mixelpixel Aug 30, 2017
4b6fbf9
cc38 reverseNumber √
mixelpixel Aug 30, 2017
4252b62
cc38 reverseNumber √
mixelpixel Aug 30, 2017
740fc38
cc39 sortString √
mixelpixel Aug 31, 2017
b28cf52
cc40 commonElements √
mixelpixel Sep 1, 2017
8302d96
set up for linter
mixelpixel Sep 1, 2017
3d59798
cc40 commonElements √
mixelpixel Sep 1, 2017
d30a2ca
cc40 commonElements √
mixelpixel Sep 1, 2017
667f02f
cc39 sortString √
mixelpixel Sep 2, 2017
a55a4b8
cc41 reverseLinkedList
mixelpixel Sep 5, 2017
fb07571
cc41 reverseLinkedList √
mixelpixel Sep 5, 2017
6d3d54e
cc41 reverseLinkedList √
mixelpixel Sep 5, 2017
37d69ef
cc42 collatzSequence √
mixelpixel Sep 6, 2017
a6e85e3
name convention change
mixelpixel Sep 6, 2017
35a3baa
cc42 collatzSequence √
mixelpixel Sep 6, 2017
bdebd15
cc42 collatzSequence √
mixelpixel Sep 6, 2017
48286a5
cc43 routeBetweenNodes √
mixelpixel Sep 7, 2017
e369f07
cc43 routeBetweenNodes √
mixelpixel Sep 7, 2017
fa91b40
c44 sumAndProduct √
mixelpixel Sep 8, 2017
cd8b593
cc45 deepEquality
mixelpixel Sep 11, 2017
e1575b1
cc45 deepEquality
mixelpixel Sep 11, 2017
f6c2f71
cc45 deepEquality
mixelpixel Sep 11, 2017
5046326
cc44 sumAndProduct
mixelpixel Sep 11, 2017
7f6ff94
renaming folders
mixelpixel Sep 11, 2017
f62aab2
cc45 deepEquality
mixelpixel Sep 11, 2017
8967883
cc45 deepEquality
mixelpixel Sep 11, 2017
56c544c
cc45 deepEquality
mixelpixel Sep 11, 2017
d1dcf3d
cc46 telephoneWords
mixelpixel Sep 12, 2017
ec2d8e2
cc46 telephoneWords
mixelpixel Sep 12, 2017
e4455e4
cc47 isTwinPrime √
mixelpixel Sep 13, 2017
271c7d0
cc47 isTwinPrimes √
mixelpixel Sep 14, 2017
a619553
cc47 isTwinPrime
mixelpixel Sep 14, 2017
1d7d7cf
cc47 isTwinPrime √
mixelpixel Sep 14, 2017
7d2b3a1
cc48 cssAnimation √
mixelpixel Sep 14, 2017
4697098
cc48 CSS Animation
mixelpixel Sep 14, 2017
f299ca3
cc48 CSS Animation
mixelpixel Sep 14, 2017
780f19a
cc49 romanNumeralEncoder
mixelpixel Sep 15, 2017
0e1cec7
cc49
mixelpixel Sep 15, 2017
57b50f3
cc49
mixelpixel Sep 25, 2017
1a49091
cc50
mixelpixel Sep 25, 2017
300720a
cc50 solution
mixelpixel Sep 25, 2017
a158731
cc50
mixelpixel Sep 25, 2017
3fed4b9
cc51 combineTwoStrings
mixelpixel Sep 26, 2017
3857908
cc50
mixelpixel Sep 26, 2017
77c6f6e
cc51
mixelpixel Sep 26, 2017
0c797f9
cc51
mixelpixel Sep 26, 2017
2950b64
cc52
mixelpixel Sep 27, 2017
f0be0a8
cc52
mixelpixel Sep 27, 2017
031413b
cc52
mixelpixel Sep 27, 2017
669f556
cc52
mixelpixel Sep 27, 2017
0322fd6
cc53
mixelpixel Sep 28, 2017
501eafb
cc53
mixelpixel Sep 28, 2017
b9584e0
cc53
mixelpixel Sep 29, 2017
1e5a8f4
cc54
mixelpixel Sep 29, 2017
6bae967
cc54
mixelpixel Sep 29, 2017
879effa
linting & babel
mixelpixel Sep 29, 2017
3d62099
cc54
mixelpixel Sep 29, 2017
1e752d9
cc53
mixelpixel Sep 29, 2017
15baf9b
cc54
mixelpixel Sep 29, 2017
6f65d83
cc10
mixelpixel Sep 30, 2017
685cc08
cc06
mixelpixel Sep 30, 2017
894bec0
renaming
mixelpixel Sep 30, 2017
8e8bc73
cc01
mixelpixel Sep 30, 2017
d289bee
cc02
mixelpixel Sep 30, 2017
7138aa5
cc03
mixelpixel Sep 30, 2017
f6b81fa
cc04
mixelpixel Sep 30, 2017
58b22eb
cc05
mixelpixel Sep 30, 2017
9662e02
cc07
mixelpixel Sep 30, 2017
daf13a5
cc08
mixelpixel Sep 30, 2017
21d52b7
cc09
mixelpixel Sep 30, 2017
4b74bce
cc11
mixelpixel Sep 30, 2017
669810f
cc12
mixelpixel Sep 30, 2017
5054839
cc13
mixelpixel Sep 30, 2017
3f8ad91
cc14
mixelpixel Sep 30, 2017
658c60c
cc15
mixelpixel Sep 30, 2017
f08c3ce
cc16
mixelpixel Sep 30, 2017
751fa11
cc17
mixelpixel Sep 30, 2017
dfb00e1
cc18
mixelpixel Sep 30, 2017
56e882b
cc19
mixelpixel Sep 30, 2017
5ddaf3a
cc20
mixelpixel Sep 30, 2017
090444d
cc21
mixelpixel Sep 30, 2017
f1940d9
cc22
mixelpixel Sep 30, 2017
ec0dacb
cc23
mixelpixel Sep 30, 2017
88c236e
cc24
mixelpixel Sep 30, 2017
ae3fd0f
cc25
mixelpixel Sep 30, 2017
bff33e8
cc26
mixelpixel Sep 30, 2017
ee02a54
cc27
mixelpixel Sep 30, 2017
9da5494
cc28
mixelpixel Sep 30, 2017
3ae2455
cc29
mixelpixel Sep 30, 2017
107e65a
cc30
mixelpixel Sep 30, 2017
d8e84e6
cc31
mixelpixel Sep 30, 2017
f272d1f
cc32
mixelpixel Sep 30, 2017
fb9e2dd
cc33
mixelpixel Sep 30, 2017
5a2cb48
cc34
mixelpixel Sep 30, 2017
77ae041
cc35
mixelpixel Sep 30, 2017
478f80c
cc36
mixelpixel Sep 30, 2017
6959a3e
cc37
mixelpixel Sep 30, 2017
9fdc625
cc38
mixelpixel Sep 30, 2017
fa9439d
cc39
mixelpixel Sep 30, 2017
71fe032
cc40
mixelpixel Sep 30, 2017
ab734af
cc41
mixelpixel Sep 30, 2017
ea1d456
cc42
mixelpixel Sep 30, 2017
1cffaed
cc43
mixelpixel Sep 30, 2017
273dca6
cc44
mixelpixel Sep 30, 2017
fb4e000
cc45
mixelpixel Sep 30, 2017
651cc28
cc46
mixelpixel Sep 30, 2017
336b744
cc47
mixelpixel Sep 30, 2017
e4bcb98
cc48
mixelpixel Sep 30, 2017
bffe93d
cc49
mixelpixel Sep 30, 2017
adb2da3
cc50
mixelpixel Sep 30, 2017
160a557
cc51
mixelpixel Sep 30, 2017
93c888c
cc52
mixelpixel Sep 30, 2017
842f354
cc54
mixelpixel Sep 30, 2017
b74d47a
cc54
mixelpixel Sep 30, 2017
46c4b8b
cc53
mixelpixel Sep 30, 2017
f2c9494
ignore this!
mixelpixel Sep 30, 2017
e333f9d
linting
mixelpixel Oct 2, 2017
8bd3b93
cc54
mixelpixel Oct 2, 2017
edbfde5
cc54
mixelpixel Oct 2, 2017
06f6995
cc54
mixelpixel Oct 3, 2017
4627b66
cc54
mixelpixel Oct 3, 2017
7ae2dee
cc55
mixelpixel Oct 3, 2017
840fadc
cc55
mixelpixel Oct 3, 2017
90d8507
cc56
mixelpixel Oct 5, 2017
f4f49a1
cc56
mixelpixel Oct 5, 2017
56b7abb
cc56
mixelpixel Oct 5, 2017
acc0e80
cc56
mixelpixel Oct 5, 2017
55e48aa
cc57
mixelpixel Oct 6, 2017
639e37d
cc57
mixelpixel Oct 6, 2017
ec6b2d6
cc58
mixelpixel Oct 9, 2017
6725a0e
cc58
mixelpixel Oct 9, 2017
b5eccf0
cc59
mixelpixel Oct 10, 2017
77a2ebf
c linting
mixelpixel Oct 10, 2017
98d3d22
cc59
mixelpixel Oct 11, 2017
ed1d0c2
cc59
mixelpixel Oct 11, 2017
b72790b
cc60
mixelpixel Oct 11, 2017
b9012c1
cc60
mixelpixel Oct 12, 2017
92951d9
cc61
mixelpixel Oct 12, 2017
4bba249
cc62
mixelpixel Oct 13, 2017
dcafaa9
cc63
mixelpixel Oct 16, 2017
6d646fb
cc63
mixelpixel Oct 16, 2017
6c4c572
cc64
mixelpixel Oct 17, 2017
0c997df
cc64
mixelpixel Oct 17, 2017
b89f9a5
cc64
mixelpixel Oct 18, 2017
7797034
cc65
mixelpixel Oct 18, 2017
da8a875
cc65
mixelpixel Oct 18, 2017
5dfa50a
cc65
mixelpixel Oct 18, 2017
e9d7309
cc65
mixelpixel Oct 18, 2017
74df0c8
cc66
mixelpixel Oct 19, 2017
1d68a34
cc66
mixelpixel Oct 19, 2017
7af7d29
cc66
mixelpixel Oct 19, 2017
05bc11f
cc67
mixelpixel Oct 20, 2017
82100a8
cc67
mixelpixel Oct 21, 2017
e82f596
cc68
mixelpixel Oct 23, 2017
58aefde
cc66
mixelpixel Oct 24, 2017
6068afe
cc67
mixelpixel Oct 24, 2017
abbed24
cc68
mixelpixel Oct 24, 2017
9f8ba76
cc69
mixelpixel Oct 24, 2017
4c4e325
cc67
mixelpixel Oct 24, 2017
1ac452c
cc68
mixelpixel Oct 24, 2017
8291cc1
cc69
mixelpixel Oct 24, 2017
ca578f0
cc69
mixelpixel Oct 24, 2017
f15f515
cc69
mixelpixel Oct 24, 2017
e6965ec
cc70
mixelpixel Oct 25, 2017
26a3014
cc70
mixelpixel Oct 25, 2017
1553e94
cc71
mixelpixel Oct 26, 2017
3fbd1da
cc72
mixelpixel Oct 27, 2017
c038404
cc72
mixelpixel Oct 27, 2017
1462500
cc73
mixelpixel Oct 31, 2017
fb83d6e
cc74
mixelpixel Oct 31, 2017
7a593bc
cc74
mixelpixel Nov 1, 2017
64d06bd
cc75
mixelpixel Nov 1, 2017
78dc603
cc76
mixelpixel Nov 2, 2017
43a4005
cc76
mixelpixel Nov 2, 2017
01c958d
cc77
mixelpixel Nov 3, 2017
7429c9e
cc77
mixelpixel Nov 3, 2017
7805784
c77
mixelpixel Nov 3, 2017
b591ab7
cc78 GO
mixelpixel Nov 6, 2017
5551ee2
cc78
mixelpixel Nov 6, 2017
2f618a5
cc78
mixelpixel Nov 6, 2017
99126ec
cc79
mixelpixel Nov 7, 2017
e51a254
cc79
mixelpixel Nov 7, 2017
924fa95
cc79
mixelpixel Nov 7, 2017
c4d5e44
cc80
mixelpixel Nov 8, 2017
415feb8
cc80
mixelpixel Nov 8, 2017
28414c8
cc80
mixelpixel Nov 8, 2017
7124c4e
cc81
mixelpixel Nov 9, 2017
f335da7
cc81
mixelpixel Nov 9, 2017
e15b196
cc82
mixelpixel Nov 10, 2017
9492e83
cc82
mixelpixel Nov 10, 2017
66223de
whiteboard prep
mixelpixel Nov 13, 2017
330cd50
whiteboard01
mixelpixel Nov 13, 2017
b19bea0
whiteboard interview prep
mixelpixel Nov 14, 2017
6cd3a8b
cc24
mixelpixel Nov 14, 2017
20f6e10
cc33
mixelpixel Nov 14, 2017
c74f62f
cc34
mixelpixel Nov 14, 2017
5c80e92
whiteboard
mixelpixel Nov 14, 2017
5ea2245
whiteboard interview prep
mixelpixel Nov 15, 2017
49afb38
whiteboard
mixelpixel Nov 15, 2017
3709531
whiteboard interview prep
mixelpixel Nov 16, 2017
668c577
cc11
mixelpixel Nov 16, 2017
4576cb6
whiteboard interview prep
mixelpixel Nov 17, 2017
1373dac
cc36
mixelpixel Jan 26, 2018
a3afdc8
cc15
mixelpixel Jan 31, 2018
4ee2f9e
cc17
mixelpixel Feb 15, 2018
afd15f0
cc12
mixelpixel Feb 20, 2018
1ea0e05
cc12
mixelpixel Feb 20, 2018
5dbec83
cc12
mixelpixel Feb 20, 2018
08e8e02
cc12
mixelpixel Feb 20, 2018
889e87a
cc19
mixelpixel Mar 31, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"presets":[
"es2015", "react"
]
}
33 changes: 33 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module.exports = {
"env": {
"browser": true,
"commonjs": true,
"es6": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true
},
"sourceType": "module"
},
"rules": {
"indent": [
"error",
2
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
]
}
};
8 changes: 8 additions & 0 deletions .gcc-flags.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"execPath": "/usr/bin/g++",
"gccDefaultCFlags": "-Wall",
"gccDefaultCppFlags": "-Wall -std=c++11",
"gccErrorLimit": 15,
"gccIncludePaths": ".,./include,./path",
"gccSuppressWarnings": true
}
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,22 @@
# npm installs
/node_modules
*/node_modules

# MongoDB
*/data

# all logfiles and tempfiles.
/log/*
!/log/.keep
/tmp

# Ignore vim
*~
*.swp
*.swo

# Ignore macOS
.DS_Store

# gcc
a.out
13 changes: 0 additions & 13 deletions allAnagrams/allAnagrams.js

This file was deleted.

9 changes: 0 additions & 9 deletions array/array.js

This file was deleted.

15 changes: 0 additions & 15 deletions binarySearch/binarySearch.js

This file was deleted.

35 changes: 35 additions & 0 deletions cc01longestString/longestString.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Write a function that accepts an array of strings.
* Return the longest string in the array.
*/

/* Take the first array item and put it in a "holding" array.
* Compare it to the next anArray, put the bigger of the two in the holding array.
*/
const bigString = function (anArr) {
const holdBig = [anArr[0]];
const tie = ['There\'s a tie: '];

for (let i = 1; i < anArr.length; i++) {
if (holdBig[0].length < anArr[i].length) {
holdBig.pop();
// console.log(anArr[i]);
holdBig.push(anArr[i]);
};
// tie if length match but different string - NOPE
// if (holdBig[0].length === anArr[i].length) {
// tie.push(anArr[i]);
// return `${tie[0]} ${tie[1]}`;
// }
};
return holdBig[0];
};

testAnArray = ['fred', 'ted', 'bob', 'alice', 'joe', 'arnold', 'mary', 'jebedaiah', 'ed', 'zachahurres', 'mae', 'antidisestablishmentarianism']
console.log(bigString(testAnArray)); // ---> antidisestablishmentarianism

// Refactor to return an array of the equal length strings if there's a tie? √
// testAnArrayTie = ['fred', 'ted', 'bob', 'antidisestablishmentarianism', 'alice', 'joe', 'arnold', 'mary', 'jebedaiah', 'ed', 'zachahurres', 'mae', 'antidisestablishmentarianism', 'manny']
// console.log(bigString(testAnArrayTie));

// Refactor to handle non-Array arguments?
35 changes: 35 additions & 0 deletions cc01longestString/solution.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const longestString = (strArr) => {
let tempStr = '';
strArr.forEach(str => {
if(str.length > tempStr.length) tempStr = str;
});
return tempStr;
};

longestString(['abc', 'def', 'gasdfasf', 'asdf', 'e', 'agwoaiengpoing']);

// Ryan's lecture video comments:
// https://youtu.be/juZvUpn4j5Y
const longestString = (strArr) => {
// tempStr variable to hold the string
let tempStr = '';
// loop over strArr
strArr.forEach(str => {
// if current string in arry is bigger than tempStr,
// then update the variable tempStr
if(str.length > tempStr.length) tempStr = str;
})
return tempStr;
};

console.log(`Ryan: ${longestString(['abc', 'def', 'gasdfasf', 'asdf', 'e', 'agwoaiengpoing', 'pp'])}`);

// Jesh's solution using sort()
const longStr = (arr) => {
arr.sort((a, b) => {
return b.length - a.length;
});
return arr[0];
}

console.log(`Jesh: ${longStr(['abc', 'def', 'gasdfasf', 'asdf', 'e', 'agwoaiengpoing', 'pp'])}`);
21 changes: 21 additions & 0 deletions cc02isUnique/isUnique.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Implement an algorithm to determine if a string has all unique characters.
* Extra Credit - Answer this question - What if you cannot use additional data structures?
*/
const isUnique = (str) => {
for (let i = 0; i < str.length; i++) {
for (let j = i + 1; j < str.length; j++) {
// console.log(`Q: does ${str[i]} === ${str[j]}? A: ${str[i] === str[j]}`)
if (str[i] === str[j]) {
return false;
}
}
} return true;
};

console.log(isUnique('abcdhijklmnopqrstuv')); // true
console.log(isUnique('abcdefghijklmnopqrstuvwyz')); // true
console.log(isUnique('abcdefga')); // false
console.log(isUnique('bcdgefga')); // false
console.log(isUnique([1, 2, 3, 4, 5, 6, 3])); // false
console.log(isUnique([0, 1, 2, 3, 4, 6, 7, 8, 9, 9])); // false
File renamed without changes.
53 changes: 53 additions & 0 deletions cc03reverseCase/pdk_reverseCase.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// I don't know why this got merge/erased, but this is my work:

/*
* Write a function that reverses the case of each letter in the strings that it receives.
* Example: 'Hello World' -> 'hELLO wORLD'
* Assume that each string will contain only spaces and letters.
*/

const reverseCase = function (str) {
// declare an array to house individual string letters or spaces in word/sentence order
const letters = [];
// declare a variable which will be used to reconstructed string
let caseConvertedString;

// examine each letter in the string
for (let i = 0; i < str.length; i++) {
// uppercase or lowercase or a space?
// if a space, push space into temp holding array (if not a space, it's a letter)
if (str[i] === ' ') {
letters.push(str[i]);
// if already Upper Case, push lower Case version of letter into holding array
} else if (str[i] === str[i].toUpperCase()) {
letters.push(str[i].toLowerCase())
// if not space and not already Upper Case, push Upper Case version of letter to holding array
} else letters.push(str[i].toUpperCase())
}
// zip up the array of letters and spaces into a string
caseConvertedString = letters.join('');
return caseConvertedString;
}

const testCase1 = 'Hello World'
console.log(reverseCase(testCase1)); // ---> hELLO wORLD
const testCase2 = 'Fsdfsdf ESDFSDFdfsdfsdfsdfdsf';
console.log(reverseCase(testCase2)); // ---> fSDFSDF esdfsdfDFSDFSDFSDFDSF
// will it handle periods?
const testCase3 = 'The quick brown Mr. Fox jumped over the lazy Mr. Dog.';
console.log(reverseCase(testCase3)); // ---> tHE QUICK BROWN mR. fOX JUMPED OVER THE LAZY mR. dOG.

// // Latoyya's solution
// const reverseString = (str) => {
// let newString = '';
// for (let i = 0; i < str.length; i++) {
// if (str.charCodeAt(i) >= 65 && str.charCodeAt(i) <= 90) {
// newString += str.charAt(i).toLowerCase();
// } else {
// newString += str.charAt(i).toUpperCase();
// }
// }
// return newString;
// };
// console.log(reverseString('Hello World'));
// console.log(reverseString('Hello World My NamE is LAtoyYa SmitH'));
File renamed without changes.
File renamed without changes.
104 changes: 104 additions & 0 deletions cc04largestPrimePalindrome/findPrimePalindromes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
// I: a sorted array of prime numbers, smallest to largest
// O: array of prime palindromes
const findPrimePals = function(primeArr) {
// console.log(primeArr);
const primePalsArr = []
for (i = 0; i < primeArr.length; i++) {
if (isPalindrome(numToStr(primeArr[i]))) primePalsArr.push(numToStr(primeArr[i]))
}
return primePalsArr;
}

// evaluates a range of natural numbers
// I: largest number in range (inclusive)
// O: an array of ALL prime #'s from range 0 thru INPUT integer
const findPrimes = function(bigNum) {
const primes = [];
// for number in range 0 thru *num
for (i = 0; i <=bigNum; i++) {
if (isPrime(i)) primes.push(i);
}
return primes;
}

// I: any integer
// O: "true" if INPUT is a prime number
const isPrime = function(num) {
// return true if num is prime.
// otherwise return false
if (num < 2) {return false;}
else if (num === 2) {return true;}
else if (num % 2 === 0) {return false;}
else if (num >= 3) {
for (var i = 2; i < Math.sqrt(num + 1); i++) { // Maybe a ceiling would work better (but slower?)?
if (num % i === 0) {
return false;
}
}
} return true;
}

// I: any string NOTE: does NOT handle integers
// O: "true" if INPUT is a palindrome
function isPalindrome(str) {
// return true if string is a palindrome.
// otherwise return false
for (let i = 0; i < str.length / 2; i++) { // <--- make sure divided by 2 handles odd and even length (floor vs. ceiling)
if (str[i] === str[str.length - 1 - i]) {
return true;
} else {
return false;
}
}
}

// I: a NUMBER
// O: a STRING
const numToStr = function(num) {
return `${num}`;
}

// // isPalindrome() TEST SUITE
// console.log(`Q: Is 'palindrome' a palindrome? A: ${isPalindrome('palindrome')}`) // <-- false
// console.log(`Q: Is ' ' a palindrome? A: ${isPalindrome(' ')}`) // <-- true
// console.log(`Q: Is 'a' a palindrome? A: ${isPalindrome('a')}`) // <-- true
// console.log(`Q: Is 'bb' a palindrome? A: ${isPalindrome('bb')}`) // <-- true
// console.log(`Q: Is 'cdc' a palindrome? A: ${isPalindrome('cdc')}`) // <-- true
// console.log(`Q: Is 'amanaplanacanalpanama' a palindrome? A: ${isPalindrome('amanaplanacanalpanama')}`) // <-- true
// console.log(`Q: Is an integer a palindrome? A: ${isPalindrome(5)}`) // <-- undefined

// // numToStr() test
// console.log(numToStr(5)); // <--- '5'
// console.log(typeof numToStr(5)); // <--- string
// console.log(`Q: Is the integer converted to a string? A: ${isPalindrome(numToStr(5))}`) // <-- true

// // isPrime TEST SUITE
// // 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199,
// console.log(`Q: Is 0 prime? A: ${isPrime(0)}`) // <--- false
// console.log(`Q: Is 1 prime? A: ${isPrime(1)}`) // <--- false
// console.log(`Q: Is 2 prime? A: ${isPrime(2)}`) // <--- true
// console.log(`Q: Is 3 prime? A: ${isPrime(3)}`) // <--- true
// console.log(`Q: Is 4 prime? A: ${isPrime(4)}`) // <--- false
// console.log(`Q: Is 5 prime? A: ${isPrime(5)}`) // <--- true
// console.log(`Q: Is 6 prime? A: ${isPrime(6)}`) // <--- false
// console.log(`Q: Is 7 prime? A: ${isPrime(7)}`) // <--- true
// console.log(`Q: Is 8 prime? A: ${isPrime(8)}`) // <--- false
// console.log(`Q: Is 9 prime? A: ${isPrime(9)}`) // <--- false
// console.log(`Q: Is 10 prime? A: ${isPrime(10)}`) // <--- false
// console.log(`Q: Is 11 prime? A: ${isPrime(11)}`) // <--- true
// console.log(`Q: Is 12 prime? A: ${isPrime(12)}`) // <--- false
// console.log(`Q: Is 13 prime? A: ${isPrime(13)}`) // <--- true
// console.log(`Q: Is 121 prime? A: ${isPrime(121)}`) // <--- false (11 * 11 = 121)
// console.log(`Q: Is 104729 prime? A: ${isPrime(104729)}`)// <--- true (104,729 is the 10,000th prime number!)

// // findPrimes TEST SUITE
// [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127]
console.log(`Q: what are the primes from 0 to 127?\nA: ${findPrimes(127)}`);
// console.log(`Q: what are the primes from 0 to 121?\nA: ${findPrimes(104729)}`); // <--- 10,000 prime numbers!!!!
console.log(findPrimes(104729).length);

// findPrimePals TEST SUITE
// [11, 101, ...]
console.log(`Q: Is findPrimePals(findPrimes(127)) an instance of an array?\nA: ${findPrimePals(findPrimes(127)) instanceof Array}`); // <--- true
console.log(`Q: what are the prime palindromes from 0 to 127?\nA: ${findPrimePals(findPrimes(127))}`); // <--- 2,3,5,7,11,101
console.log(`Q: what are the prime palindromes from 0 to 1000?\nA: ${findPrimePals(findPrimes(1000))}`); // <--- 2,3,5,7,11,101,131,151,181,191,313,353,373,383,727,757,787,797,919,929
Loading