-
-
Notifications
You must be signed in to change notification settings - Fork 46.8k
sock_merchant.py: Matching socks by color #5761
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
21 commits
Select commit
Hold shift + click to select a range
88de7cc
Python file for finding number of pairs
SouvikGhosh05 8ce37b7
updating DIRECTORY.md
5b114c5
fixed iterative_pair.py
SouvikGhosh05 b71d224
Merge branch 'master' of github.com:SouvikGhosh05/Python
SouvikGhosh05 05162dd
further fixed with type casting
SouvikGhosh05 b7df4ff
fixed naming conventions
SouvikGhosh05 a86c985
further fixed with naming convention
SouvikGhosh05 3be15ca
documented done
SouvikGhosh05 31ce790
build issue fixed
SouvikGhosh05 92e368b
updating DIRECTORY.md
8ab059a
Revert "documented done"
SouvikGhosh05 3e2ee83
Merge branch 'master' of github.com:SouvikGhosh05/Python
SouvikGhosh05 4024940
Update canny.py
cclauss 733f600
Update test_digital_image_processing.py
cclauss cf06141
Update sobel_filter.py
cclauss 7b4e515
requirements.txt fixed
SouvikGhosh05 c8d3350
keras<2.7.0
cclauss 3ac46fe
requirements.txt fixed
SouvikGhosh05 a32226a
Update sock_merchant.py
cclauss a7c9643
doctest with black fixed
SouvikGhosh05 b2251b1
Update sock_merchant.py
cclauss 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
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,20 @@ | ||
from collections import Counter | ||
|
||
|
||
def sock_merchant(colors: list[int]) -> int: | ||
""" | ||
>>> sock_merchant([10, 20, 20, 10, 10, 30, 50, 10, 20]) | ||
3 | ||
>>> sock_merchant([1, 1, 3, 3]) | ||
2 | ||
""" | ||
return sum(socks_by_color // 2 for socks_by_color in Counter(colors).values()) | ||
|
||
|
||
if __name__ == "__main__": | ||
import doctest | ||
|
||
doctest.testmod() | ||
|
||
colors = [int(x) for x in input("Enter socks by color :").rstrip().split()] | ||
print(f"sock_merchant({colors}) = {sock_merchant(colors)}") |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
beautifulsoup4 | ||
fake_useragent | ||
keras | ||
keras<2.7.0 | ||
lxml | ||
matplotlib | ||
numpy | ||
|
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.
@cclauss I think this is the issue here