+ 25

[ ASSIGNMENT: ] Lambda expressions

TASK : Write the following methods that return a lambda expression performing a specified action : 1. PerformOperation isOdd() : The lambda expression must return true if a number is odd or false if it is even. 2. PerformOperation isPrime() : The lambda expression must return true if a number is prime or false if it is composite. 3. PerformOperation isPalindrome() : The lambda expression must return true if a number is a palindrome or false if it is not. Sample Input : * The first line contains an integer, N (the number of test cases). * The N subsequent lines each describe a test case in the form of 2 space-separated integers : - The first integer specifies the condition to check for (1 for Odd/Even, 2 for Prime, or 3 for Palindrome). - The second integer denotes the number to be checked. 5 1 4 2 5 3 898 1 3 2 12 Sample Output : EVEN PRIME PALINDROME ODD COMPOSITE HappyCodings!:)

28th May 2018, 1:49 PM
Danijel Ivanović
Danijel Ivanović - avatar
12 Antworten
+ 16
MyTry ... [Finally:] 😄👍😃 https://code.sololearn.com/cplhRZS5w45M/?ref=app
31st May 2018, 8:21 PM
Danijel Ivanović
Danijel Ivanović - avatar
+ 14
Reviiea N is the number of test cases! For your example, you need to enter 4 cases, not 5 as you specify, then that is the wrong entry! 👍
29th May 2018, 8:56 PM
Danijel Ivanović
Danijel Ivanović - avatar
30th May 2018, 5:35 AM
LukArToDo
LukArToDo - avatar
+ 11
https://code.sololearn.com/c7BSvt925zMC/?ref=app
15th Jun 2018, 10:14 AM
Mert Yazıcı
Mert Yazıcı - avatar
28th May 2018, 9:27 PM
hinanawi
hinanawi - avatar
30th May 2018, 9:31 PM
reviiea
reviiea - avatar
+ 6
What is supposed to do the integer N? 😯 What should be the output if the input is 4 1 4 2 5 3 898 1 3 2 12 Output: "EVEN PRIME PALINDROME ODD" or "Invalid input!" or something else? 🤔🤔 I think it should be the first one but i'm not sure... 😅
29th May 2018, 8:42 PM
reviiea
reviiea - avatar
+ 4
Reviiea it denotes the number of lines to input as said in the assignment
29th May 2018, 8:44 PM
hinanawi
hinanawi - avatar
+ 4
Danijel Ivanović hinanawi Thank you both ☺️☺️
29th May 2018, 9:00 PM
reviiea
reviiea - avatar
29th May 2018, 6:03 AM
hinanawi
hinanawi - avatar
+ 2
Danijel Ivanović hi, i was surprised to see very few entries. i know u like detailed coding, however this was fun doing this one-liner( without using import statements on the top and with very basic error handling). i’m not bragging, but this is pure use of lambda expressions and a pure one-liner( of course someone could make a shorter version of this, i guess). it’d be cool if u check this out. thanks https://code.sololearn.com/c4lE2H5TMIqw/?ref=app
13th Jun 2018, 11:14 PM
Flash