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

Implemented the selection sort algo using python and java #473

Closed
wants to merge 1 commit into from
Closed

Implemented the selection sort algo using python and java #473

wants to merge 1 commit into from

Conversation

john2ksonn
Copy link

@john2ksonn john2ksonn commented Oct 28, 2018

For short term contributors: we understand that getting your commits well
defined like we require is a hard task and takes some learning. If you
look to help without wanting to contribute long term there's no need
for you to learn this. Just drop us a message and we'll take care of brushing
up your stuff for merge!

Fixes #446

By submitting this pull request I confirm I've read and complied with the
below declarations.

  • I have read the Contribution guidelines and I am confident that my PR reflects them.
  • I have followed the commit guidelines for this project.
  • My code follows the standard code structure.
  • This pull request has a descriptive title. For example, {Tag}: Add {Algorithm/DS name} [{Language}], not Update README.md or Added new code.
  • This pull request will be closed if I fail to update it even once in a continuous time span of 7 days.
  • I have mentioned the issue number correctly (with hyperlink) in this pull request description.
  • This pull request shall only be reviewed and merged once all the checks passes. No maintainer or supporter shall be obliged to review it before this condition is met.

After you submit your pull request, DO NOT click the 'Update Branch' button.

@@ -0,0 +1,28 @@
'''
____ _ _ _ ____ _
Copy link
Member

Choose a reason for hiding this comment

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

Line contains following spacing inconsistencies:

  • Trailing whitespaces.

Origin: SpaceConsistencyBear, Section: all.pyjava.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpz6y7xvz3/selection_sort/Python/selection_sort.py
+++ b/tmp/tmpz6y7xvz3/selection_sort/Python/selection_sort.py
@@ -1,5 +1,5 @@
 '''
- ____       _           _   _             ____             _   
+ ____       _           _   _             ____             _
 / ___|  ___| | ___  ___| |_(_) ___  _ __ / ___|  ___  _ __| |_ 
 \___ \ / _ | |/ _ \/ __| __| |/ _ \| '_ \\___ \ / _ \| '__| __|
  ___) |  __| |  __| (__| |_| | (_) | | |  ___) | (_) | |  | |_ 

@@ -0,0 +1,28 @@
'''
____ _ _ _ ____ _
/ ___| ___| | ___ ___| |_(_) ___ _ __ / ___| ___ _ __| |_
Copy link
Member

Choose a reason for hiding this comment

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

Line contains following spacing inconsistencies:

  • Trailing whitespaces.

Origin: SpaceConsistencyBear, Section: all.pyjava.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpz6y7xvz3/selection_sort/Python/selection_sort.py
+++ b/tmp/tmpz6y7xvz3/selection_sort/Python/selection_sort.py
@@ -1,6 +1,6 @@
 '''
  ____       _           _   _             ____             _   
-/ ___|  ___| | ___  ___| |_(_) ___  _ __ / ___|  ___  _ __| |_ 
+/ ___|  ___| | ___  ___| |_(_) ___  _ __ / ___|  ___  _ __| |_
 \___ \ / _ | |/ _ \/ __| __| |/ _ \| '_ \\___ \ / _ \| '__| __|
  ___) |  __| |  __| (__| |_| | (_) | | |  ___) | (_) | |  | |_ 
 |____/ \___|_|\___|\___|\__|_|\___/|_| |_|____/ \___/|_|   \__|

____ _ _ _ ____ _
/ ___| ___| | ___ ___| |_(_) ___ _ __ / ___| ___ _ __| |_
\___ \ / _ | |/ _ \/ __| __| |/ _ \| '_ \\___ \ / _ \| '__| __|
___) | __| | __| (__| |_| | (_) | | | ___) | (_) | | | |_
Copy link
Member

Choose a reason for hiding this comment

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

Line contains following spacing inconsistencies:

  • Trailing whitespaces.

Origin: SpaceConsistencyBear, Section: all.pyjava.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpz6y7xvz3/selection_sort/Python/selection_sort.py
+++ b/tmp/tmpz6y7xvz3/selection_sort/Python/selection_sort.py
@@ -2,7 +2,7 @@
  ____       _           _   _             ____             _   
 / ___|  ___| | ___  ___| |_(_) ___  _ __ / ___|  ___  _ __| |_ 
 \___ \ / _ | |/ _ \/ __| __| |/ _ \| '_ \\___ \ / _ \| '__| __|
- ___) |  __| |  __| (__| |_| | (_) | | |  ___) | (_) | |  | |_ 
+ ___) |  __| |  __| (__| |_| | (_) | | |  ___) | (_) | |  | |_
 |____/ \___|_|\___|\___|\__|_|\___/|_| |_|____/ \___/|_|   \__|
 
 '''

def sort(a):
max_idx = len(a) - 1
for idx in range(0, max_idx):
min_idx = idx
Copy link
Member

Choose a reason for hiding this comment

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

Line contains following spacing inconsistencies:

  • Trailing whitespaces.

Origin: SpaceConsistencyBear, Section: all.pyjava.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpz6y7xvz3/selection_sort/Python/selection_sort.py
+++ b/tmp/tmpz6y7xvz3/selection_sort/Python/selection_sort.py
@@ -14,7 +14,7 @@
 def sort(a):
     max_idx = len(a) - 1
     for idx in range(0, max_idx):
-        min_idx = idx        
+        min_idx = idx
         for i in range(idx+1, max_idx+1):
             if a[i] < a[min_idx]:
                 min_idx = i

for i in range(idx+1, max_idx+1):
if a[i] < a[min_idx]:
min_idx = i
a[idx], a[min_idx] = a[min_idx], a[idx]
Copy link
Member

Choose a reason for hiding this comment

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

Line contains following spacing inconsistencies:

  • Trailing whitespaces.

Origin: SpaceConsistencyBear, Section: all.pyjava.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpz6y7xvz3/selection_sort/Python/selection_sort.py
+++ b/tmp/tmpz6y7xvz3/selection_sort/Python/selection_sort.py
@@ -18,7 +18,7 @@
         for i in range(idx+1, max_idx+1):
             if a[i] < a[min_idx]:
                 min_idx = i
-        a[idx], a[min_idx] = a[min_idx], a[idx]        
+        a[idx], a[min_idx] = a[min_idx], a[idx]
     return a
     
 

min_idx = i
a[idx], a[min_idx] = a[min_idx], a[idx]
return a

Copy link
Member

Choose a reason for hiding this comment

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

Line contains following spacing inconsistencies:

  • Trailing whitespaces.

Origin: SpaceConsistencyBear, Section: all.pyjava.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpz6y7xvz3/selection_sort/Python/selection_sort.py
+++ b/tmp/tmpz6y7xvz3/selection_sort/Python/selection_sort.py
@@ -20,7 +20,7 @@
                 min_idx = i
         a[idx], a[min_idx] = a[min_idx], a[idx]        
     return a
-    
+
 
 if __name__ == "__main__":
     rand_list = random.sample(range(1000), 40)

import java.util.Random;

/*
____ _ _ _ ____ _
Copy link
Member

Choose a reason for hiding this comment

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

Line contains following spacing inconsistencies:

  • Trailing whitespaces.

Origin: SpaceConsistencyBear, Section: all.pyjava.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpz6y7xvz3/selection_sort/Java/SelectionSort.java
+++ b/tmp/tmpz6y7xvz3/selection_sort/Java/SelectionSort.java
@@ -1,7 +1,7 @@
 import java.util.Random;
 
 /*
- ____       _           _   _             ____             _   
+ ____       _           _   _             ____             _
 / ___|  ___| | ___  ___| |_(_) ___  _ __ / ___|  ___  _ __| |_ 
 \___ \ / _ | |/ _ \/ __| __| |/ _ \| '_ \\___ \ / _ \| '__| __|
  ___) |  __| |  __| (__| |_| | (_) | | |  ___) | (_) | |  | |_ 


/*
____ _ _ _ ____ _
/ ___| ___| | ___ ___| |_(_) ___ _ __ / ___| ___ _ __| |_
Copy link
Member

Choose a reason for hiding this comment

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

Line contains following spacing inconsistencies:

  • Trailing whitespaces.

Origin: SpaceConsistencyBear, Section: all.pyjava.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpz6y7xvz3/selection_sort/Java/SelectionSort.java
+++ b/tmp/tmpz6y7xvz3/selection_sort/Java/SelectionSort.java
@@ -2,7 +2,7 @@
 
 /*
  ____       _           _   _             ____             _   
-/ ___|  ___| | ___  ___| |_(_) ___  _ __ / ___|  ___  _ __| |_ 
+/ ___|  ___| | ___  ___| |_(_) ___  _ __ / ___|  ___  _ __| |_
 \___ \ / _ | |/ _ \/ __| __| |/ _ \| '_ \\___ \ / _ \| '__| __|
  ___) |  __| |  __| (__| |_| | (_) | | |  ___) | (_) | |  | |_ 
 |____/ \___|_|\___|\___|\__|_|\___/|_| |_|____/ \___/|_|   \__|

____ _ _ _ ____ _
/ ___| ___| | ___ ___| |_(_) ___ _ __ / ___| ___ _ __| |_
\___ \ / _ | |/ _ \/ __| __| |/ _ \| '_ \\___ \ / _ \| '__| __|
___) | __| | __| (__| |_| | (_) | | | ___) | (_) | | | |_
Copy link
Member

Choose a reason for hiding this comment

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

Line contains following spacing inconsistencies:

  • Trailing whitespaces.

Origin: SpaceConsistencyBear, Section: all.pyjava.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpz6y7xvz3/selection_sort/Java/SelectionSort.java
+++ b/tmp/tmpz6y7xvz3/selection_sort/Java/SelectionSort.java
@@ -4,7 +4,7 @@
  ____       _           _   _             ____             _   
 / ___|  ___| | ___  ___| |_(_) ___  _ __ / ___|  ___  _ __| |_ 
 \___ \ / _ | |/ _ \/ __| __| |/ _ \| '_ \\___ \ / _ \| '__| __|
- ___) |  __| |  __| (__| |_| | (_) | | |  ___) | (_) | |  | |_ 
+ ___) |  __| |  __| (__| |_| | (_) | | |  ___) | (_) | |  | |_
 |____/ \___|_|\___|\___|\__|_|\___/|_| |_|____/ \___/|_|   \__|
 
 */

# date: 10.28.2018

import random

Copy link
Member

Choose a reason for hiding this comment

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

The code does not comply to PEP8.

Origin: PEP8Bear, Section: all.autopep8.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpz6y7xvz3/selection_sort/Python/selection_sort.py
+++ b/tmp/tmpz6y7xvz3/selection_sort/Python/selection_sort.py
@@ -10,6 +10,7 @@
 # date: 10.28.2018
 
 import random
+
 
 def sort(a):
     max_idx = len(a) - 1

def sort(a):
max_idx = len(a) - 1
for idx in range(0, max_idx):
min_idx = idx
Copy link
Member

Choose a reason for hiding this comment

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

The code does not comply to PEP8.

Origin: PEP8Bear, Section: all.autopep8.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpz6y7xvz3/selection_sort/Python/selection_sort.py
+++ b/tmp/tmpz6y7xvz3/selection_sort/Python/selection_sort.py
@@ -14,7 +14,7 @@
 def sort(a):
     max_idx = len(a) - 1
     for idx in range(0, max_idx):
-        min_idx = idx        
+        min_idx = idx
         for i in range(idx+1, max_idx+1):
             if a[i] < a[min_idx]:
                 min_idx = i

for i in range(idx+1, max_idx+1):
if a[i] < a[min_idx]:
min_idx = i
a[idx], a[min_idx] = a[min_idx], a[idx]
Copy link
Member

Choose a reason for hiding this comment

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

The code does not comply to PEP8.

Origin: PEP8Bear, Section: all.autopep8.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpz6y7xvz3/selection_sort/Python/selection_sort.py
+++ b/tmp/tmpz6y7xvz3/selection_sort/Python/selection_sort.py
@@ -18,9 +18,9 @@
         for i in range(idx+1, max_idx+1):
             if a[i] < a[min_idx]:
                 min_idx = i
-        a[idx], a[min_idx] = a[min_idx], a[idx]        
+        a[idx], a[min_idx] = a[min_idx], a[idx]
     return a
-    
+
 
 if __name__ == "__main__":
     rand_list = random.sample(range(1000), 40)

@@ -0,0 +1,28 @@
'''
____ _ _ _ ____ _
Copy link
Member

Choose a reason for hiding this comment

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

W291 trailing whitespace

Origin: PycodestyleBear (W291), Section: all.autopep8.

@@ -0,0 +1,28 @@
'''
____ _ _ _ ____ _
/ ___| ___| | ___ ___| |_(_) ___ _ __ / ___| ___ _ __| |_
Copy link
Member

Choose a reason for hiding this comment

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

W291 trailing whitespace

Origin: PycodestyleBear (W291), Section: all.autopep8.

____ _ _ _ ____ _
/ ___| ___| | ___ ___| |_(_) ___ _ __ / ___| ___ _ __| |_
\___ \ / _ | |/ _ \/ __| __| |/ _ \| '_ \\___ \ / _ \| '__| __|
___) | __| | __| (__| |_| | (_) | | | ___) | (_) | | | |_
Copy link
Member

Choose a reason for hiding this comment

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

W291 trailing whitespace

Origin: PycodestyleBear (W291), Section: all.autopep8.


import random

def sort(a):
Copy link
Member

Choose a reason for hiding this comment

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

E302 expected 2 blank lines, found 1

Origin: PycodestyleBear (E302), Section: all.autopep8.

def sort(a):
max_idx = len(a) - 1
for idx in range(0, max_idx):
min_idx = idx
Copy link
Member

Choose a reason for hiding this comment

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

W291 trailing whitespace

Origin: PycodestyleBear (W291), Section: all.autopep8.

for i in range(idx+1, max_idx+1):
if a[i] < a[min_idx]:
min_idx = i
a[idx], a[min_idx] = a[min_idx], a[idx]
Copy link
Member

Choose a reason for hiding this comment

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

W291 trailing whitespace

Origin: PycodestyleBear (W291), Section: all.autopep8.

min_idx = i
a[idx], a[min_idx] = a[min_idx], a[idx]
return a

Copy link
Member

Choose a reason for hiding this comment

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

W293 blank line contains whitespace

Origin: PycodestyleBear (W293), Section: all.autopep8.

@sangamcse sangamcse added invalid This doesn't seem right and removed difficulty/low hacktoberfest HACKTOBERFEST 2020 lang/Python labels Oct 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Algo] Selection Sort [Python]
2 participants