Ad
Code
Diff
  • find_max=max
    • def find_max(arr):
    • return max(arr)
    • find_max=max
Numbers
Data Types
Algorithms
Logic

It is bad practice to have different return types. Maybe instead you could return 0 if the input is invalid.

You may also want to specify whether floats should be converted too.

Code
Diff
  • def convert(number):
        return number*-1 if type(number) == int else 0
    
    • def convert(number):
    • if isinstance(number, int):
    • # Check if number is negitive
    • if number < 0:
    • # negitive -> positive
    • return (abs(number))
    • else:
    • # positive -> negitive
    • return (number * -1)
    • else:
    • return False
    • return number*-1 if type(number) == int else 0
Code
Diff
  • o=lambda n: n if n%2==1 else n-1
    • def o(n): return n-(n%2==0)
    • o=lambda n: n if n%2==1 else n-1
Code
Diff
  • e=lambda n:n if n%2 == 0 else n-1
    • e=lambda n:n&-2
    • e=lambda n:n if n%2 == 0 else n-1
Code
Diff
  • sort_names = lambda s: ' '.join(sorted(s.title().split()))
    • def sort_names(s):
    • return ' '.join(sorted(s.title().split()))
    • sort_names = lambda s: ' '.join(sorted(s.title().split()))

Create a function called sort_names() which takes a string of names each separated by a space and returns them as a string with the names sorted and in title case. See below.

'Kate Amara Bob Justin' --> 'Amara Bob Justin Kate'
'kate amara bob justin' --> 'Amara Bob Justin Kate'
def sort_names(s):
    return ' '.join(sorted(s.title().split()))

Anagrams are words that consist of the same letters. One example is 'felt' and 'left'.
Super anagrams also consist of the same words, but their first and last letter are the same. For example, 'Bart' and 'Brat'

Your task is to create a function called 'anagram_check' that determines whether a pair of words are anagrams, super anagrams or not anagrams at all.

If it is a super anagram, it should return 'Super Anagram'.
If it is an anagram, it should return 'Anagram'.
If it is not an anagram, it should return False.

The input will be stored in one variable. The program should not be case-sensitive. The test will not contain any other characters apart from letters of the Latin/English alphabet.

Notes:
Make sure to return the result exactly as it is shown (i.e. in titlecase)
The program should not be case sensitive.
All input will be valid.

If any improvements can be made, please let me know, otherwise have fun and enjoy!

def anagram_check(words):
    listed = words.split() 
    first = listed[0] 
    second = listed[1] 
    first_split = (list(first))
    second_split = (list(second)) 
    if first_split[0]==second_split[0] and first_split[-1]==second_split[-1]:
        first_split_alpha = sorted(first_split)
        second_split_alpha = sorted(second_split) 
        if first_split_alpha == second_split_alpha:
            return'Super Anagram'
        else: 
            return False
    else: 
        return 'Anagram'