Anonymous user
McNuggets problem: Difference between revisions
→{{header|Python}}: Sub-headers.
(→{{header|Python}}: Sub-headers.) |
|||
Line 482:
=={{header|Python}}==
===Python: REPL===
{{trans|FSharp}}▼
It's a simple solution done on the command line:
<lang python>▼
#Wherein I observe that Set Comprehension is not intrinsically dysfunctional. Nigel Galloway: October 28th., 2018▼
n = {n for x in range(0,101,20) for y in range(x,101,9) for n in range(y,101,6)}▼
g = {n for n in range(101)}▼
print(max(g.difference(n)))▼
</lang>▼
{{out}}▼
<pre>▼
43▼
</pre>▼
<lang python>>>> from itertools import product
>>> nuggets = set(range(101))
Line 511 ⟶ 502:
>>> </lang>
===Python: Just functions===
Or, composing pure functions, including dropwhile:
<lang python>from itertools import (chain, dropwhile)
Line 565 ⟶ 556:
{{Out}}
<pre>43</pre>
===Python: From F#===
▲{{trans|FSharp}}
▲<lang python>
▲#Wherein I observe that Set Comprehension is not intrinsically dysfunctional. Nigel Galloway: October 28th., 2018
▲n = {n for x in range(0,101,20) for y in range(x,101,9) for n in range(y,101,6)}
▲g = {n for n in range(101)}
▲print(max(g.difference(n)))
▲</lang>
▲{{out}}
▲<pre>
▲43
▲</pre>
=={{header|REXX}}==
|