Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
6006d4a
Tried to solve
Jul 11, 2017
e0a24ce
Solved
Jul 12, 2017
2641cca
Solved
Jul 12, 2017
25f53d0
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
Jul 12, 2017
948e91b
Changes
Jul 12, 2017
7e4716c
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
Jul 13, 2017
cb702ec
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
manishavi Jul 14, 2017
34c5e54
USed ASCII
manishavi Jul 17, 2017
9a25645
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
manishavi Jul 17, 2017
7b6ec54
Update reverseCase.js
manishavi Jul 17, 2017
e84fdcb
solved
manishavi Jul 18, 2017
7a0cd3c
solved
manishavi Jul 18, 2017
5e139d0
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
manishavi Jul 18, 2017
df830bc
Merge branch 'master' of https://github.com/manishavi/CS1-Code-Challe…
manishavi Jul 18, 2017
a42ccec
solved
manishavi Jul 18, 2017
40a01c0
Now it prints
manishavi Jul 19, 2017
4157f1d
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
manishavi Jul 19, 2017
ff126db
solved
manishavi Jul 19, 2017
8611f47
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
manishavi Jul 20, 2017
a08b371
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
manishavi Jul 21, 2017
a558d3d
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
manishavi Jul 24, 2017
3e68152
array done
manishavi Jul 24, 2017
9f19073
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
manishavi Jul 25, 2017
7571177
did the first part
manishavi Jul 25, 2017
a4c0b2e
done tricky part for multiply
manishavi Jul 25, 2017
8d3492f
started today
manishavi Jul 25, 2017
4b742ff
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
manishavi Jul 26, 2017
9136cad
multiply and divide done with (+ and -)
manishavi Jul 26, 2017
1b5ec3f
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
manishavi Jul 27, 2017
b7d305f
did the first part
manishavi Jul 28, 2017
b66a925
with tests
manishavi Jul 28, 2017
14219cb
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
manishavi Jul 28, 2017
feb39c6
Solved
manishavi Jul 28, 2017
e9cf562
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
manishavi Jul 31, 2017
d7754b3
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
manishavi Aug 1, 2017
8a740a5
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
manishavi Aug 2, 2017
9c8c4e8
Solved
manishavi Aug 2, 2017
d44a4b7
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
manishavi Aug 3, 2017
189fdc3
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
manishavi Aug 4, 2017
2e848a3
solved
manishavi Aug 4, 2017
29c871b
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
manishavi Aug 7, 2017
078e3ae
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
manishavi Aug 8, 2017
e3011d8
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
manishavi Aug 9, 2017
9a99bf2
solved
manishavi Aug 9, 2017
a2a52da
selction sort completed
manishavi Aug 10, 2017
fa1aa22
added missing semicolon
manishavi Aug 10, 2017
3e9da74
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
manishavi Aug 10, 2017
cee1f3a
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
manishavi Aug 11, 2017
a4999b8
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
manishavi Aug 15, 2017
d0b11ea
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
manishavi Aug 16, 2017
abdf615
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
manishavi Aug 17, 2017
a8bcef4
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
manishavi Aug 18, 2017
3322202
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
manishavi Aug 21, 2017
5745742
completed
manishavi Aug 22, 2017
f2af01c
typo
manishavi Aug 22, 2017
c5e67d1
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
manishavi Aug 22, 2017
a35ac7e
completed
manishavi Aug 23, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
14 changes: 13 additions & 1 deletion allAnagrams/allAnagrams.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,16 @@
* example usage:
* const anagrams = allAnagrams('abc');
* console.log(anagrams); // [ 'abc', 'acb', 'bac', 'bca', 'cab', 'cba' ]
*/
*/
const allAnagrams = (word) => {
let arr = [];
for(let i = 0; i < word.length; i++) {
for(let j = word.length; j>0; j--) {
let cur = word.substring(i, i + 1);
let before = word.substring(0, i);
let after = word.substring(i + 1);
console.log( cur+before + after);
}
}
}
const anagrams = allAnagrams('abc');
35 changes: 35 additions & 0 deletions array/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,38 @@
* How do these operations compare to that of a linked list?
* How does the time complexity of insertion and deletion compare to that of a linked list?
*/
class Array {
constructor() {
this.array = {};
this.length = 0;
}

push() {
this.array[this.length];
this.length++;
}
pop() {
delete this.array[this.length-1];
this.index--;
return this.array[this.length-1];
}
get(index) {
return this.array[index];
}
delete(index) {
delete this.array[index];
for (let i = index; i <= this.length; i++) {
this.array[i] = this.array[i + 1];
}
this.length--;
}
}

const array = new Array(3);
array.push(1);
array.push(3);
array.push(5);
array.push(7);
console.log(array);
console.log(array.get(2));
console.log(array.delete(0));
22 changes: 22 additions & 0 deletions binarySearch/binarySearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,26 @@

const binarySearch = (nums, target) => {

let min = 0;
let max = nums.length - 1;
let mid = Math.floor((min + max)/2);

while (min <= max){

mid = Math.floor((min + max)/2);

if(nums[mid] === target) {
return mid;
}
else if (nums[mid] < target){
min = mid + 1;
}
else if (nums[mid] > target){
max = mid - 1;
}
}
return -1;

};
const index = binarySearch([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 2);
console.log(index); // 1
18 changes: 18 additions & 0 deletions bubbleSort/bubbleSort.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,22 @@

const bubbleSort = (arr) => {
//code here
let n = arr.length;
let temp;

for(let i = 0; i < n; i++) {
for(let j = 1; j < (n - i); j++) {

if (arr[j - 1] > arr[j]) {
temp = arr[j - 1];
arr[j - 1] = arr[j];
arr[j] = temp;
}

}
}
console.log(arr);
};

bubbleSort([2, 1, 3]);
bubbleSort([4, 9, 3]);
49 changes: 39 additions & 10 deletions callbackPractice/callbackPractice.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,52 +19,81 @@
// Write a function called firstItem that passes the first item of the given array to the callback function

const foods = ['pineapple', 'mango', 'ribeye', 'curry', 'tacos', 'ribeye', 'mango'];
const firstItem = (arr, cb) => {
cb(arr[0]);
};

firstItem(foods, (firstItem) => {
console.log(`The first item is ${firstItem}.`);
});

// Write a function called getLength that passes the length of the array into the callback

// Write a function called getLength that passes the length of the array into the callback
const getLength = (arr, cb) => {
cb(arr.length);
};
const length = getLength;
getLength(foods, (length) => {
console.log(`The length of the array is ${length}.`);
});
});;

// Write a function called last which passes the last item of the array into the callback

// Write a function called last which passes the last item of the array into the callback
const last = (arr, cb) => {
cb(arr[arr.length - 1]);
};
last(foods, (lastItem) => {
console.log(`The last item in the array is ${lastItem}.`);
});

// Write a function called sumNums that adds two numbers and passes the result to the callback


const sumNums = (num1, num2, cb) => {
cb(num1 + num2);
};
sumNums(5, 10, (sum) => {
console.log(`The sum is ${sum}.`);
});

// Write a function called multiplyNums that adds two numbers and passes the result to the callback

const multiplyNums = (num1, num2, cb) => {
cb(num1 * num2);
};
multiplyNums(5, 10, (product) => {
console.log(`The product is ${product}.`);
});

// Write a function called contains that checks if an item is present inside of the given array.
// Pass true to the callback if it is, otherwise pass false

const contains = (arr, item, cb) => {
if (cb(arr.indexOf(item) >= 0)){ return true;}
return false;
};
contains(foods, 'ribeye', (result) => {
console.log(result ? 'ribeye is in the array' : 'ribeye is not in the array');
});

// Write a function called removeDuplicates that removes all duplicate values from the given array.
// Pass the array to the callback function. Do not mutate the original array.

const removeDuplicates = (arr, cb) => {
const obj = {};
const aarr = [];
arr.forEach((item) => {
if (!obj[item]) {
obj[item] = true;
aarr.push(item);
}
}
cb(aarr);
};
removeDuplicates(foods, (uniqueFoods) => {
console.log(`foods with duplicates removed: ${uniqueFoods}`);
});

// Write a function called forEach that iterates over the provided array and passes the value and index into the callback.

const forEach = (arr, cb) => {
for(let i = 0; i < arr.length; i++){
cb(arr[i], i);
}
};
forEach(foods, (value, index) => {
console.log(`${value} is at index ${index}.`);
});
1 change: 1 addition & 0 deletions fizzBuzzTesting/node_modules/.bin/_mocha

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions fizzBuzzTesting/node_modules/.bin/mkdirp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions fizzBuzzTesting/node_modules/.bin/mocha

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions fizzBuzzTesting/node_modules/assertion-error/.npmignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions fizzBuzzTesting/node_modules/assertion-error/History.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions fizzBuzzTesting/node_modules/assertion-error/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading