Coder Social home page Coder Social logo

recursion-prompts's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

recursion-prompts's Issues

Review tests for prompt #20

The tests for prompt 20 need reviewing. Since objects don't promise a particular order, it's tricky determining if the returned object contains all the correct key/value pairs.

isEven -- Modulo issue

Test will fail for "should not use modulo" when the word "modulo" is included in comments.

Add tests to restrict number of arguments allowed

There are many ways to utilize recursion. One approach is to define inner functions that perform recursive behavior and cause side effects. This technique is often simpler to comprehend for those new to recursion. Another approach is to modify the number of parameters a function accepts in order to pass different values through the recursive stack. Both of these techniques are valid uses of recursion, but there are important lessons to be learned from avoiding these two techniques. The student needs to understand how values can be passed through the recursive stack without using recursive subroutines or modifying the number of parameters the function accepts.

Tests already exist requiring each function call itself instead of utilize subroutines, but tests need to be added restricting the number of arguments allowed for each prompt.

Comments fail it("should not use complex math")

First off thanks for this challenge set!

So I just noticed that adding in-function comments to Modulo, Multiply, and Divide is caught by the search for '/' operators. Not sure if its worth changing the test for it but a warning above the prompt might be nice.

Best,
Jordan

alternateSign function

Hello,
I'm working on the recursion prompts and noticed that the test being done on alternateSign are not working according to specifications.

// their original sign. The first number in the index always needs to be positive.
// alternateSign([2,7,8,3,1,4]) // [2,-7,8,-3,1,-4]
// alternateSign([-2,-7,8,3,-1,4]) // [2,-7,8,-3,1,-4]

After completing the function I noticed that the first element being positive gave off an error. I adjusted the functions code to make the first element in the array negative and then alternate from there. I guess I just wanted to let someone who made it know.

Regards,
Erwin

Prompt #34 - Minimize Zeroes - needs more robust testing

Tests should be run against an array which also has multiple consecutive digits other than zero in a row.

With the following code, the current automated mocha tests will pass:

var minimizeZeroes = function(array) {
if (array.length <= 1) {
return array;
} else if (array[0] !== array[1]) {
return [array[0]].concat(minimizeZeroes(array.slice(1)));
} else {
return minimizeZeroes(array.slice(1));
}
};

But the above code also minimizes numbers other than zero as well

The following function call :
minimizeZeroes([1, 2, 2, 2, 3, 0, 0, 4, 0, 0])
will produce:
[1, 2, 3, 0, 4, 0]
when it should produce:
[1, 2, 2, 2, 3, 0, 4, 0]

Suggestion for fix:
add multiple consecutive digits which aren't zero to the test

Test for sumBelow has incorrect text

part1.js line 279

it says "should return the sum of an array of negative integers"

This function tests integers, not arrays. The tests in question pass negative integers as arguments.

The wording from the immediate previous test could probably be adapted.

Test for recursion on 15. Compare Strings uses strings of unequal length

Line 890 of part1.js
Problem 15 compare strings
It uses strings of unequal length 'house' and 'houses' to check that recursive calls equal at least 1.

This is a problem because the first thing many people will do is compare string length. Which is a good habit it to be in.

if the strings compared were 'house' and 'houes' it would test for recursion calls as well as pass a test for equal length. (or even just 'house' and 'house')

Actual:

it('should use recursion by calling self', function() {
        compareStr('house', 'houses');  <<-----------------------
        expect(compareStr.callCount).to.be.above(1);
      });

suggested:
compareStr('house', 'houes');

Recursion Test - Part 1 (Exponent)

First off, I wanted to say thanks for setting this up, it's been a huge help in practicing recursion! I just wanted to point out a slight issue with one of the tests (lines 435-440) in Part I. A negative base with an even exponent will yield a positive number.

it('should accept negative integer for base', function() {
expect(exponent(-3,4)).to.equal(-81); //should be 81
expect(exponent(-12,5)).to.equal(-248832);
expect(exponent(-7,2)).to.equal(-49); //should be 49
expect(exponent(-7,4)).to.equal(-2401); //should be 2401
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.