Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
I think I overcomplicated lol solution in Creative category for Max Digit by BootzenKatzen
#This is what I came up with without hints:
def max_digit(value: int) -> int:
valslice = str(value) #turning the value into a string to be sliced
list = [*valslice] #unpacks the string into a list of individual values
for i in list:
list.append(int(list.pop(0))) #pops each value off the list, turns them into an integer and puts them back on
return max(list) #finds the max number
#Their way is much neater:
def max_digits(a: int) -> int:
return max(map(int, str(a))) # map uses int() on each individual character of str(a) - the number as a string
# but even though it's turning them back into integers since map was done on each
# peice of the string, it holds them as separate objects - kind of like a list
# then you can find the max number among those individual integers
# I don't know much about lambda but I think it's just another way of creating a function
max_digits2 = lambda a: max(map(int, str(a))) #so this does the same thing as their first answer, but packed in 1 line
print(max_digits2(123432356))
print("Example:")
print(max_digit(10))
# These "asserts" are used for self-checking
assert max_digit(0) == 0
assert max_digit(52) == 5
assert max_digit(634) == 6
assert max_digit(1) == 1
assert max_digit(10000) == 1
print("The mission is done! Click 'Check Solution' to earn rewards!")
April 3, 2023
Comments: