-
Notifications
You must be signed in to change notification settings - Fork 45
matrix rotation and logic gates #93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sfmajors373
wants to merge
69
commits into
bloominstituteoftechnology:master
Choose a base branch
from
sfmajors373:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
69 commits
Select commit
Hold shift + click to select a range
ba19352
first commit
sfmajors373 85f01e0
isUnique, first part works
sfmajors373 035c3aa
delete unnecessary comments
sfmajors373 9dcf51a
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
sfmajors373 0031f30
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
sfmajors373 d776dd4
LargestPrimePalindrome - work
sfmajors373 70ebcce
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
sfmajors373 9f0c853
ievenOccurences
sfmajors373 f6920e1
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
sfmajors373 e938619
callbackPractice: code written, not tested
sfmajors373 768885a
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
sfmajors373 29e292c
forLoopTimeout: fixed
sfmajors373 7b40ece
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
sfmajors373 5c87020
Daily update
sfmajors373 4b9127b
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
sfmajors373 0f90717
Fixed spacing issues
sfmajors373 8c88393
waterJug solution
sfmajors373 50622aa
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
sfmajors373 9a1ba4c
Array: tests added, not passing
sfmajors373 cd1cef2
Array: tests pass
sfmajors373 89ecf7a
Array: comment maintenance
sfmajors373 f67ad92
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
sfmajors373 2817968
Array: add return statement to pop
sfmajors373 02e7850
stringCompression: beginning but not passing tests yet
sfmajors373 5f1308b
string compression: tests pass
sfmajors373 579abbd
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
sfmajors373 9040d7b
operators: tests bench created
sfmajors373 a8ab1a5
operators: tests pass
sfmajors373 77a2364
operators: adjust spacing
sfmajors373 b1afd25
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
sfmajors373 1098af0
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
sfmajors373 877b243
QueueStack: Queue remove not working correctly
sfmajors373 67299f3
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
sfmajors373 cd87257
Adjustments to queueStack and all of bubbleSort
sfmajors373 72b14a8
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
sfmajors373 900e743
allAnagrams: works, could be improved for efficiency
sfmajors373 0fd3dcc
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
sfmajors373 ee8b129
instertionSort: works
sfmajors373 d4f7fb9
Added Alt solutions for AllAnagrams
sfmajors373 1616844
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
sfmajors373 fdcb4dc
RotateImage: works, not extra credit though
sfmajors373 3c1996c
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
sfmajors373 f22acfb
logicGates passes tests
sfmajors373 c37b57a
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
sfmajors373 6956712
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
sfmajors373 9179398
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
sfmajors373 53041f6
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
sfmajors373 283f41c
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
sfmajors373 5caa890
rotatedArray: tests do not pass
sfmajors373 a537df1
rotatedArray works
sfmajors373 fe74674
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
sfmajors373 d259ea5
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
sfmajors373 ea04e4a
Updating backlog of codechallenges
sfmajors373 7141d6a
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
sfmajors373 7e6b0fd
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
sfmajors373 277cb71
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
sfmajors373 567da0a
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
sfmajors373 6b95236
Common characters
sfmajors373 45dd999
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
sfmajors373 108db8e
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
sfmajors373 215403d
Update
sfmajors373 e932397
Merge branch 'master' of https://github.com/ryanhca/CS1-Code-Challenges
sfmajors373 bbb3dba
Update
sfmajors373 0560515
Daily update
sfmajors373 9c902d4
Adjustment to daily challenge
sfmajors373 f4a8de3
Daily update
sfmajors373 63804bf
Daily update
sfmajors373 5b774d5
Daily update
sfmajors373 9d0dbc7
Daily update
sfmajors373 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| // Recursive: | ||
| const allAnagrams = (str, start = '') => { | ||
| if (str.length === 1) return [start + str]; | ||
| const anagrams = []; | ||
|
|
||
| for (let i = 0; i < str.length; i++) { | ||
| const result = allAnagrams(str.substr(0, i) + str.substr(i + 1), str[i]); | ||
| for (let j = 0; j < result.length; j++) { | ||
| anagrams.push(start + result[j]); | ||
| } | ||
| } | ||
| return anagrams; | ||
| }; | ||
|
|
||
| // Depth First Search, turning string into tree: | ||
| class Anagram { | ||
| constructor(string, letter = null) { | ||
| this.string = string; | ||
| this.letter = letter; | ||
| this.children = []; | ||
| this.answer = []; | ||
| this.divide(); | ||
| this.produce(); | ||
| } | ||
|
|
||
| divide() { | ||
| const arr = this.string.split(''); | ||
| arr.forEach(l => { | ||
| const rest = arr.filter(x => x !== l).join(''); | ||
| const anagram = new Anagram(rest, l); | ||
| this.children.push(anagram); | ||
| }); | ||
| } | ||
|
|
||
| produce(a = this, b = null) { | ||
| if (a.letter) { | ||
| b = b ? b.concat(a.letter) : a.letter; | ||
| } | ||
| if (a.children.length) { | ||
| a.children.forEach(aa => { | ||
| return this.produce(aa, b ? b : null) | ||
| }); | ||
| return this.answer; | ||
| } | ||
| this.answer.push(b); | ||
| } | ||
| } | ||
|
|
||
| function allAnagrams(s) { | ||
| return (new Anagram(s)).answer; | ||
| } | ||
|
|
||
| const anagrams = allAnagrams('abcdefghi'); | ||
| console.log(anagrams); | ||
|
|
||
| // JS implementation of Heap's Permutation Algorithm, also using generator: | ||
| var swap = function (array, pos1, pos2) { | ||
| var temp = array[pos1]; | ||
| array[pos1] = array[pos2]; | ||
| array[pos2] = temp; | ||
| }; | ||
|
|
||
| var heapsPermute = function (array, output, n) { | ||
| n = n || array.length; // set n default to array.length | ||
| if (n === 1) { | ||
| output(array); | ||
| } else { | ||
| for (var i = 1; i <= n; i += 1) { | ||
| heapsPermute(array, output, n - 1); | ||
| if (n % 2) { | ||
| var j = 1; | ||
| } else { | ||
| var j = i; | ||
| } | ||
| swap(array, j - 1, n - 1); // -1 to account for javascript zero-indexing | ||
| } | ||
| } | ||
| }; | ||
| https://gist.github.com/dsernst/2570de0dc7d44a8cbbd0 | ||
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 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| //An Armstrong number is an n-digit number that is equal to the sum of the n'th powers of its digits. Determine if the input numbers are Armstrong numbers. Return either true or false . | ||
|
|
||
| // For example with the number 153 there are 3 digits so you would add together the cubed values of all the digits like this: 1^3 + 5^3 + 3^3 === 153 | ||
|
|
||
| function isArmstrongNumber(n){ | ||
| const arr = n.toString().split(''); | ||
| let acc = 0; | ||
| for (let i = 0; i < arr.length; i++) { | ||
| acc = Math.pow(Number(arr[i]), arr.length) + acc; | ||
| } | ||
| if (acc === n) { | ||
| return true; | ||
| } | ||
| return false; | ||
| } |
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 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 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <header> | ||
| <link rel="stylesheet" type="text/css" href="styles.css"> | ||
| <script src="scripts.js"></script> | ||
| </header> | ||
| <body> | ||
| <div class="container"> | ||
| <a class="box" href="#">1</a> | ||
| <a class="box" href="#">2</a> | ||
| <a class="box" href="#">3</a> | ||
| <a class="box" href="#">4</a> | ||
| <a class="box" href="#">5</a> | ||
| <a class="box" href="#">6</a> | ||
| <a class="box" href="#">7</a> | ||
| <a class="box" href="#">8</a> | ||
| <a class="box" href="#">9</a> | ||
| <a class="box" href="#">10</a> | ||
| <a class="box" href="#">11</a> | ||
| <a class="box" href="#">12</a> | ||
| </div> | ||
| </body> | ||
| </html> |
Empty file.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| body { | ||
| } | ||
|
|
||
| .container { | ||
| display: flex; | ||
| flex-direction: row; | ||
| flex-wrap: wrap; | ||
| justify-content: space-around; | ||
| } | ||
|
|
||
| .box { | ||
| background: tomato; | ||
| padding: 5px; | ||
| width: 200px; | ||
| height: 150px; | ||
| margin-top: 10px; | ||
| line-height: 150px; | ||
| color: white; | ||
| font-weight: bolder; | ||
| font-size: 3em; | ||
| text-align: center; | ||
| } | ||
|
|
||
| a:hover { | ||
| background-color: blue; | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| You have a five-quart jug, a three-quart jug, and an unlimited supply of water (but no measuring cups). | ||
| How would you come up with exactly four quarts of water? | ||
| Note that the jugs are oddly shaped, such that filling up exactly "half" of the jug would be impossible. | ||
|
|
||
| Take the full 5, use it to fill the 3-quart jug. Empty the 3-quart jug, and place the remaining 2-quarts from the 5-quart jug into the small jug. Refill the large jug. Pour enough out of the large jug to fill the small jug. This leaves 4 quarts in the larger jug. |
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 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sarah, this is fantastic. allAnagrams is such a plaguing algorithm to complete. I hate it. haha. You've solved it recursively and with a depth first search solution. I'm very impressed!