The number of daffodils is a 3-bit positive integer in which the sum of the 3 powers of the number on each bit is equal to itself. (For example: 1^3 + 5^3+ 3^3 = 153)
The following is a code to find all the number of daffodils: method One:
>>>
>>> A = List (map (X:x[1], filter ( Range (0)]) print (a) [153, 370, 371,
407]
Description
The code above can break down three lines of code:
Range (0)]
B = Filter (x:x[0], a)
c = List (map (x:x[1), b)
The first sentence is to use the list to traverse all three digits, each number marked, the Narcissus number is Mark True, not mark false, tag and sum into a single ancestor: (flag, value), all tuples in a list structure.
The second sentence indicates that a tuple marked as true is filtered out.
The third sentence indicates that the second value of the tuple that is filtered out in the first sentence is placed in the list structure.
Add the print statement, and perform the above three code to understand.
method Two: only use list derivation.
I*100+j*10+k = = i**3+j**3+k**3]
>>> Print (a)
[153, 370, 371, 407]