stephengrider / algocasts Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU General Public License v3.0
License: GNU General Public License v3.0
The second line should be:
const Queue = require('./queue');
Instead of Q capital!
There seems to be a typo in AlgoCasts/exercises/reversestring/index.js:
// reverse('apple') === 'leppa'
Here the expected value should be 'elppa' instead of 'leppa'
Hello! I was writing a solution for your maxChar problem and I passed all your tests. However, when I ran the solution against string 'cacacbb', it returned 'b' instead of 'c'. Since my faulty function has passed all the original tests, I assume other students could have the same issue, so I added:
expect(maxChar('cacacbb')).toEqual('c');
to AlgoCasts/exercises/maxchar/test.js
Here is the link to my pull request: #3
Here is my faulty function that passed the original tests:
function maxChar(str) {
var letter;
var count = 0;
str.split('').forEach((item, index) => {
if(letter === undefined || item === letter) {
letter = item;
count++;
} else {
if(count === 1){
letter = item
}
}
});
return letter;
}
this is the error
No tests found, exiting with code 1
Run with --passWithNoTests
to exit with code 0
In C:\Users\pawan\Desktop\AlgoCasts\completed_exercises
62 files checked.
testMatch: /tests//.[jt]s?(x), **/?(.)+(spec|test).[tj]s?(x) - 27 matches
testPathIgnorePatterns: \node_modules\ - 62 matches
testRegex: - 0 matches
Pattern: index.js - 0 matches
I believe this should read: returns Node instance with data 'b'
Example is the same for getFirst vs getLast
I forgot to put the global tag in my regex replace, and the tests still passed, but the example test in the description doesn't.
anagrams('RAIL! SAFETY!', 'fairy tales') --> True
Maybe add this in the test as well just to make sure all edge cases are covered.
Courses are paid but what about course material?
Shouldn't the material be open source so that students can fork freely?
palindrome/test.js
✓ palindrome function is defined (2ms)
✕ "aba" is a palindrome
✓ " aba" is not a palindrome
✓ "aba " is not a palindrome (1ms)
✓ "greetings" is not a palindrome
✕ "1000000001" a palindrome
✓ "Fish hsif" is not a palindrome
✕ "pennep" a palindrome
● GetAt › returns the node at given index
TypeError: Cannot set property 'next' of null
79 | let lastNode = this.getLast()
80 | let newNode = new Node(data)
> 81 | lastNode.next = newNode
| ^
82 | }
83 |
84 | getAt(index) {
at LinkedList.insertLast (linkedlist/index.js:81:5)
at Object.test (linkedlist/test.js:155:7)
function maxChar(str) {
let groupedChars = {};
str.split("").forEach(character => {
groupedChars[character] = !!groupedChars[character]
? groupedChars[character] + 1
: 1;
});
const values = Object.values(groupedChars);
return Object.keys(groupedChars)[values.indexOf(Math.max(...values))];
}
Minor issue, but it seems that it is missing an export for the merge
function for the sort.js
in the algorithm.
Currently it is this:
module.exports = { bubbleSort, selectionSort, mergeSort };
It should be:
module.exports = { bubbleSort, selectionSort, mergeSort, merge };
I was just working through the anagram section of the exercises and I realized that one the examples given in the problem definition are not being checked by the test code. I propose adding a simple test to check for the same.
The solution should not avoid the second loop?
function maxChar(str) {
const charMap = {};
let max = 0;
let maxChar = '';
for(let element of str) {
charMap[element] = charMap[element] ? charMap[element] + 1 : 1;
if(charMap[element] > max) {
max = charMap[element];
maxChar = element
}
}
return maxChar;
}
instead of
function maxChar(str) {
const charMap = {};
let max = 0;
let maxChar = '';
for (let char of str) {
if (charMap[char]) {
charMap[char]++;
} else {
charMap[char] = 1;
}
}
for (let char in charMap) {
if (charMap[char] > max) {
max = charMap[char];
maxChar = char;
}
}
return maxChar;
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.