Gold nugget storage
Clash Royale CLAN TAG#URR8PPP
up vote
5
down vote
favorite
Given a positive integer, write it as the sum of numbers, where each of them is in $kin1,9,81,tin1,2,3,...,64$. How many numbers at least are used? Shortest code win.
Samples:
Input Output Method
1 1 1
2 1 2
64 1 64
65 2 64+1
72 1 72
343 2 342+1
576 1 576
577 2 576+1
5184 1 5184
46656 9 5184+5184+5184+5184+5184+5184+5184+5184+5184
5274 2 5184+90
code-golf
|
show 5 more comments
up vote
5
down vote
favorite
Given a positive integer, write it as the sum of numbers, where each of them is in $kin1,9,81,tin1,2,3,...,64$. How many numbers at least are used? Shortest code win.
Samples:
Input Output Method
1 1 1
2 1 2
64 1 64
65 2 64+1
72 1 72
343 2 342+1
576 1 576
577 2 576+1
5184 1 5184
46656 9 5184+5184+5184+5184+5184+5184+5184+5184+5184
5274 2 5184+90
code-golf
4
Could you give slightly more detail/put into words how the input results in the output?
– Quintec
9 hours ago
2
If something requires clarification in the comments, it would be useful to edit the challenge to include that clarification
– trichoplax
9 hours ago
1
Is it basically a sort of change-making problem ? With the coins denominations being in the set1,9,81 × 1...64
?
– digEmAll
9 hours ago
1
Are you trying to minimize the number of items or number of stacks?
– fəˈnɛtɪk
9 hours ago
1
@fəˈnɛtɪk number of stacks for minecraft picture, item(numbers to be added) for the problem
– l4m2
9 hours ago
|
show 5 more comments
up vote
5
down vote
favorite
up vote
5
down vote
favorite
Given a positive integer, write it as the sum of numbers, where each of them is in $kin1,9,81,tin1,2,3,...,64$. How many numbers at least are used? Shortest code win.
Samples:
Input Output Method
1 1 1
2 1 2
64 1 64
65 2 64+1
72 1 72
343 2 342+1
576 1 576
577 2 576+1
5184 1 5184
46656 9 5184+5184+5184+5184+5184+5184+5184+5184+5184
5274 2 5184+90
code-golf
Given a positive integer, write it as the sum of numbers, where each of them is in $kin1,9,81,tin1,2,3,...,64$. How many numbers at least are used? Shortest code win.
Samples:
Input Output Method
1 1 1
2 1 2
64 1 64
65 2 64+1
72 1 72
343 2 342+1
576 1 576
577 2 576+1
5184 1 5184
46656 9 5184+5184+5184+5184+5184+5184+5184+5184+5184
5274 2 5184+90
code-golf
code-golf
edited 2 hours ago
asked 9 hours ago
l4m2
4,1991432
4,1991432
4
Could you give slightly more detail/put into words how the input results in the output?
– Quintec
9 hours ago
2
If something requires clarification in the comments, it would be useful to edit the challenge to include that clarification
– trichoplax
9 hours ago
1
Is it basically a sort of change-making problem ? With the coins denominations being in the set1,9,81 × 1...64
?
– digEmAll
9 hours ago
1
Are you trying to minimize the number of items or number of stacks?
– fəˈnɛtɪk
9 hours ago
1
@fəˈnɛtɪk number of stacks for minecraft picture, item(numbers to be added) for the problem
– l4m2
9 hours ago
|
show 5 more comments
4
Could you give slightly more detail/put into words how the input results in the output?
– Quintec
9 hours ago
2
If something requires clarification in the comments, it would be useful to edit the challenge to include that clarification
– trichoplax
9 hours ago
1
Is it basically a sort of change-making problem ? With the coins denominations being in the set1,9,81 × 1...64
?
– digEmAll
9 hours ago
1
Are you trying to minimize the number of items or number of stacks?
– fəˈnɛtɪk
9 hours ago
1
@fəˈnɛtɪk number of stacks for minecraft picture, item(numbers to be added) for the problem
– l4m2
9 hours ago
4
4
Could you give slightly more detail/put into words how the input results in the output?
– Quintec
9 hours ago
Could you give slightly more detail/put into words how the input results in the output?
– Quintec
9 hours ago
2
2
If something requires clarification in the comments, it would be useful to edit the challenge to include that clarification
– trichoplax
9 hours ago
If something requires clarification in the comments, it would be useful to edit the challenge to include that clarification
– trichoplax
9 hours ago
1
1
Is it basically a sort of change-making problem ? With the coins denominations being in the set
1,9,81 × 1...64
?– digEmAll
9 hours ago
Is it basically a sort of change-making problem ? With the coins denominations being in the set
1,9,81 × 1...64
?– digEmAll
9 hours ago
1
1
Are you trying to minimize the number of items or number of stacks?
– fəˈnɛtɪk
9 hours ago
Are you trying to minimize the number of items or number of stacks?
– fəˈnɛtɪk
9 hours ago
1
1
@fəˈnɛtɪk number of stacks for minecraft picture, item(numbers to be added) for the problem
– l4m2
9 hours ago
@fəˈnɛtɪk number of stacks for minecraft picture, item(numbers to be added) for the problem
– l4m2
9 hours ago
|
show 5 more comments
4 Answers
4
active
oldest
votes
up vote
3
down vote
Jelly, 17 bytes
64R×9;Ɗ⁺ff€¥@ŒṗẈṂ
Try it online!
-1 thanks to Jonathan Allan.
Explanation (you can't test for inputs larger than 58
over TIO):
64R×9;Ɗ⁺ff€¥@ŒṗẈṂ Arguments: x
64R [1..64]
×9;Ɗ Multiply by 9, prepend to original list
⁺ Do the above once more
Œṗ Positive integer partitions of x
¥@ Call with reversed arguments (x = partitions, y = flattened outer product)
f€ For each partition in x, keep the elements that are in y
f Keep the elements of x that have remained intact after the above
Ẉ Lengths of the remaining partitions
Ṃ Minimum
Since the output in testable area is trivial, can't quite check?
– l4m2
2 hours ago
add a comment |
up vote
2
down vote
JavaScript (ES6), 72 66 57 56 bytes
Saved 1 byte thanks to @nwellnhof
f=n=>n&&1+f(n<5184?n>64&&n%(n<576?9:n>719?81:72):n-5184)
Try it online!
@nwellnhof This would fail for several values (576, 632, 633, ...)
– Arnauld
4 hours ago
I see. Butf=n=>n&&1+f(n<5184?n>64&&n%(n<576?9:n<648?72:81):n-5184)
(56 bytes) should work, right?
– nwellnhof
3 hours ago
@nwellnhof Yes, it does. :)
– Arnauld
2 hours ago
add a comment |
up vote
1
down vote
05AB1E (legacy), 30 bytes
5184‰`91SvDy64*›i1sy9*%}}64/îO
Try it online!
This is my first 05AB1E submission, so I am sure that this can be optimized.
add a comment |
up vote
1
down vote
Perl 6, 47 bytes
+($_,(*X-(1,9,81 X*^65)).grep(*>=0).min...^0)
Try it online!
A greedy algorithm seems to work.
add a comment |
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
Jelly, 17 bytes
64R×9;Ɗ⁺ff€¥@ŒṗẈṂ
Try it online!
-1 thanks to Jonathan Allan.
Explanation (you can't test for inputs larger than 58
over TIO):
64R×9;Ɗ⁺ff€¥@ŒṗẈṂ Arguments: x
64R [1..64]
×9;Ɗ Multiply by 9, prepend to original list
⁺ Do the above once more
Œṗ Positive integer partitions of x
¥@ Call with reversed arguments (x = partitions, y = flattened outer product)
f€ For each partition in x, keep the elements that are in y
f Keep the elements of x that have remained intact after the above
Ẉ Lengths of the remaining partitions
Ṃ Minimum
Since the output in testable area is trivial, can't quite check?
– l4m2
2 hours ago
add a comment |
up vote
3
down vote
Jelly, 17 bytes
64R×9;Ɗ⁺ff€¥@ŒṗẈṂ
Try it online!
-1 thanks to Jonathan Allan.
Explanation (you can't test for inputs larger than 58
over TIO):
64R×9;Ɗ⁺ff€¥@ŒṗẈṂ Arguments: x
64R [1..64]
×9;Ɗ Multiply by 9, prepend to original list
⁺ Do the above once more
Œṗ Positive integer partitions of x
¥@ Call with reversed arguments (x = partitions, y = flattened outer product)
f€ For each partition in x, keep the elements that are in y
f Keep the elements of x that have remained intact after the above
Ẉ Lengths of the remaining partitions
Ṃ Minimum
Since the output in testable area is trivial, can't quite check?
– l4m2
2 hours ago
add a comment |
up vote
3
down vote
up vote
3
down vote
Jelly, 17 bytes
64R×9;Ɗ⁺ff€¥@ŒṗẈṂ
Try it online!
-1 thanks to Jonathan Allan.
Explanation (you can't test for inputs larger than 58
over TIO):
64R×9;Ɗ⁺ff€¥@ŒṗẈṂ Arguments: x
64R [1..64]
×9;Ɗ Multiply by 9, prepend to original list
⁺ Do the above once more
Œṗ Positive integer partitions of x
¥@ Call with reversed arguments (x = partitions, y = flattened outer product)
f€ For each partition in x, keep the elements that are in y
f Keep the elements of x that have remained intact after the above
Ẉ Lengths of the remaining partitions
Ṃ Minimum
Jelly, 17 bytes
64R×9;Ɗ⁺ff€¥@ŒṗẈṂ
Try it online!
-1 thanks to Jonathan Allan.
Explanation (you can't test for inputs larger than 58
over TIO):
64R×9;Ɗ⁺ff€¥@ŒṗẈṂ Arguments: x
64R [1..64]
×9;Ɗ Multiply by 9, prepend to original list
⁺ Do the above once more
Œṗ Positive integer partitions of x
¥@ Call with reversed arguments (x = partitions, y = flattened outer product)
f€ For each partition in x, keep the elements that are in y
f Keep the elements of x that have remained intact after the above
Ẉ Lengths of the remaining partitions
Ṃ Minimum
edited 6 hours ago
answered 7 hours ago
Erik the Outgolfer
30.2k428100
30.2k428100
Since the output in testable area is trivial, can't quite check?
– l4m2
2 hours ago
add a comment |
Since the output in testable area is trivial, can't quite check?
– l4m2
2 hours ago
Since the output in testable area is trivial, can't quite check?
– l4m2
2 hours ago
Since the output in testable area is trivial, can't quite check?
– l4m2
2 hours ago
add a comment |
up vote
2
down vote
JavaScript (ES6), 72 66 57 56 bytes
Saved 1 byte thanks to @nwellnhof
f=n=>n&&1+f(n<5184?n>64&&n%(n<576?9:n>719?81:72):n-5184)
Try it online!
@nwellnhof This would fail for several values (576, 632, 633, ...)
– Arnauld
4 hours ago
I see. Butf=n=>n&&1+f(n<5184?n>64&&n%(n<576?9:n<648?72:81):n-5184)
(56 bytes) should work, right?
– nwellnhof
3 hours ago
@nwellnhof Yes, it does. :)
– Arnauld
2 hours ago
add a comment |
up vote
2
down vote
JavaScript (ES6), 72 66 57 56 bytes
Saved 1 byte thanks to @nwellnhof
f=n=>n&&1+f(n<5184?n>64&&n%(n<576?9:n>719?81:72):n-5184)
Try it online!
@nwellnhof This would fail for several values (576, 632, 633, ...)
– Arnauld
4 hours ago
I see. Butf=n=>n&&1+f(n<5184?n>64&&n%(n<576?9:n<648?72:81):n-5184)
(56 bytes) should work, right?
– nwellnhof
3 hours ago
@nwellnhof Yes, it does. :)
– Arnauld
2 hours ago
add a comment |
up vote
2
down vote
up vote
2
down vote
JavaScript (ES6), 72 66 57 56 bytes
Saved 1 byte thanks to @nwellnhof
f=n=>n&&1+f(n<5184?n>64&&n%(n<576?9:n>719?81:72):n-5184)
Try it online!
JavaScript (ES6), 72 66 57 56 bytes
Saved 1 byte thanks to @nwellnhof
f=n=>n&&1+f(n<5184?n>64&&n%(n<576?9:n>719?81:72):n-5184)
Try it online!
edited 2 hours ago
answered 8 hours ago
Arnauld
68.1k584288
68.1k584288
@nwellnhof This would fail for several values (576, 632, 633, ...)
– Arnauld
4 hours ago
I see. Butf=n=>n&&1+f(n<5184?n>64&&n%(n<576?9:n<648?72:81):n-5184)
(56 bytes) should work, right?
– nwellnhof
3 hours ago
@nwellnhof Yes, it does. :)
– Arnauld
2 hours ago
add a comment |
@nwellnhof This would fail for several values (576, 632, 633, ...)
– Arnauld
4 hours ago
I see. Butf=n=>n&&1+f(n<5184?n>64&&n%(n<576?9:n<648?72:81):n-5184)
(56 bytes) should work, right?
– nwellnhof
3 hours ago
@nwellnhof Yes, it does. :)
– Arnauld
2 hours ago
@nwellnhof This would fail for several values (576, 632, 633, ...)
– Arnauld
4 hours ago
@nwellnhof This would fail for several values (576, 632, 633, ...)
– Arnauld
4 hours ago
I see. But
f=n=>n&&1+f(n<5184?n>64&&n%(n<576?9:n<648?72:81):n-5184)
(56 bytes) should work, right?– nwellnhof
3 hours ago
I see. But
f=n=>n&&1+f(n<5184?n>64&&n%(n<576?9:n<648?72:81):n-5184)
(56 bytes) should work, right?– nwellnhof
3 hours ago
@nwellnhof Yes, it does. :)
– Arnauld
2 hours ago
@nwellnhof Yes, it does. :)
– Arnauld
2 hours ago
add a comment |
up vote
1
down vote
05AB1E (legacy), 30 bytes
5184‰`91SvDy64*›i1sy9*%}}64/îO
Try it online!
This is my first 05AB1E submission, so I am sure that this can be optimized.
add a comment |
up vote
1
down vote
05AB1E (legacy), 30 bytes
5184‰`91SvDy64*›i1sy9*%}}64/îO
Try it online!
This is my first 05AB1E submission, so I am sure that this can be optimized.
add a comment |
up vote
1
down vote
up vote
1
down vote
05AB1E (legacy), 30 bytes
5184‰`91SvDy64*›i1sy9*%}}64/îO
Try it online!
This is my first 05AB1E submission, so I am sure that this can be optimized.
05AB1E (legacy), 30 bytes
5184‰`91SvDy64*›i1sy9*%}}64/îO
Try it online!
This is my first 05AB1E submission, so I am sure that this can be optimized.
edited 5 hours ago
answered 5 hours ago
Black Owl Kai
4217
4217
add a comment |
add a comment |
up vote
1
down vote
Perl 6, 47 bytes
+($_,(*X-(1,9,81 X*^65)).grep(*>=0).min...^0)
Try it online!
A greedy algorithm seems to work.
add a comment |
up vote
1
down vote
Perl 6, 47 bytes
+($_,(*X-(1,9,81 X*^65)).grep(*>=0).min...^0)
Try it online!
A greedy algorithm seems to work.
add a comment |
up vote
1
down vote
up vote
1
down vote
Perl 6, 47 bytes
+($_,(*X-(1,9,81 X*^65)).grep(*>=0).min...^0)
Try it online!
A greedy algorithm seems to work.
Perl 6, 47 bytes
+($_,(*X-(1,9,81 X*^65)).grep(*>=0).min...^0)
Try it online!
A greedy algorithm seems to work.
answered 2 hours ago
nwellnhof
5,608921
5,608921
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f175710%2fgold-nugget-storage%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
4
Could you give slightly more detail/put into words how the input results in the output?
– Quintec
9 hours ago
2
If something requires clarification in the comments, it would be useful to edit the challenge to include that clarification
– trichoplax
9 hours ago
1
Is it basically a sort of change-making problem ? With the coins denominations being in the set
1,9,81 × 1...64
?– digEmAll
9 hours ago
1
Are you trying to minimize the number of items or number of stacks?
– fəˈnɛtɪk
9 hours ago
1
@fəˈnɛtɪk number of stacks for minecraft picture, item(numbers to be added) for the problem
– l4m2
9 hours ago