How to resolve the algorithm McNuggets problem step by step in the Draco programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm McNuggets problem step by step in the Draco 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 Draco programming language
Source code in the draco programming language
proc nonrec main() void:
byte LIMIT = 100;
[LIMIT+1] bool nugget;
byte a, b, c;
for a from 0 upto LIMIT do
nugget[a] := false
od;
for a from 0 by 6 upto LIMIT do
for b from a by 9 upto LIMIT do
for c from b by 20 upto LIMIT do
nugget[c] := true
od
od
od;
a := LIMIT;
while nugget[a] do a := a - 1 od;
writeln("Maximum non-McNuggets number: ", a)
corp
You may also check:How to resolve the algorithm Plot coordinate pairs step by step in the BBC BASIC programming language
You may also check:How to resolve the algorithm Straddling checkerboard step by step in the Raku programming language
You may also check:How to resolve the algorithm Minimum positive multiple in base 10 using only 0 and 1 step by step in the Wren programming language
You may also check:How to resolve the algorithm Penney's game step by step in the Tcl programming language
You may also check:How to resolve the algorithm Vector step by step in the RPL programming language