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

Published on 12 May 2024 09:40 PM
#Jq

How to resolve the algorithm McNuggets problem step by step in the jq 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 jq programming language

Source code in the jq programming language

[
 [range(18) as $n6  |
  range(13) as $n9  |
  range(6)  as $n20 |
  ($n6 * 6 + $n9 * 9 + $n20 * 20)] |
 unique |
 . as $possible |
 range(101) |
 . as $n |
 select($possible|contains([$n])|not)
] |
max

  

You may also check:How to resolve the algorithm Anagrams step by step in the Visual Basic .NET programming language
You may also check:How to resolve the algorithm Koch curve step by step in the AutoHotkey programming language
You may also check:How to resolve the algorithm Date format step by step in the Stata programming language
You may also check:How to resolve the algorithm String append step by step in the Erlang programming language
You may also check:How to resolve the algorithm History variables step by step in the Kotlin programming language