Coder Social home page Coder Social logo

cs371p-collatz's People

Contributors

mdelvalle avatar

Watchers

 avatar  avatar

cs371p-collatz's Issues

Unit Tests

Created at least 3 Unit tests for each of the functions.

Implementation

Implemented all of the requirements and the project runs as expected.

Improved speed

Changed from:
n = (3 * n) + 1;
to:
n = n + (n >> 1) + 1;

Issue Tracker

Counting this one, there is a total of 18 issues.

Sphere

Sphere accepted solutions to both the required and extra-credit solutions.

Still too slow

Made it dramatically faster by adding:
Let m = e / 2.
If b < m, then max_cycle_length(b, e) = max_cycle_length(m, e)

Acceptance tests

Used Python script to create the 1000 Acceptance tests.
Pushed the tests to the public test repository.

error: ‘cache’ was not declared in this scope

Had:
int idx = 1000000;
int cache[idx] = {0};
This is what gave me the error; these were both global variables used inside the function collatz_eval.

After, I changed the code to:
int cache[1000000] = {0};
with no index variable, the algorithm worked without problems.

More than 10000000 total errors detected

Was getting more than 1 million memory errors because I was creating an array of 1 million entries every time the function collatz_eval was called.
Instead I made the array a global variable; it solved the problem and increased the efficiency dramatically.

Git repository

Created a new private repository for the Collatz project.

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.