-
Notifications
You must be signed in to change notification settings - Fork 24
Solution to issue #18 in Python #26
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c77b47f
Solution to issue #18 in Python
Himanshu1495 3068663
Modified the code,function created to allow passing the parameters
Himanshu1495 01c3ab9
Tests for issue #18 added. SKELETON CODE to test python(2.7) solution…
Himanshu1495 83580c3
Modification to 18.py
Himanshu1495 80f3222
Modification to test18.py
Himanshu1495 64650de
Solution to issue #34 in Python 2.7
Himanshu1495 fabec11
Merge branch 'master' of https://github.com/Himanshu1495/algorithms
Himanshu1495 e2d1f35
Delete 34.py
Himanshu1495 ab97ccf
Delete test34.py
Himanshu1495 7a20b9b
print statement removed from solution
Himanshu1495 a0d7b6e
Test skeleton moved from solutions to tests
Himanshu1495 2b03a34
Test modified to eliminate redundancy. pythontest_skeleton modified w…
Himanshu1495 0a2acc5
Renamed test18.py to 18.py and deleted pythontest_skeleton
Himanshu1495 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,17 @@ | ||
| #Himanshu Nachane (@Himanshu1495) | ||
| '''return missing number in an input array of consecutively increasing numbers. | ||
|
|
||
| i: [5,6,8,9] | ||
| o: 7 | ||
| ''' | ||
|
|
||
| def missing_num(arr): | ||
| first_element = arr[0] | ||
| last_element = arr[-1] | ||
| new_sum = 0 | ||
| for x in range(first_element,last_element+1): | ||
| new_sum += x | ||
| return new_sum - sum(arr) | ||
|
|
||
|
|
||
|
|
||
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,14 @@ | ||
| import sys | ||
| sys.path.insert(0,'../solutions/') | ||
| from sol18 import missing_num | ||
| import unittest | ||
|
|
||
| class MyTest(unittest.TestCase): | ||
| def test1(self): | ||
| self.assertEqual(missing_num([10,11,12,14,15,16]),13) | ||
| def test2(self): | ||
| self.assertEqual(missing_num([125,126,128,129,130]),127) | ||
| def test3(self): | ||
| self.assertEqual(missing_num([1125,1127,1128,1129,1130]),1126) | ||
|
|
||
| unittest.main() |
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.
can you rename this file to just 18.py please?
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.
@songz, I tried keeping it 18.py but then I found out that Python files should not start with a number for the exact same reason. It would be good to keep the file name as sol18.py or anything which starts with a string.