How to resolve the algorithm McNuggets problem step by step in the zkl programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm McNuggets problem step by step in the zkl programming language

Table of Contents

Problem Statement

Calculate (from 0 up to a limit of 100) the largest non-McNuggets number (a number n which cannot be expressed with 6x + 9y + 20z = n where x, y and z are natural numbers).

Let's start with the solution:

Step by Step solution about How to resolve the algorithm McNuggets problem step by step in the zkl programming language

Source code in the zkl programming language

nuggets:=[0..101].pump(List());	// (0,1,2,3..101), mutable
foreach s,n,t in ([0..100/6],[0..100/9],[0..100/20])
   { nuggets[(6*s + 9*n + 20*t).min(101)]=0 }
println((0).max(nuggets));

  

You may also check:How to resolve the algorithm FizzBuzz step by step in the Z80 Assembly programming language
You may also check:How to resolve the algorithm Playing cards step by step in the C# programming language
You may also check:How to resolve the algorithm Bioinformatics/base count step by step in the Perl programming language
You may also check:How to resolve the algorithm Execute HQ9+ step by step in the Rust programming language
You may also check:How to resolve the algorithm Rosetta Code/Count examples step by step in the Python programming language