McNuggets problem: Difference between revisions

Add ABC
(Add ABC)
(19 intermediate revisions by 12 users not shown)
Line 18:
{{trans|Python}}
 
<langsyntaxhighlight lang="11l">V nuggets = Set(0..100)
L(s, n, t) cart_product(0 .. 100 I/ 6,
0 .. 100 I/ 9,
Line 24:
nuggets.discard(6*s + 9*n + 20*t)
 
print(max(nuggets))</langsyntaxhighlight>
 
{{out}}
Line 31:
</pre>
 
=={{header|8080 Assembly}}==
<syntaxhighlight lang="asm"> org 100h
lxi h,200h ; Zero out a page to keep nugget flags
xra a
znugs: mov m,a
inr l
jnz znugs
lxi b,101 ; B = 6 stepper, C = 101 (limit)
loopa: mov d,b ; D = 9 stepper
loopb: mov l,d ; L = 20 stepper
loopc: inr m ; Mark nugget
mvi a,20 ; 20 step
add l
mov l,a
cmp c
jc loopc
mvi a,9 ; 9 step
add d
mov d,a
cmp c
jc loopb
mvi a,6 ; 6 step
add b
mov b,a
cmp c
jc loopa
mov l,c ; Find largest number not seen
scan: dcr l
dcr m
jp scan
mov a,l
mvi b,'0'-1 ; B = high digit
digit: inr b
sui 10
jnc digit
adi '0'+10 ; A = low digit
lxi h,digits+1
mov m,a ; Store digits
dcx h
mov m,b
xchg
mvi c,9 ; CP/M print string
jmp 5
digits: db 0,0,'$' ; Placeholder for output</syntaxhighlight>
{{out}}
<pre>43</pre>
=={{header|ABC}}==
<syntaxhighlight lang="abc">PUT {1..100} IN non.nuggets
 
PUT 0 IN a
WHILE a <= 100:
PUT a IN b
WHILE b <= 100:
PUT b IN c
WHILE c <= 100:
IF c in non.nuggets:
REMOVE c FROM non.nuggets
PUT c+20 IN c
PUT b+9 IN b
PUT a+6 IN a
 
WRITE "Maximum non-McNuggets number:", max non.nuggets/</syntaxhighlight>
{{out}}
<pre>Maximum non-McNuggets number: 43</pre>
=={{header|Action!}}==
<langsyntaxhighlight Actionlang="action!">PROC Main()
BYTE x,y,z,n
BYTE ARRAY nuggets(101)
Line 67 ⟶ 131:
FI
OD
RETURN</langsyntaxhighlight>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/McNuggets_problem.png Screenshot from Atari 8-bit computer]
Line 75 ⟶ 139:
 
=={{header|Ada}}==
<langsyntaxhighlight Adalang="ada">with Ada.Text_IO; use Ada.Text_IO;
 
procedure McNugget is
Line 98 ⟶ 162:
end if;
end loop;
end McNugget;</langsyntaxhighlight>
{{out}}
<pre>
Line 105 ⟶ 169:
 
=={{header|ALGOL 68}}==
<langsyntaxhighlight lang="algol68">BEGIN
# Solve the McNuggets problem: find the largest n <= 100 for which there #
# are no non-negative integers x, y, z such that 6x + 9y + 20z = n #
Line 126 ⟶ 190:
)
)
END</langsyntaxhighlight>
{{out}}
<pre>
Line 134 ⟶ 198:
=={{header|APL}}==
{{works with|Dyalog APL}}
<langsyntaxhighlight APLlang="apl">100 (⌈/(⍳⊣)~(⊂⊢)(+/×)¨(,⎕IO-⍨(⍳∘⌊÷))) 6 9 20</langsyntaxhighlight>
{{out}}
<pre>43</pre>
Line 141 ⟶ 205:
Generalised for other set sizes, and for other triples of natural numbers.
Uses NSMutableSet, through the AppleScript ObjC interface:
<langsyntaxhighlight lang="applescript">use AppleScript version "2.4"
use framework "Foundation"
use scripting additions
Line 317 ⟶ 381:
on setMember(x, objcSet)
missing value is not (objcSet's member:(x))
end setMember</langsyntaxhighlight>
{{Out}}
<pre>43</pre>
Line 323 ⟶ 387:
=={{header|Arturo}}==
{{trans|Ruby}}
<langsyntaxhighlight lang="rebol">nonMcNuggets: function [lim][
result: new 0..lim
 
Line 336 ⟶ 400:
]
 
print max nonMcNuggets 100</langsyntaxhighlight>
 
{{out}}
 
<pre>46</pre>
 
=={{header|Asymptote}}==
<syntaxhighlight lang="Asymptote">bool[] n;
for(int i = 0; i <= 100; ++i) { n[i] = false; }
int k;
 
for (int a = 0; a < 100/6; ++a) {
for (int b = 0; b < 100/9; ++b) {
for (int c = 0; c < 100/20; ++c) {
k = a*6 + b*9 + c*20;
if (k <= 100) { n[k] = true; }
}
}
}
 
for (int k = 100; k >= 0; --k) {
if (n[k] != true) {
write("Maximum non-McNuggets number is: ", k);
break;
}
}</syntaxhighlight>
{{out}}
<pre>Maximum non-McNuggets number is: 43</pre>
 
=={{header|AWK}}==
<syntaxhighlight lang="awk">
<lang AWK>
# syntax: GAWK -f MCNUGGETS_PROBLEM.AWK
# converted from Go
Line 363 ⟶ 450:
exit(0)
}
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 370 ⟶ 457:
 
=={{header|BASIC}}==
<langsyntaxhighlight lang="basic">10 DEFINT A-Z: DIM F(100)
20 FOR A=0 TO 100 STEP 6
30 FOR B=A TO 100 STEP 9
Line 378 ⟶ 465:
70 FOR A=100 TO 0 STEP -1
80 IF NOT F(A) THEN PRINT A: END
90 NEXT A</langsyntaxhighlight>
{{out}}
<pre> 43</pre>
 
==={{header|Applesoft BASIC}}===
{{works with|Chipmunk Basic|3.6.4}}
<syntaxhighlight lang="qbasic">100 dim nuggets(100)
110 for six = 0 to 100/6
120 for nine = 0 to 100/9
130 for twenty = 0 to 100/20
140 n = six*6+nine*9+twenty*20
150 if n <= 100 then nuggets(n) = 1
160 next twenty
170 next nine
180 next six
190 for n = 100 to 1 step -1
200 if nuggets(n) <> 1 then print "Maximum non-McNuggets number is: ";n : goto 250
240 next n
250 end</syntaxhighlight>
{{out}}
<pre>Maximum non-McNuggets number is: 43</pre>
 
==={{header|BASIC256}}===
<syntaxhighlight lang="vb">arraybase 1
dim nuggets(100)
 
for six = 0 To 100/6
for nine = 0 To 100/9
for twenty = 0 To 100/20
n = six*6 + nine*9 + twenty*20
if n <= 100 then nuggets[n] = true
next twenty
next nine
next six
 
for n = 100 to 1 step -1
if nuggets[n] = false then
print "Maximum non-McNuggets number is: "; n
exit for
end if
next n</syntaxhighlight>
{{out}}
<pre>Maximum non-McNuggets number is: 43</pre>
 
==={{header|Chipmunk Basic}}===
{{works with|Chipmunk Basic|3.6.4}}
<syntaxhighlight lang="qbasic">100 dim nuggets(100)
110 for six = 0 to 100/6
120 for nine = 0 to 100/9
130 for twenty = 0 to 100/20
140 n = six*6+nine*9+twenty*20
150 if n <= 100 then nuggets(n) = 1
160 next twenty
170 next nine
180 next six
190 for n = 100 to 1 step -1
200 if nuggets(n) <> 1 then
210 print "Maximum non-McNuggets number is: ";n
220 end
230 endif
240 next n
250 end</syntaxhighlight>
{{out}}
<pre>Maximum non-McNuggets number is: 43</pre>
 
==={{header|Gambas}}===
<syntaxhighlight lang="vbnet">Public l[101] As Integer
 
Public Sub Main()
Dim a As Integer, b As Integer, c As Integer, n As Integer
For a = 0 To 100 / 6
For b = 0 To 100 / 9
For c = 0 To 100 / 20
n = a * 6 + b * 9 + c * 20
If n <= 100 Then l[n] = True
Next
Next
Next
For n = 100 To 1 Step -1
If Not l[n] Then
Print "Maximum non-McNuggets number is: "; n
Break
End If
Next
End</syntaxhighlight>
{{out}}
<pre>Maximum non-McNuggets number is: 43</pre>
 
==={{header|GW-BASIC}}===
The [[#Chipmunk Basic|Chipmunk Basic]] solution works without any changes.
 
==={{header|Minimal BASIC}}===
{{works with|QBasic}}
{{works with|QuickBasic}}
{{works with|Applesoft BASIC}}
{{works with|BASICA}}
{{works with|Chipmunk Basic}}
{{works with|GW-BASIC}}
{{works with|MSX BASIC}}
{{works with|Quite BASIC}}
<syntaxhighlight lang="qbasic">10 DIM N(100) : rem 10 ARRAY N for Quite BASIC
20 FOR A = 0 TO 100/6
30 FOR B = 0 TO 100/9
40 FOR C = 0 TO 100/20
50 LET K = A*6+B*9+C*20
60 IF K <= 100 THEN 80
70 GOTO 90
80 LET N(K) = 1
90 NEXT C
100 NEXT B
110 NEXT A
120 FOR K = 100 TO 1 STEP -1
130 IF N(K) <> 1 THEN 160
140 NEXT K
150 STOP
160 PRINT "Maximum non-McNuggets number is: "; K
170 END</syntaxhighlight>
{{out}}
<pre>Maximum non-McNuggets number is: 43</pre>
 
==={{header|MSX Basic}}===
{{works with|MSX BASIC|any}}
The [[#Minimal BASIC|Minimal BASIC]] solution works without any changes.
 
==={{header|PureBasic}}===
<syntaxhighlight lang="purebasic">OpenConsole()
Define n.i
Dim nuggets.i(100)
 
For six.i = 0 To 100/6
For nine.i = 0 To 100/9
For twenty.i = 0 To 100/20
n = six*6 + nine*9 + twenty*20
If n <= 100
nuggets(n) = #True
EndIf
Next twenty
Next nine
Next six
 
For n = 100 To 1 Step -1
If nuggets(n) = #False
PrintN("Maximum non-McNuggets number is: " + Str(n))
Break
EndIf
Next n
 
PrintN(#CRLF$ + "Press ENTER to exit"): Input()
CloseConsole()</syntaxhighlight>
{{out}}
<pre>Maximum non-McNuggets number is: 43</pre>
 
==={{header|Quite BASIC}}===
The [[#Minimal BASIC|Minimal BASIC]] solution works without any changes.
 
==={{header|Run BASIC}}===
{{works with|Just BASIC}}
{{works with|Liberty BASIC}}
<syntaxhighlight lang="vb">dim nuggets(100)
 
for six = 0 to 100/6
for nine = 0 to 100/9
for twenty = 0 to 100/20
n = six*6 + nine*9 + twenty*20
if n <= 100 then nuggets(n) = 1
next twenty
next nine
next six
 
for n = 100 to 1 step -1
if nuggets(n) <> 1 then
print "Maximum non-McNuggets number is: "; n
end
end if
next n</syntaxhighlight>
{{out}}
<pre>Maximum non-McNuggets number is: 43</pre>
 
==={{header|True BASIC}}===
<syntaxhighlight lang="qbasic">OPTION BASE 0
DIM nuggets(100)
FOR n = 0 TO 100
LET nuggets(n) = 0
NEXT n
 
FOR six = 0 TO 100/6
FOR nine = 0 TO 100/9
FOR twenty = 0 TO 100/20
LET n = six*6 + nine*9 + twenty*20
IF n <= 100 THEN LET nuggets(n) = 1
NEXT twenty
NEXT nine
NEXT six
 
FOR n = 100 TO 1 STEP -1
IF nuggets(n) <> 1 THEN
PRINT "Maximum non-McNuggets number is: "; n
EXIT FOR
END IF
NEXT n
END</syntaxhighlight>
 
==={{header|XBasic}}===
{{works with|Windows XBasic}}
<syntaxhighlight lang="qbasic">PROGRAM "McNuggets problem"
VERSION "0.0000"
 
DECLARE FUNCTION Entry ()
 
FUNCTION Entry ()
DIM N[100]
 
FOR A = 0 TO 100/6
FOR B = 0 TO 100/9
FOR C = 0 TO 100/20
K = A*6+B*9+C*20
IF K <= 100 THEN N[K] = 1
NEXT C
NEXT B
NEXT A
 
FOR K = 100 TO 1 STEP -1
IF N[K] <> 1 THEN PRINT "Maximum non-McNuggets number is: "; K : EXIT FOR
NEXT K
 
END FUNCTION
END PROGRAM</syntaxhighlight>
{{out}}
<pre>Maximum non-McNuggets number is: 43</pre>
 
==={{header|Yabasic}}===
<syntaxhighlight lang="vb">dim nuggets(100)
 
for six = 0 to 100/6
for nine = 0 to 100/9
for twenty = 0 to 100/20
n = six*6 + nine*9 + twenty*20
if n <= 100 nuggets(n) = true
next twenty
next nine
next six
 
for n = 100 to 1 step -1
if nuggets(n) = false then
print "Maximum non-McNuggets number is: ", n
break
end if
next n</syntaxhighlight>
{{out}}
<pre>Maximum non-McNuggets number is: 43</pre>
 
=={{header|BCPL}}==
<langsyntaxhighlight lang="bcpl">get "libhdr"
manifest $( limit = 100 $)
 
Line 400 ⟶ 737:
finish
$)
$)</langsyntaxhighlight>
{{out}}
<pre>Maximum non-McNuggets number: 43.</pre>
 
=={{header|BQN}}==
<langsyntaxhighlight lang="bqn">100 ((↕⊣)(⌈´⊣×⊣¬∘∊⥊∘⊢)(<⊢)(+´×)¨(↕⌊∘÷)) 6‿9‿20</langsyntaxhighlight>
{{out}}
<pre>43</pre>
Line 411 ⟶ 748:
=={{header|C}}==
 
<langsyntaxhighlight lang="c">#include <stdio.h>
 
int
Line 445 ⟶ 782:
 
return 0;
}</langsyntaxhighlight>
 
{{out}}
Line 453 ⟶ 790:
 
=={{header|C sharp|C#}}==
<syntaxhighlight lang="c#">
<lang c#>
using System;
 
Line 487 ⟶ 824:
}
}
</syntaxhighlight>
</lang>
{{out}}
<pre>
Largest non-McNuggett Number less than 100: 43
</pre>
 
=={{header|C++}}==
<syntaxhighlight lang="c++">
#include <cstdint>
#include <iostream>
#include <vector>
 
void mcnuggets(int32_t limit) {
std::vector<bool> mcnuggets_numbers(limit + 1, false);
for ( int32_t small = 0; small <= limit; small += 6 ) {
for ( int32_t medium = small; medium <= limit; medium += 9 ) {
for ( int32_t large = medium; large <= limit; large += 20 ) {
mcnuggets_numbers[large] = true;
}
}
}
 
for ( int32_t i = limit; i >= 0; --i ) {
if ( ! mcnuggets_numbers[i] ) {
std::cout << "Maximum non-McNuggets number is " << i << std::endl;
return;
}
}
}
 
int main() {
mcnuggets(100);
}
</syntaxhighlight>
{{ out }}
<pre>
Maximum non-McNuggets number is 43
</pre>
 
=={{header|Clojure}}==
<langsyntaxhighlight lang="clojure">(defn cart [colls]
(if (empty? colls)
'(())
Line 505 ⟶ 875:
(let [possible (distinct (map nuggets (cart (map range [18 13 6]))))
mcmax (apply max (filter (fn [x] (not-any? #{x} possible)) (range 101)))]
(printf "Maximum non-McNuggets number is %d\n" mcmax))</langsyntaxhighlight>
{{out}}
<pre>Maximum non-McNuggets number is 43</pre>
 
=={{header|CLU}}==
<langsyntaxhighlight lang="clu">% Recursive nugget iterator.
% This yields all the nugget numbers of the given box sizes from start to max.
gen_nuggets = iter (start, max: int, sizes: sequence[int]) yields (int)
Line 541 ⟶ 911:
stream$putl(po, "Maximum non-McNuggets number: " || int$unparse(maxn))
end start_up</langsyntaxhighlight>
{{out}}
<pre>Maximum non-McNuggets number: 43</pre>
 
=={{header|COBOL}}==
<langsyntaxhighlight lang="cobol"> IDENTIFICATION DIVISION.
PROGRAM-ID. MCNUGGETS.
 
Line 580 ⟶ 950:
C-LOOP.
IF C IS NOT EQUAL TO ZERO, MOVE 'X' TO NUGGET-FLAGS(C).</langsyntaxhighlight>
{{out}}
<pre>Largest non-McNugget number: 043</pre>
 
=={{header|Comal}}==
<langsyntaxhighlight lang="comal">0010 limit#:=100
0020 DIM nugget#(0:limit#)
0030 FOR a#:=0 TO limit# STEP 6 DO
Line 597 ⟶ 967:
0110 END
0120 ENDIF
0130 ENDFOR i#</langsyntaxhighlight>
{{out}}
<pre>Maximum non-McNuggets number: 43</pre>
 
=={{header|Cowgol}}==
<langsyntaxhighlight lang="cowgol">include "cowgol.coh";
const LIMIT := 100;
 
Line 635 ⟶ 1,005:
end if;
a := a - 1;
end loop;</langsyntaxhighlight>
{{out}}
<pre>Maximum non-McNuggets number: 43</pre>
 
=={{header|Dart}}==
<langsyntaxhighlight lang="dart">import 'dart:math';
main() {
var nuggets = List<int>.generate(101, (int index) => index);
Line 651 ⟶ 1,021:
}
print('Largest non-McNuggets number: ${nuggets.reduce(max).toString() ?? 'none'}.');
}</langsyntaxhighlight>
 
{{out}}
Line 658 ⟶ 1,028:
 
=={{header|Draco}}==
<langsyntaxhighlight lang="draco">proc nonrec main() void:
byte LIMIT = 100;
[LIMIT+1] bool nugget;
Line 678 ⟶ 1,048:
while nugget[a] do a := a - 1 od;
writeln("Maximum non-McNuggets number: ", a)
corp</langsyntaxhighlight>
{{out}}
<pre>Maximum non-McNuggets number: 43</pre>
Line 686 ⟶ 1,056:
{{trans|Go}}
 
<langsyntaxhighlight lang="dyalect">func mcnugget(limit) {
var sv = Array.Empty(limit + 1, false)
for s in 0^6..limit {
Line 703 ⟶ 1,073:
}
mcnugget(100)</langsyntaxhighlight>
 
{{out}}
 
<pre>Maximum non-McNuggets number is 43</pre>
 
=={{header|EasyLang}}==
{{trans|FreeBASIC}}
<syntaxhighlight>
len l[] 100
for a = 0 to 100 div 6
for b = 0 to 100 div 9
for c = 0 to 100 div 20
n = a * 6 + b * 9 + c * 20
if n >= 1 and n <= 100
l[n] = 1
.
.
.
.
for n = 100 downto 1
if l[n] = 0
print n
break 1
.
.
</syntaxhighlight>
 
 
=={{header|Elixir}}==
Line 713 ⟶ 1,106:
Uses MapSet and Comprehension
 
<langsyntaxhighlight Elixirlang="elixir">defmodule Mcnugget do
def solve(limit) do
0..limit
Line 735 ⟶ 1,128:
 
Mcnugget.solve(100) |> IO.puts
</syntaxhighlight>
</lang>
 
{{out}}
Line 742 ⟶ 1,135:
 
=={{header|F_Sharp|F#}}==
<langsyntaxhighlight lang="fsharp">
// McNuggets. Nigel Galloway: October 28th., 2018
let fN n g = Seq.initInfinite(fun ng->ng*n+g)|>Seq.takeWhile(fun n->n<=100)
printfn "%d" (Set.maxElement(Set.difference (set[1..100]) (fN 20 0|>Seq.collect(fun n->fN 9 n)|>Seq.collect(fun n->fN 6 n)|>Set.ofSeq)))
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 753 ⟶ 1,146:
 
=={{header|Factor}}==
<langsyntaxhighlight lang="factor">USING: backtrack kernel math.ranges prettyprint sequences sets ;
101 <iota> [ 0 6 9 20 [ 100 swap <range> amb-lazy ] tri@ ] bag-of diff last .</langsyntaxhighlight>
{{out}}
<pre>
Line 761 ⟶ 1,154:
 
=={{header|FOCAL}}==
<langsyntaxhighlight lang="focal">01.10 F N=0,100;S T(N)=0
01.20 F A=0,6,100;F B=A,9,100;F C=B,20,100;S T(C)=-1
01.30 S N=101
Line 767 ⟶ 1,160:
01.50 I (T(N))1.4
01.60 T %3,N,!
01.70 Q</langsyntaxhighlight>
{{out}}
<pre>= 43</pre>
 
=={{header|FreeBASIC}}==
<langsyntaxhighlight lang="freebasic">
Dim As Integer l(100), a, b, c, n
For a = 0 To 100/6
Line 786 ⟶ 1,179:
Next n
End
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 793 ⟶ 1,186:
 
=={{header|Frink}}==
This is a nice demonstration for Frink's <CODE>multifor</CODE> loop which can perform arbitrarily-deeply-nested loops in a single statement. The "inner" (rightmost) loops can use values set by the "outer" (leftmost) as part of their bounds.
<langsyntaxhighlight lang="frink">a = toSet[0 to 100]
 
multifor [z,y,x] = [0 to 100 step 20, 0 to 100-z step 9, 0 to 100-z-y step 6]
a.remove[x+y+z]
 
println[max[a]]</langsyntaxhighlight>
{{out}}
<pre>
Line 806 ⟶ 1,199:
 
=={{header|FutureBasic}}==
<langsyntaxhighlight lang="futurebasic">
local fn McNuggetsProblem
BOOL l(100)
Line 828 ⟶ 1,221:
 
HandleEvents
</syntaxhighlight>
</lang>
{{output}}
<pre>
Line 842 ⟶ 1,235:
 
=={{header|Go}}==
<langsyntaxhighlight lang="go">package main
 
import "fmt"
Line 865 ⟶ 1,258:
func main() {
mcnugget(100)
}</langsyntaxhighlight>
 
{{out}}
Line 873 ⟶ 1,266:
 
=={{header|Haskell}}==
<langsyntaxhighlight lang="haskell">import Data.Set (Set, fromList, member)
 
------------------------ MCNUGGETS -----------------------
gaps :: [Int]
gaps = dropWhile (`member` mcNuggets) [100,99 .. 1]
 
mcNuggets :: Set Int
mcNuggets =
let size = enumFromTo 0 . quot 100
in fromList $
size 6 >>=
>>= \x ->
size 9 >>=
>>= \y ->
size 20 >>=
>>= \z ->
let v = sum [6 * x,[ 9 * y, 20 * z]v
in [ | let v = sum [6 * x, 9 * y, 20 * z],
| 101 > v ]
]
 
--------------------------- TEST -------------------------
main :: IO ()
main =
print(putStrLn . go) $
dropWhile (`member` mcNuggets) [100, 99 .. 1]
case gaps of
where
x:_ -> show x
go (x : _) = show x
[] -> "No unreachable quantities found ..."</lang>
go [] = "No unreachable quantities found ..."</syntaxhighlight>
 
Or equivalently, making use of the list comprehension notation:
<langsyntaxhighlight lang="haskell">import Data.Set (Set, fromList, member)
 
gaps :: [Int]
Line 921 ⟶ 1,316:
case gaps of
x:_ -> show x
[] -> "No unreachable quantities found ..."</langsyntaxhighlight>
<pre>43</pre>
 
Line 928 ⟶ 1,323:
Brute force solution: calculate all pure (just one kind of box) McNugget numbers which do not exceed 100, then compute all possible sums, and then remove those from the list of numbers up to 100 (which is obviously a McNugget number), then find the largest number remaining:
 
<langsyntaxhighlight Jlang="j"> >./(i.100)-.,+/&>{(* i.@>.@%~&101)&.>6 9 20
43</langsyntaxhighlight>
 
Technically, we could have used 100 in place of 101 when we were finding how many pure McNugget numbers were in each series (because 100 is obviously a McNugget number), but it's not like that's a problem, either.
 
=={{header|Java}}==
<langsyntaxhighlight Javalang="java">public class McNuggets {
 
public static void main(String... args) {
Line 988 ⟶ 1,383:
return;
}
}</langsyntaxhighlight>
{{Out}}
<pre>Largest non-McNugget number in the search space is 43</pre>
 
=={{header|JavaScript}}==
<langsyntaxhighlight lang="javascript">(() => {
'use strict';
 
Line 1,072 ⟶ 1,467:
main()
);
})();</langsyntaxhighlight>
{{Out}}
<pre>43</pre>
Line 1,078 ⟶ 1,473:
=={{header|jq}}==
{{trans|Clojure}}
<langsyntaxhighlight lang="jq">[
[range(18) as $n6 |
range(13) as $n9 |
Line 1,089 ⟶ 1,484:
select($possible|contains([$n])|not)
] |
max</langsyntaxhighlight>
{{out}}
<pre>43</pre>
Line 1,095 ⟶ 1,490:
=={{header|Julia}}==
Simple brute force solution, though the BitSet would save memory considerably with larger max numbers.
<langsyntaxhighlight lang="julia">function mcnuggets(max)
b = BitSet(1:max)
for i in 0:6:max, j in 0:9:max, k in 0:20:max
Line 1,104 ⟶ 1,499:
 
println(mcnuggets(100))
</langsyntaxhighlight> {{output}} <pre>
43
</pre>
Line 1,110 ⟶ 1,505:
=={{header|Kotlin}}==
{{trans|Go}}
<langsyntaxhighlight lang="scala">// Version 1.2.71
 
fun mcnugget(limit: Int) {
Line 1,128 ⟶ 1,523:
fun main(args: Array<String>) {
mcnugget(100)
}</langsyntaxhighlight>
 
{{output}}
Line 1,136 ⟶ 1,531:
 
=={{header|Locomotive Basic}}==
<langsyntaxhighlight lang="locobasic">100 CLEAR
110 DIM a(100)
120 FOR a=0 TO 100/6
Line 1,150 ⟶ 1,545:
220 NEXT n
230 PRINT"The Largest non McNugget number is:";l
240 END</langsyntaxhighlight>
 
{{output}}
Line 1,156 ⟶ 1,551:
 
=={{header|Lua}}==
<langsyntaxhighlight lang="lua">
function range(A,B)
return function()
Line 1,229 ⟶ 1,624:
 
print(maximum(exclude(sum, range(1, N))))
</syntaxhighlight>
</lang>
{{out}}
<pre>
43
</pre>
 
=={{header|MACRO-11}}==
<syntaxhighlight lang="macro11"> .TITLE NUGGET
.MCALL .TTYOUT,.EXIT
NUGGET::MOV #^D50,R1
MOV #NUGBUF,R0
CLEAR: CLR (R0)+ ; CLEAR BUFFER
SOB R1,CLEAR
MARK: MOV #^D100,R5 ; R5 = LIMIT
CLR R0 ; R0 = 6 STEPPER
1$: MOV R0,R1 ; R1 = 9 STEPPER
2$: MOV R1,R2 ; R2 = 20 STEPPER
3$: INCB NUGBUF(R2) ; MARK
ADD #^D20,R2 ; 20 STEP
CMP R2,R5
BLT 3$
ADD #^D9,R1 ; 9 STEP
CMP R1,R5
BLT 2$
ADD #^D6,R0 ; 6 STEP
CMP R0,R5
BLT 1$
SCAN: MOV #NUGBUF+^D100,R0
1$: DEC R5
MOVB -(R0),R1
BNE 1$
DIGIT: MOV #'0-1,R0 ; SPLIT DIGITS
1$: INC R0
SUB #^D10,R5
BCC 1$
.TTYOUT ; HIGH DIGIT
MOV R5,R0
ADD #'0+^D10,R0
.TTYOUT ; LOW DIGIT
.EXIT
NUGBUF: .BLKB ^D100
.END NUGGET</syntaxhighlight>
{{out}}
<pre>43</pre>
 
=={{header|MAD}}==
<langsyntaxhighlight lang="mad"> NORMAL MODE IS INTEGER
BOOLEAN NUGGET
DIMENSION NUGGET(101)
Line 1,252 ⟶ 1,686:
PRINT FORMAT F, I
VECTOR VALUES F = $29HMAXIMUM NON-MCNUGGET NUMBER: ,I2*$
END OF PROGRAM </langsyntaxhighlight>
{{out}}
<pre>MAXIMUM NON-MCNUGGET NUMBER: 43</pre>
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<langsyntaxhighlight lang="mathematica">FrobeniusNumber[{6, 9, 20}]</langsyntaxhighlight>
{{out}}
<pre>43</pre>
 
=={{header|Modula-2}}==
<langsyntaxhighlight lang="modula2">MODULE McNuggets;
FROM InOut IMPORT WriteCard, WriteString, WriteLn;
 
Line 1,287 ⟶ 1,721:
WriteCard(a, 2);
WriteLn();
END McNuggets.</langsyntaxhighlight>
{{out}}
<pre>Maximum non-McNuggets number: 43</pre>
 
=={{header|MiniScript}}==
<syntaxhighlight lang="miniscript">
n = range(0, 100)
for six in range(0, 100, 6)
for nine in range(0, 100, 9)
for twenty in range(0, 100, 20)
mcnuggets = six + nine + twenty
ix = n.indexOf(mcnuggets)
if ix != null then n.remove(ix)
end for
end for
end for
 
print "The largest non-McNugget number is " + n[-1]
</syntaxhighlight>
{{out}}
<pre>
The largest non-McNugget number is 43</pre>
 
=={{header|MiniZinc}}==
<syntaxhighlight lang="minizinc">
<lang MiniZinc>
%McNuggets. Nigel Galloway, August 27th., 2019
var 0..99: n;
Line 1,298 ⟶ 1,751:
solve maximize n;
output [show(n)]
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 1,307 ⟶ 1,760:
 
=={{header|Nim}}==
<langsyntaxhighlight Nimlang="nim">const Limit = 100
 
var mcnuggets: array[0..Limit, bool]
Line 1,319 ⟶ 1,772:
if not mcnuggets[n]:
echo "The largest non-McNuggets number is: ", n
break</langsyntaxhighlight>
 
{{out}}
<pre>The largest non-McNuggets number is: 43</pre>
 
=={{header|Pascal}}==
A console program in Free Pascal. Same idea as the Raku solution, but without generalizing. We stop once we've found 6 consecutive integers that can be represented.
<syntaxhighlight lang="pascal">
program McNuggets;
 
{$mode objfpc}{$H+}
 
const
ARRAY_SIZE_STEP = 20; // small, to demonstrate extending array dynamically
var
i, nr_consec : integer;
can_do : array of boolean;
begin
SetLength( can_do, ARRAY_SIZE_STEP);
can_do[0] := true;
nr_consec := 0;
i := 0;
repeat
inc(i);
if i >= Length( can_do) then SetLength( can_do, i + ARRAY_SIZE_STEP);
can_do[i] := ((i >= 6) and can_do[i - 6])
or ((i >= 9) and can_do[i - 9])
or ((i >= 20) and can_do[i - 20]);
if can_do[i] then begin
if can_do[i - 1] then inc( nr_consec)
else nr_consec := 1;
end
else nr_consec := 0;
until nr_consec = 6;
WriteLn ('Max that can''t be represented is ', i - 6);
end.
</syntaxhighlight>
{{out}}
<pre>
Max that can't be represented is 43
</pre>
 
=={{header|Perl}}==
{{trans|Raku}}
{{libheader|ntheory}}
<langsyntaxhighlight lang="perl">use ntheory qw/forperm gcd vecmin/;
 
sub Mcnugget_number {
Line 1,369 ⟶ 1,859:
for my $counts ([6,9,20], [6,7,20], [1,3,20], [10,5,18], [5,17,44], [2,4,6], [3,6,15]) {
print 'Maximum non-Mcnugget number using ' . join(', ', @$counts) . ' is: ' . Mcnugget_number($counts) . "\n"
}</langsyntaxhighlight>
{{out}}
<pre>Maximum non-Mcnugget number using 6, 9, 20 is: 43
Line 1,380 ⟶ 1,870:
 
===Perl using Regex===
<langsyntaxhighlight Perllang="perl">use strict;
use warnings;
 
$_ = 1 . 0 x 100;
1 while s/ (?=1) (?:.{6}|.{9}|.{20}) \K 0 /1/x;
/01*$/ and print "Maximum non-Mcnugget number is: $-[0]\n";</langsyntaxhighlight>
{{out}}
<pre>Maximum non-Mcnugget number is: 43</pre>
Line 1,391 ⟶ 1,881:
=={{header|Phix}}==
{{trans|Go}}
<!--<langsyntaxhighlight Phixlang="phix">(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">constant</span> <span style="color: #000000;">limit</span><span style="color: #0000FF;">=</span><span style="color: #000000;">100</span>
Line 1,403 ⟶ 1,893:
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Maximum non-McNuggets number is %d\n"</span><span style="color: #0000FF;">,</span> <span style="color: #7060A8;">rfind</span><span style="color: #0000FF;">(</span><span style="color: #004600;">false</span><span style="color: #0000FF;">,</span><span style="color: #000000;">nuggets</span><span style="color: #0000FF;">)-</span><span style="color: #000000;">1</span><span style="color: #0000FF;">)</span>
<!--</langsyntaxhighlight>-->
{{out}}
<pre>
Line 1,410 ⟶ 1,900:
Also, since it is a bit more interesting, a
{{trans|Raku}}
<!--<langsyntaxhighlight Phixlang="phix">(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">function</span> <span style="color: #000000;">Mcnugget_number</span><span style="color: #0000FF;">(</span><span style="color: #004080;">sequence</span> <span style="color: #000000;">counts</span><span style="color: #0000FF;">)</span>
Line 1,455 ⟶ 1,945:
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Maximum non-Mcnugget number using %V is: %s\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">ti</span><span style="color: #0000FF;">,</span><span style="color: #000000;">Mcnugget_number</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ti</span><span style="color: #0000FF;">)})</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<!--</langsyntaxhighlight>-->
{{out}}
<pre>
Line 1,469 ⟶ 1,959:
=={{header|Picat}}==
Using constraint modelling (cp solver).
<langsyntaxhighlight Picatlang="picat">import cp.
 
go =>
Line 1,477 ⟶ 1,967:
end,
solve($[max(N)],N),
println(n=N).</langsyntaxhighlight>
 
{{out}}
Line 1,483 ⟶ 1,973:
 
=={{header|PicoLisp}}==
<langsyntaxhighlight PicoLisplang="picolisp">(de nuggets1 (M)
(let Lst (range 0 M)
(for A (range 0 M 6)
Line 1,489 ⟶ 1,979:
(for C (range B M 20)
(set (nth Lst (inc C))) ) ) )
(apply max Lst) ) )</langsyntaxhighlight>
Generator from fiber:
<langsyntaxhighlight PicoLisplang="picolisp">(de nugg (M)
(co 'nugget
(for A (range 0 M 6)
Line 1,501 ⟶ 1,991:
(while (nugg 100)
(set (nth Lst @)) )
(apply max Lst) ) )</langsyntaxhighlight>
Test versions against each other:
<langsyntaxhighlight PicoLislang="picolis">(test
T
(=
43
(nuggets1 100)
(nuggets2 100) ) )</langsyntaxhighlight>
 
=={{header|PL/I}}==
<langsyntaxhighlight lang="pli">mcnugget: procedure options(main);
declare nugget(0:100) bit, (a, b, c) fixed;
do a=0 to 100; nugget(a) = '0'b; end;
Line 1,529 ⟶ 2,019:
end;
end;
end mcnugget;</langsyntaxhighlight>
{{out}}
<pre>Maximum non-McNuggets number: 43</pre>
 
=={{header|PL/M}}==
<langsyntaxhighlight lang="plm">100H:
BDOS: PROCEDURE (FN, ARG); DECLARE FN BYTE, ARG ADDRESS; GO TO 5; END BDOS;
EXIT: PROCEDURE; CALL BDOS(0,0); END EXIT;
Line 1,567 ⟶ 2,057:
CALL PRINT$NUMBER(A);
CALL EXIT;
EOF</langsyntaxhighlight>
{{out}}
<pre>43</pre>
Line 1,573 ⟶ 2,063:
=={{header|PowerShell}}==
{{trans|UNIX Shell}}
<langsyntaxhighlight lang="powershell">$possible = @{}
For ($i=0; $i -lt 18; $i++) {
For ($j=0; $j -lt 13; $j++) {
Line 1,590 ⟶ 2,080:
}
}
Write-Host "Maximum non-McNuggets number is $n"</langsyntaxhighlight>
{{out}}
<pre>Maximum non-McNuggets number is 43</pre>
Line 1,597 ⟶ 2,087:
===Python: REPL===
It's a simple solution done on the command line:
<langsyntaxhighlight lang="python">>>> from itertools import product
>>> nuggets = set(range(101))
>>> for s, n, t in product(range(100//6+1), range(100//9+1), range(100//20+1)):
Line 1,605 ⟶ 2,095:
>>> max(nuggets)
43
>>> </langsyntaxhighlight>
 
Single expression version (expect to be slower, however no noticeable difference on a Celeron B820 and haven't benchmarked):
<langsyntaxhighlight lang="python">>>> from itertools import product
>>> max(x for x in range(100+1) if x not in
... (6*s + 9*n + 20*t for s, n, t in
... product(range(100//6+1), range(100//9+1), range(100//20+1))))
43
>>> </langsyntaxhighlight>
 
===Using Set Comprehension===
{{trans|FSharp}}
<langsyntaxhighlight 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)))
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 1,634 ⟶ 2,124:
 
{{Works with|Python|3.7}}
<langsyntaxhighlight lang="python">'''mcNuggets list monad'''
 
from itertools import (chain, dropwhile)
Line 1,760 ⟶ 2,250:
# MAIN ---
if __name__ == '__main__':
main()</langsyntaxhighlight>
{{Out}}
<pre>
Line 1,769 ⟶ 2,259:
 
=={{header|Quackery}}==
<langsyntaxhighlight Quackerylang="quackery">0 temp put
100 6 / times
[ i 6 *
Line 1,794 ⟶ 2,284:
[ say "The largest non-McNugget number below 101 is "
echo ]
char . emit</langsyntaxhighlight>
 
'''Output:'''
Line 1,803 ⟶ 2,293:
 
There are two natural approaches. The first is to generate all valid x, y, and z and then apply the function:
<langsyntaxhighlight lang="rsplus">allInputs <- expand.grid(x = 0:(100 %/% 6), y = 0:(100 %/% 9), z = 0:(100 %/% 20))
mcNuggets <- do.call(function(x, y, z) 6 * x + 9 * y + 20 * z, allInputs)</langsyntaxhighlight>
The second is to find all of the valid 6x, 9y, and 20z, and then sum them:
<langsyntaxhighlight lang="rsplus">mcNuggets2 <- rowSums(expand.grid(seq(0, 100, 6), seq(0, 100, 9), seq(0, 100, 20)))</langsyntaxhighlight>
Either way, we get identical results, as checked by:
<langsyntaxhighlight lang="rsplus">all(mcNuggets == mcNuggets2)</langsyntaxhighlight>
For our final answer, note that our choice to remove values from the vector 0:100 means our outputs will already be sorted, unique, and no greater than 100.
<langsyntaxhighlight lang="rsplus">results <- setdiff(0:100, mcNuggets)
cat("The non-McNuggets numbers that are no greater than 100 are:", results, "\nThe largest is", max(results), "\n")</langsyntaxhighlight>
Ultimately, this can be done in one line:
<langsyntaxhighlight lang="rsplus">max(setdiff(0:100, rowSums(expand.grid(seq(0, 100, 6), seq(0, 100, 9), seq(0, 100, 20)))))</langsyntaxhighlight>
However, using seq without naming its arguments is considered bad practice. It works here, but breaking this code up is probably a better idea.
{{output}}
Line 1,827 ⟶ 2,317:
{{trans|Python}} (one of them)
 
<langsyntaxhighlight lang="racket">#lang racket
(apply max (set->list (for*/fold ((s (list->set (range 1 101))))
((x (in-range 0 101 20))
(y (in-range x 101 9))
(n (in-range y 101 6)))
(set-remove s n))))</langsyntaxhighlight>
 
=={{header|Raku}}==
Line 1,841 ⟶ 2,331:
Finds the smallest count value, then looks for the first run of consecutive count totals able to be generated, that is at least the length of the smallest count size. From then on, every number can be generated by simply adding multiples of the minimum count to each of the totals in that run.
 
<syntaxhighlight lang="raku" perl6line>sub Mcnugget-number (*@counts) {
 
return '∞' if 1 < [gcd] @counts;
Line 1,871 ⟶ 2,361:
put "Maximum non-Mcnugget number using {$counts.join: ', '} is: ",
Mcnugget-number(|$counts)
}</langsyntaxhighlight>
{{out}}
<pre>Maximum non-Mcnugget number using 6, 9, 20 is: 43
Line 1,888 ⟶ 2,378:
:* &nbsp; excludes meals that have a multiple order of nuggets
:* &nbsp; automatically computes the '''high''' value algebraically instead of using &nbsp; '''100'''.
<langsyntaxhighlight lang="rexx">/*REXX pgm solves the McNuggets problem: the largest McNugget number for given meals. */
parse arg y /*obtain optional arguments from the CL*/
if y='' | y="," then y= 6 9 20 /*Not specified? Then use the defaults*/
Line 1,932 ⟶ 2,422:
do while $\==''; parse var $ y $; y= abs(y); if y==0 then iterate
do until y==0; parse value x//y y with y x; end
end; return x</langsyntaxhighlight>
{{out|output|text=&nbsp; when using the default inputs:}}
<pre>
Line 1,941 ⟶ 2,431:
 
=={{header|Ring}}==
<langsyntaxhighlight lang="ring">
Nuggets = list(100)
 
Line 1,961 ⟶ 2,451:
ok
next
</syntaxhighlight>
</lang>
{{out}}
<pre>
Maximum non-McNuggets number is: 43
</pre>
 
=={{header|RPL}}==
{{trans|Go}}
« → limit
« { } limit 1 + + 0 CON
0 limit '''FOR''' s
s limit '''FOR''' n
n limit '''FOR''' t
t 1 + 1 PUT
20 '''STEP'''
9 '''STEP'''
6 '''STEP'''
limit
'''WHILE''' DUP2 GET '''REPEAT''' 1 - '''END'''
1 + SWAP DROP
» » '<span style="color:blue">MCNUGTS</span>' STO
We can tweak a little bit the above traduction, to benefit from latest efficient built-in functions:
{{works with|HP|49}}
« → limit
« 0 limit NDUPN →LIST
0 limit '''FOR''' s
s limit '''FOR''' n
n limit '''FOR''' t
limit t - 1 + 1 PUT
20 '''STEP'''
9 '''STEP'''
6 '''STEP'''
0 POS limit SWAP - 1 +
» » '<span style="color:blue">MCNUGTS</span>' STO
 
100 <span style="color:blue">MCNUGTS</span>
{{out}}
<pre>
1: 43
</pre>
 
=={{header|Ruby}}==
{{trans|Go}}
<langsyntaxhighlight lang="ruby">def mcnugget(limit)
sv = (0..limit).to_a
 
Line 1,983 ⟶ 2,508:
end
 
puts(mcnugget 100)</langsyntaxhighlight>
{{out}}
<pre>
Line 1,989 ⟶ 2,514:
</pre>
Generic solution, allowing for more or less then 3 portion-sizes:
<langsyntaxhighlight lang="ruby">limit = 100
nugget_portions = [6, 9, 20]
 
arrs = nugget_portions.map{|n| 0.step(limit, n).to_a }
hits = arrs.pop.product(*arrs).map(&:sum)
p ((0..limit).to_a - hits).max # => 43</langsyntaxhighlight>
 
=={{header|Rust}}==
Line 2,000 ⟶ 2,525:
Generalization of Rødseth’s Algorithm explained in [https://parramining.blogspot.com/2019/09/generalization-of-rdseths-algorithm-for.html post].
Working code: [https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=1424a910a196fb3d0e964c754fbf325c Rust playground].
<langsyntaxhighlight lang="rust">fn main() {
let test_cases = vec![
[6, 9, 20],
Line 2,088 ⟶ 2,613:
(m * y + cc) / aa
}
}</langsyntaxhighlight>
{{out}}
<pre>
Line 2,103 ⟶ 2,628:
g(6, 15, 1) = -1
</pre>
 
=={{header|SETL}}==
<syntaxhighlight lang="setl">program mcnuggets;
nuggets := +/+/ {{{ x + y + z
: x in [0, 6..100] }
: y in [0, 9..100] }
: z in [0, 20..100] };
 
print(max/{n : n in [1..100] | not n in nuggets});
end program;</syntaxhighlight>
{{out}}
<pre>43</pre>
 
=={{header|Swift}}==
 
<langsyntaxhighlight lang="swift">func maxNugget(limit: Int) -> Int {
var (max, sixes, nines, twenties, i) = (0, 0, 0, 0, 0)
 
Line 2,150 ⟶ 2,687:
}
 
print(maxNugget(limit: 100))</langsyntaxhighlight>
 
{{out}}
Line 2,157 ⟶ 2,694:
 
=={{header|Tailspin}}==
<langsyntaxhighlight lang="tailspin">
templates largestNonMcNuggetNumber
@: { largest: 0, mcNuggetNumbers: [1..$+20 -> 0] };
Line 2,168 ⟶ 2,705:
 
100 -> largestNonMcNuggetNumber -> !OUT::write
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 2,179 ⟶ 2,716:
{{works with|ksh}}
{{works with|zsh}}
<langsyntaxhighlight lang="bash">possible=()
for (( i=0; i<18; ++i )); do
for (( j=0; j<13; ++j )); do
Line 2,198 ⟶ 2,735:
done
 
printf 'Maximum non-McNuggets number is %d\n' $n</langsyntaxhighlight>
{{out}}
<pre>Maximum non-McNuggets number is 43</pre>
{{works with|sh}}
<langsyntaxhighlight lang="bash">possible=
i=0
while [ $i -lt 18 ]; do
Line 2,225 ⟶ 2,762:
break
done
echo "Maximum non-McNuggets number is $n"</langsyntaxhighlight>
{{out}}
<pre>Maximum non-McNuggets number is 43</pre>
 
=={{header|V (Vlang)}}==
{{trans|Go}}
<syntaxhighlight lang="v (vlang)">fn mcnugget(limit int) {
mut sv := []bool{len: limit+1} // all false by default
for s := 0; s <= limit; s += 6 {
Line 2,250 ⟶ 2,787:
fn main() {
mcnugget(100)
}</langsyntaxhighlight>
 
{{out}}
Line 2,257 ⟶ 2,794:
 
=={{header|VTL-2}}==
<langsyntaxhighlight VTL2lang="vtl2">10 N=0
20 :N+1)=0
30 N=N+1
Line 2,275 ⟶ 2,812:
170 #=:N+1)
180 ?="Largest non-McNuggets number: ";
190 ?=N</langsyntaxhighlight>
{{out}}
<pre>Largest non-McNuggets number: 43</pre>
Line 2,281 ⟶ 2,818:
=={{header|Wren}}==
{{trans|Go}}
<langsyntaxhighlight ecmascriptlang="wren">var mcnugget = Fn.new { |limit|
var sv = List.filled(limit+1, false)
var s = 0
Line 2,304 ⟶ 2,841:
}
 
mcnugget.call(100)</langsyntaxhighlight>
 
{{out}}
Line 2,312 ⟶ 2,849:
 
=={{header|XPL0}}==
<langsyntaxhighlight XPL0lang="xpl0">int N, A(101), X, Y, Z;
[for N:= 0 to 100 do A(N):= false;
for X:= 0 to 100/6 do
Line 2,325 ⟶ 2,862:
exit;
];
]</langsyntaxhighlight>
 
{{out}}
Line 2,332 ⟶ 2,869:
=={{header|zkl}}==
{{trans|Python}}
<langsyntaxhighlight lang="zkl">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));</langsyntaxhighlight>
{{out}}
<pre>
2,091

edits