Skip to content
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

Updated Prime Numbers in JavaScript #2009

Merged
merged 3 commits into from
Oct 5, 2020

Conversation

theuntamed839
Copy link
Contributor

@theuntamed839 theuntamed839 commented Oct 2, 2020

Congrats on taking the first step to contributing to the Sample Programs repository maintained by The Renegade Coder!
For simplicity, please make sure that your pull request includes one and only one contribution.

Complete the Applicable Sections Below

Find which section best describes your pull request and make sure you fill it out. To start, let us know which issue you've fixed.

  • I fixed #your-issue-number-here

Code Snippets

  • I named the pull request using Added/Updated <Sample Program> in <Language> format
  • I created/updated the language README
    • I added the sample program name to the README
    • I added fun facts (i.e. debut developer, typing, etc.)
    • I added reference link(s) to the README
    • I added solution citations when necessary (see plagiarism)

Testing

  • I named the pull request using Added/Updated <Language>/<Project> Testing format
  • I followed the testinfo template, if applicable

Notes

Feel free to describe what you added or updated.

@theuntamed839 theuntamed839 changed the title Performance improvement Updated Prime-number in Javascript Oct 2, 2020
Copy link
Member

@jrg94 jrg94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clever change! This is definitely more performant.

@jrg94 jrg94 changed the title Updated Prime-number in Javascript Updated Prime Numbers in JavaScript Oct 3, 2020
@jrg94 jrg94 self-assigned this Oct 3, 2020
@jrg94 jrg94 added enhancement Any code that improves the repo prime number See: https://sampleprograms.io/projects/prime-number/ labels Oct 3, 2020
@jrg94 jrg94 added this to the 1,000 Code Snippets milestone Oct 3, 2020
@jrg94
Copy link
Member

jrg94 commented Oct 3, 2020

Oh wait... the changes fail one test:

=================================== FAILURES ===================================
_______________ test_prime_valid[prime-number.js-sample input 2] _______________
description = 'sample input 2', in_params = '"2"', expected = 'prime'
prime = Source(name: prime-number, path: /home/travis/build/TheRenegadeCoder/sample-programs/archive/j/javascript)
    @project_test(ProjectType.Prime.key)
    @pytest.mark.parametrize(valid_permutations[0], valid_permutations[1],
                             ids=[p[0] for p in valid_permutations[1]])
    def test_prime_valid(description, in_params, expected, prime):
        actual = prime.run(params=in_params)
>       assert actual.strip().lower() == expected
E       AssertionError: assert 'composite' == 'prime'
E         - composite
E         + prime
test/projects/test_prime.py:80: AssertionError
================== 1 failed, 1303 passed in 444.20s (0:07:24) ==================
The command "python runner.py test" exited with 1.

@jrg94 jrg94 self-requested a review October 3, 2020 01:26
Copy link
Member

@jrg94 jrg94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments above. Looks like the changes cause the script to report composite for 2.

Copy link
Member

@jrg94 jrg94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great now!

@jrg94 jrg94 merged commit f40e136 into TheRenegadeCoder:master Oct 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Any code that improves the repo prime number See: https://sampleprograms.io/projects/prime-number/
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants