Skip to main content
added 434 characters in body
Source Link
Wheat Wizard
  • 100k
  • 22
  • 282
  • 661

Haskell, 36 bytes

f n|n<1=n==0
f n=any(f.(n-))[6,9,20]

Try it online!

Explanation

This solution is about as straightforward as it can get. The first line declares that for any number less than 1 it is a McNugget number if n==0. That is to say that 0 is a McNugget number and all negative numbers are not.

The second line declares that for all other numbers, n is a McNugget number if it minus any of the Nugget sizes is a McNugget number.

This is a pretty simple recursive search.

Haskell, 36 bytes

f n|n<1=n==0
f n=any(f.(n-))[6,9,20]

Try it online!

Haskell, 36 bytes

f n|n<1=n==0
f n=any(f.(n-))[6,9,20]

Try it online!

Explanation

This solution is about as straightforward as it can get. The first line declares that for any number less than 1 it is a McNugget number if n==0. That is to say that 0 is a McNugget number and all negative numbers are not.

The second line declares that for all other numbers, n is a McNugget number if it minus any of the Nugget sizes is a McNugget number.

This is a pretty simple recursive search.

deleted 604 characters in body
Source Link
Wheat Wizard
  • 100k
  • 22
  • 282
  • 661

Haskell, 5236 bytes

x=[6,9,20]
f n|elem n x=1>0|n<1=1<0n|n<1=n==0
f n=any(f.(n-))x

Try it online!


Alternative

g n|n<1=n==0
g n=any(g.(n-))[6,9,20]
f 0=1<0
f n=g n

Try it online!

I find it incredibly frustrating that 0 is considered falsy. (You can easily get 0 McNuggets by not purchasing any). This entire thing would be 36 bytes if zero was truthy as it should be.Try it online!

Haskell, 52 bytes

x=[6,9,20]
f n|elem n x=1>0|n<1=1<0
f n=any(f.(n-))x

Try it online!


Alternative

g n|n<1=n==0
g n=any(g.(n-))[6,9,20]
f 0=1<0
f n=g n

Try it online!

I find it incredibly frustrating that 0 is considered falsy. (You can easily get 0 McNuggets by not purchasing any). This entire thing would be 36 bytes if zero was truthy as it should be.

Haskell, 36 bytes

f n|n<1=n==0
f n=any(f.(n-))[6,9,20]

Try it online!

added 567 characters in body
Source Link
Wheat Wizard
  • 100k
  • 22
  • 282
  • 661

Haskell, 52 bytes

x=[6,9,20]
f n|elem n x=1>0|n<1=1<0
f n=any(f.(n-))x

Try it online!


Alternative

g n|n<1=n==0
g n=any(g.(n-))[6,9,20]
f 0=1<0
f n=g n

Try it online!

I find it incredibly frustrating that 0 is considered falsy. (You can easily get 0 McNuggets by not purchasing any). This entire thing would be 36 bytes if zero was truthy as it should be.

Haskell, 52 bytes

x=[6,9,20]
f n|elem n x=1>0|n<1=1<0
f n=any(f.(n-))x

Try it online!

Haskell, 52 bytes

x=[6,9,20]
f n|elem n x=1>0|n<1=1<0
f n=any(f.(n-))x

Try it online!


Alternative

g n|n<1=n==0
g n=any(g.(n-))[6,9,20]
f 0=1<0
f n=g n

Try it online!

I find it incredibly frustrating that 0 is considered falsy. (You can easily get 0 McNuggets by not purchasing any). This entire thing would be 36 bytes if zero was truthy as it should be.

added 2 characters in body
Source Link
Wheat Wizard
  • 100k
  • 22
  • 282
  • 661
Loading
Source Link
Wheat Wizard
  • 100k
  • 22
  • 282
  • 661
Loading