+ 10
[ASSIGNMENT] One Liner to find the largest out of three numbers using Ternary Operator !
Write a program to input three numbers by the user, then write a single statement which checks all the three numbers and finds the greatest amongst them. Printing of the largest number can be done in an extra line. Important part is the single line which will check the numbers and find the greatest one. Good Luck to all !!!! :) PS: You could use Ternary operator as well to write the single line statement. Aaron Stone
20 Answers
+ 21
Flash
We all know what is One Line Code!
most of us have answered the assignment where the ternary operator is used.
Please, read the task and see what is being asked to write in OneLine!
the codes in one line are not simply clean to read in other languages and are not nice, at least for me!
so everyone is trying to improvise with code in order to make the helpful one.
>>Important part<< is the Single Line Which Will Check the Numbers and Find the Greatest One!
PS : You could use
》Ternary operator《 as well to write the
=> single line statement! <=
+ 18
https://code.sololearn.com/cMAFbpjsawyE/?ref=app
+ 11
https://code.sololearn.com/cKyzYzeq2chD/#py
+ 6
Great guys !!
+ 6
Nice work everyone !
+ 5
One liners r normally messy, and purpose is to reduce the size of the code, not to make it readable. Writing in a single line and one-liners r not same as far as I understand (def x(s) : return s —- is it a one-liner? Don’t think so, by definition it means done with the execution of the program in one line). Of course! I didn’t use ternary. But assignment header is bit confusing and the way people titled their solutions. Nonetheless, I didn’t mean to offend anyone. Just expressed my point of view.
+ 5
Flash
Don't worry, it's okey☺. No one is offended. 😉
You are expressing your point of view, same we are.
Good luck!! ✌👌👍
+ 4
MeanMachine is right.
What is asked to be in one liner is just the check of the numbers. So the solutions in here are ok.
My complete one liner code:
https://code.sololearn.com/cryq3d9V7zpN/?ref=app
+ 3
https://code.sololearn.com/c2xVIuE4R7C1/?ref=app
https://code.sololearn.com/cx0E1kcqbc46/?ref=app
+ 3
No offense but none of the entries seems to be a “one-liner”. In my opinion this is called one-liner:
#written by flash in python (works on any number of inputs)
[print(max(list(map(int, input().split()))))]
+ 2
Hello, everyone!
In Python it is rather simple with the built-in function max(), but I used some comparison in a second version.
https://code.sololearn.com/cb6NOXj31MVx/
+ 1
Max=a>b?a:b>c?b:c;
+ 1
👍🏼