Skip to content

Commit

Permalink
add whiteboarding session file from TextEdit app
Browse files Browse the repository at this point in the history
  • Loading branch information
eluckie committed Apr 14, 2023
1 parent 5a3da41 commit a975e79
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 17 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,13 @@ Output: true

Write an algorithm that sorts an array without using the sort() method. There are many different sorting algorithms — take the time to read about the following:

Quick sort
Merge sort
Heap sort
Insertion sort
Bubble sort
Selection sort
* Quick sort
* Merge sort
* Heap sort
* Insertion sort
* Bubble sort
* Selection sort

You may implement any of the above algorithms (or your own) to solve the problem — as long as it doesn't use sort().

Example
Expand Down
8 changes: 8 additions & 0 deletions prompt1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,13 @@ result: "Jasmine%20Ann%20Jones";
WITH RECURSION:

const stringToUrl = (input) => {
let firstSpace = input.indexOf(" ");
if (firstSpace === -1) {
return input;
}

let firstWord = input.substring(0, firstSpace);
let updatedFirstWord = firstWord + "%20";
let restOfInput = input.substring(firstSpace + 1);
return stringToUrl(updatedFirstWord + restOfInput);
};
24 changes: 17 additions & 7 deletions prompt2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ WITHOUT RECURSION OR .FILTER:

const removeDuplicates = (inputArray) => {
let resultArray = [];
for (let i=0; i < inputArray.length; i++) {
const currentInput = inputArray[i];
if (!resultArray.includes(currentInput)) {
resultArray.push(inputArray[i]);
if (!Array.isArray(resultArray)) {
return "Please enter an array";
} else {
for (let i=0; i < inputArray.length; i++) {
if (!resultArray.includes(inputArray[i])) {
resultArray.push(inputArray[i]);
};
};
};
return resultArray;
Expand All @@ -36,9 +39,16 @@ const removeDuplicates = (inputArray) => {
inputArray = [7, 9, "hi", 7, 12, "hi", 53];
result = [7, 9, "hi", 12, 53];


WITH RECURSION:

const removeDuplicates = (inputArray) => {

const removeDuplicates = (array) => {

};

USING FILTER:

const removeDuplicates = (array) => {
return unique = array.filter((item, index) => {
return array.indexOf(item) === index;
});
};
6 changes: 3 additions & 3 deletions prompt3.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ empty result string > .concat +

WITHOUT RECURSION:

const stringCompression = (string) => {
const stringCompression = (input) => {
const string = input.toLowerCase();
let result = "";
let counter = 1;
for (let i=0; i < string.length; i++) {
Expand All @@ -33,8 +34,7 @@ const stringCompression = (string) => {
} else if (counter === 1) {
result += currentChar;
} else {
result+= counter + currentChar;
currentChar = string[i];
result += counter + currentChar;
counter = 1;
}
}
Expand Down
1 change: 0 additions & 1 deletion prompt4.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ no array or array.methods
for loop

const uniqueElements = (string) => {
let counter = 0;
let resultString = "";
for (i=0; i < string.length; i++) {
const currentChar = string[i];
Expand Down
50 changes: 50 additions & 0 deletions whiteboarding.rtf
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{\rtf1\ansi\ansicpg1252\cocoartf2580
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
{\*\expandedcolortbl;;}
\margl1440\margr1440\vieww18000\viewh12940\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0

\f0\fs48 \cf0 Luckie\
\
Array de-duping\
Remove duplicates\
\
W & w.o filter\
w.o recursion\
Any data types in array\
Not in same order\
\
Input [7, 9, \'93hi\'94, 12, \'93hi\'94, 7, 53]\
Output [7, 9, \'93hi\'94, 12, 53]\
\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
\cf0 No .filter\
.includes\
[] .push\
For loop\
.isArray\
Typeof()\
(3, 4, 5, 6)\
[valid data types];\
\
Const removeDuplicates = (inputArray) => \{\
let resultArray = [];\
\
if (!Array.isArray(inputArray)) \{\
return \'93Please enter an array\'94;\
\} else \{\
for (let I=0; I < inputArray.length; I++) \{\
if (!resultArray.includes(inputArray[I])) \{\
resultArray.push(inputArray[I]);\
\}\
\};\
\};\
return resultArray;\
\};\
\
Const removeDuplicates = (inputArray) => \{\
return array = inputArray.filter((item, index) => \{\
return inputArray.indexOf(item) === index;\
\});\
\};}

0 comments on commit a975e79

Please sign in to comment.