Skip to content
Advertisement

Diophantine Equation

that takes a number (n) as an argument and returns tuple of four numbers which are; total number of packages, the number of packages of 6 nuggets, the number of packages of 9 nuggets and the number of packages of 20 nuggets that are needed to sell n number of nuggets. If the combination of nuggets cannot be made then it returns a tuple of four zeros i.e. (0,0,0,0).

Note that there can be multiple solutions for a given n, then your solution should ensure that the smaller packages are used before the larger packages. For example, buy_nuggets(18) should return (3,3,0,0) instead of (2,0,2,0), that is 3 boxes of 6 piece nuggets over 2 boxes of nine piece.

This function has input Format Integer (n) and restrictions -10^6<=a,b,c,n<=10^6

The output format would be a tuple of 4 numbers (d,a,b,c) where

d = total number of packages
a – number of packages of 6
b – number of packages of 9
c – number of packages of 20

Any help would be great, thank you.

JavaScript

This function returns nothing, I could not find anything on the website that would help

Advertisement

Answer

I don’t know if i’m right, i think you need to call the function to see the output?

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement