How many threes?
Clash Royale CLAN TAG#URR8PPP
up vote
6
down vote
favorite
In this task your code will be given an integer $n$ as input. Your code should then output the greatest number of multiples of $3$ that can be concatenated (in base $10$) to form $3n$ (with no leading zeros). For example if you were given $26042$ as input,
$26042times3=78126$
and $78126$ can be made by concatenating $78$, $12$ and $6$, so you output $3$.
Any standard forms of IO are permitted. Answers should aim to minimize the number of bytes in their code.
Here are the first $2188$ entries in this sequence starting with zero:
1,1,1,1,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,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1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,4,4,4,4,3,3,3,3,3,3,4,4,4,4,3,3,3,3,3,3,4,4,4,4,3,3,3,3,3,3,4,4,4,4,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,4,4,4,4,3,3,3,3,3,3,4,4,4,4,3,3,3,3,3,3,4,4,4,4,3,3,3,3,3,3,4,4,4,4,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2
code-golf sequence
add a comment |Â
up vote
6
down vote
favorite
In this task your code will be given an integer $n$ as input. Your code should then output the greatest number of multiples of $3$ that can be concatenated (in base $10$) to form $3n$ (with no leading zeros). For example if you were given $26042$ as input,
$26042times3=78126$
and $78126$ can be made by concatenating $78$, $12$ and $6$, so you output $3$.
Any standard forms of IO are permitted. Answers should aim to minimize the number of bytes in their code.
Here are the first $2188$ entries in this sequence starting with zero:
1,1,1,1,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1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on the formn -> f(n)
, wheref(n)
is the answer. As it is now, I can't even tell if your 6561 entries are 0-indexed or 1-indexed.
– maxb
32 mins ago
@maxb There are too many examples to do that format. My list is zero indexed.
– W W
31 mins ago
Of course, but some select few would be great, in addition to the first example. And from what I can see, we are allowed to split the number $3n$ any way we want? So a brute force implementation would be required (in some languages) to find the maximum number of multiples of 3? Also, do you define 0 as a multiple of 3? From your question it seems like it.
– maxb
28 mins ago
Your list contains 2188 entries (~6561 / 3).
– Arnauld
17 mins ago
@maxb There are two tricks that can be used to get solutions in shorter and faster ways. (hint 3 is special) and yes 0 is a multiple of 3. I dont know how else it could be.
– W W
13 mins ago
add a comment |Â
up vote
6
down vote
favorite
up vote
6
down vote
favorite
In this task your code will be given an integer $n$ as input. Your code should then output the greatest number of multiples of $3$ that can be concatenated (in base $10$) to form $3n$ (with no leading zeros). For example if you were given $26042$ as input,
$26042times3=78126$
and $78126$ can be made by concatenating $78$, $12$ and $6$, so you output $3$.
Any standard forms of IO are permitted. Answers should aim to minimize the number of bytes in their code.
Here are the first $2188$ entries in this sequence starting with zero:
1,1,1,1,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,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1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,4,4,4,4,3,3,3,3,3,3,4,4,4,4,3,3,3,3,3,3,4,4,4,4,3,3,3,3,3,3,4,4,4,4,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,4,4,4,4,3,3,3,3,3,3,4,4,4,4,3,3,3,3,3,3,4,4,4,4,3,3,3,3,3,3,4,4,4,4,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2
code-golf sequence
In this task your code will be given an integer $n$ as input. Your code should then output the greatest number of multiples of $3$ that can be concatenated (in base $10$) to form $3n$ (with no leading zeros). For example if you were given $26042$ as input,
$26042times3=78126$
and $78126$ can be made by concatenating $78$, $12$ and $6$, so you output $3$.
Any standard forms of IO are permitted. Answers should aim to minimize the number of bytes in their code.
Here are the first $2188$ entries in this s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,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,4,4,4,4,3,3,3,3,3,3,4,4,4,4,3,3,3,3,3,3,4,4,4,4,3,3,3,3,3,3,4,4,4,4,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2
code-golf sequence
code-golf sequence
edited 5 mins ago
asked 40 mins ago


W W
33.7k10149351
33.7k10149351
2
It would be great to have some examples on the formn -> f(n)
, wheref(n)
is the answer. As it is now, I can't even tell if your 6561 entries are 0-indexed or 1-indexed.
– maxb
32 mins ago
@maxb There are too many examples to do that format. My list is zero indexed.
– W W
31 mins ago
Of course, but some select few would be great, in addition to the first example. And from what I can see, we are allowed to split the number $3n$ any way we want? So a brute force implementation would be required (in some languages) to find the maximum number of multiples of 3? Also, do you define 0 as a multiple of 3? From your question it seems like it.
– maxb
28 mins ago
Your list contains 2188 entries (~6561 / 3).
– Arnauld
17 mins ago
@maxb There are two tricks that can be used to get solutions in shorter and faster ways. (hint 3 is special) and yes 0 is a multiple of 3. I dont know how else it could be.
– W W
13 mins ago
add a comment |Â
2
It would be great to have some examples on the formn -> f(n)
, wheref(n)
is the answer. As it is now, I can't even tell if your 6561 entries are 0-indexed or 1-indexed.
– maxb
32 mins ago
@maxb There are too many examples to do that format. My list is zero indexed.
– W W
31 mins ago
Of course, but some select few would be great, in addition to the first example. And from what I can see, we are allowed to split the number $3n$ any way we want? So a brute force implementation would be required (in some languages) to find the maximum number of multiples of 3? Also, do you define 0 as a multiple of 3? From your question it seems like it.
– maxb
28 mins ago
Your list contains 2188 entries (~6561 / 3).
– Arnauld
17 mins ago
@maxb There are two tricks that can be used to get solutions in shorter and faster ways. (hint 3 is special) and yes 0 is a multiple of 3. I dont know how else it could be.
– W W
13 mins ago
2
2
It would be great to have some examples on the form
n -> f(n)
, where f(n)
is the answer. As it is now, I can't even tell if your 6561 entries are 0-indexed or 1-indexed.– maxb
32 mins ago
It would be great to have some examples on the form
n -> f(n)
, where f(n)
is the answer. As it is now, I can't even tell if your 6561 entries are 0-indexed or 1-indexed.– maxb
32 mins ago
@maxb There are too many examples to do that format. My list is zero indexed.
– W W
31 mins ago
@maxb There are too many examples to do that format. My list is zero indexed.
– W W
31 mins ago
Of course, but some select few would be great, in addition to the first example. And from what I can see, we are allowed to split the number $3n$ any way we want? So a brute force implementation would be required (in some languages) to find the maximum number of multiples of 3? Also, do you define 0 as a multiple of 3? From your question it seems like it.
– maxb
28 mins ago
Of course, but some select few would be great, in addition to the first example. And from what I can see, we are allowed to split the number $3n$ any way we want? So a brute force implementation would be required (in some languages) to find the maximum number of multiples of 3? Also, do you define 0 as a multiple of 3? From your question it seems like it.
– maxb
28 mins ago
Your list contains 2188 entries (~6561 / 3).
– Arnauld
17 mins ago
Your list contains 2188 entries (~6561 / 3).
– Arnauld
17 mins ago
@maxb There are two tricks that can be used to get solutions in shorter and faster ways. (hint 3 is special) and yes 0 is a multiple of 3. I dont know how else it could be.
– W W
13 mins ago
@maxb There are two tricks that can be used to get solutions in shorter and faster ways. (hint 3 is special) and yes 0 is a multiple of 3. I dont know how else it could be.
– W W
13 mins ago
add a comment |Â
6 Answers
6
active
oldest
votes
up vote
0
down vote
JavaScript (ES6), 52 bytes
n=>[...n*3+''].map(d=>(k=k*10-d)%3?0:k=!++i,i=k=0)|i
Try it online!
add a comment |Â
up vote
0
down vote
Perl 6, 54 bytes
($_...2).first(~(3*$_)∈[X~] [1..$_ X*3]xx$^a)
Try it online!
Brute force solution which can't really test past n=8
.
add a comment |Â
up vote
0
down vote
MathGolf, 15 bytes
3*▒0ô§_3%╜0;]£
Try it online!
Explanation
3* Multiply the input by 3
▒ Convert to a list of digits
0 Push a zero and swap the top two elements
ô Execute the next 6 characters for each block
§ Concatenate
_ Duplicate
3% Modulo 3
╜0 If not true, push 0
; Discard TOS (it's always the last zero)
]£ Wrap the entire stack in an array and output its length
I don't know if this is the correct solution to the problem but it mimics the JS solution by Arnauld. If I'm incorrect, I'll try to fix it.
add a comment |Â
up vote
0
down vote
Python 2, 99 88 bytes
lambda n:g(`3*n`)
g=lambda n:int(n)%3<1and 1+max([g(n[i:])for i in range(1,len(n))]+[0])
Try it online!
add a comment |Â
up vote
0
down vote
Pyth, 16 15 bytes
lef!.E%vT3./`*3
Try it online here.
add a comment |Â
up vote
0
down vote
05AB1E, 14 12 bytes
3*.œʒ3ÖP}€gÃÂ
Or alternatively €gÃÂ
can be éθg
.
Try it online or verify the first 1000 items
add a comment |Â
6 Answers
6
active
oldest
votes
6 Answers
6
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
JavaScript (ES6), 52 bytes
n=>[...n*3+''].map(d=>(k=k*10-d)%3?0:k=!++i,i=k=0)|i
Try it online!
add a comment |Â
up vote
0
down vote
JavaScript (ES6), 52 bytes
n=>[...n*3+''].map(d=>(k=k*10-d)%3?0:k=!++i,i=k=0)|i
Try it online!
add a comment |Â
up vote
0
down vote
up vote
0
down vote
JavaScript (ES6), 52 bytes
n=>[...n*3+''].map(d=>(k=k*10-d)%3?0:k=!++i,i=k=0)|i
Try it online!
JavaScript (ES6), 52 bytes
n=>[...n*3+''].map(d=>(k=k*10-d)%3?0:k=!++i,i=k=0)|i
Try it online!
answered 24 mins ago


Arnauld
65.1k581275
65.1k581275
add a comment |Â
add a comment |Â
up vote
0
down vote
Perl 6, 54 bytes
($_...2).first(~(3*$_)∈[X~] [1..$_ X*3]xx$^a)
Try it online!
Brute force solution which can't really test past n=8
.
add a comment |Â
up vote
0
down vote
Perl 6, 54 bytes
($_...2).first(~(3*$_)∈[X~] [1..$_ X*3]xx$^a)
Try it online!
Brute force solution which can't really test past n=8
.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Perl 6, 54 bytes
($_...2).first(~(3*$_)∈[X~] [1..$_ X*3]xx$^a)
Try it online!
Brute force solution which can't really test past n=8
.
Perl 6, 54 bytes
($_...2).first(~(3*$_)∈[X~] [1..$_ X*3]xx$^a)
Try it online!
Brute force solution which can't really test past n=8
.
answered 16 mins ago
Jo King
16.1k24189
16.1k24189
add a comment |Â
add a comment |Â
up vote
0
down vote
MathGolf, 15 bytes
3*▒0ô§_3%╜0;]£
Try it online!
Explanation
3* Multiply the input by 3
▒ Convert to a list of digits
0 Push a zero and swap the top two elements
ô Execute the next 6 characters for each block
§ Concatenate
_ Duplicate
3% Modulo 3
╜0 If not true, push 0
; Discard TOS (it's always the last zero)
]£ Wrap the entire stack in an array and output its length
I don't know if this is the correct solution to the problem but it mimics the JS solution by Arnauld. If I'm incorrect, I'll try to fix it.
add a comment |Â
up vote
0
down vote
MathGolf, 15 bytes
3*▒0ô§_3%╜0;]£
Try it online!
Explanation
3* Multiply the input by 3
▒ Convert to a list of digits
0 Push a zero and swap the top two elements
ô Execute the next 6 characters for each block
§ Concatenate
_ Duplicate
3% Modulo 3
╜0 If not true, push 0
; Discard TOS (it's always the last zero)
]£ Wrap the entire stack in an array and output its length
I don't know if this is the correct solution to the problem but it mimics the JS solution by Arnauld. If I'm incorrect, I'll try to fix it.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
MathGolf, 15 bytes
3*▒0ô§_3%╜0;]£
Try it online!
Explanation
3* Multiply the input by 3
▒ Convert to a list of digits
0 Push a zero and swap the top two elements
ô Execute the next 6 characters for each block
§ Concatenate
_ Duplicate
3% Modulo 3
╜0 If not true, push 0
; Discard TOS (it's always the last zero)
]£ Wrap the entire stack in an array and output its length
I don't know if this is the correct solution to the problem but it mimics the JS solution by Arnauld. If I'm incorrect, I'll try to fix it.
MathGolf, 15 bytes
3*▒0ô§_3%╜0;]£
Try it online!
Explanation
3* Multiply the input by 3
▒ Convert to a list of digits
0 Push a zero and swap the top two elements
ô Execute the next 6 characters for each block
§ Concatenate
_ Duplicate
3% Modulo 3
╜0 If not true, push 0
; Discard TOS (it's always the last zero)
]£ Wrap the entire stack in an array and output its length
I don't know if this is the correct solution to the problem but it mimics the JS solution by Arnauld. If I'm incorrect, I'll try to fix it.
answered 8 mins ago


maxb
1,4091519
1,4091519
add a comment |Â
add a comment |Â
up vote
0
down vote
Python 2, 99 88 bytes
lambda n:g(`3*n`)
g=lambda n:int(n)%3<1and 1+max([g(n[i:])for i in range(1,len(n))]+[0])
Try it online!
add a comment |Â
up vote
0
down vote
Python 2, 99 88 bytes
lambda n:g(`3*n`)
g=lambda n:int(n)%3<1and 1+max([g(n[i:])for i in range(1,len(n))]+[0])
Try it online!
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Python 2, 99 88 bytes
lambda n:g(`3*n`)
g=lambda n:int(n)%3<1and 1+max([g(n[i:])for i in range(1,len(n))]+[0])
Try it online!
Python 2, 99 88 bytes
lambda n:g(`3*n`)
g=lambda n:int(n)%3<1and 1+max([g(n[i:])for i in range(1,len(n))]+[0])
Try it online!
edited 6 mins ago
answered 23 mins ago


TFeld
11.9k2833
11.9k2833
add a comment |Â
add a comment |Â
up vote
0
down vote
Pyth, 16 15 bytes
lef!.E%vT3./`*3
Try it online here.
add a comment |Â
up vote
0
down vote
Pyth, 16 15 bytes
lef!.E%vT3./`*3
Try it online here.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Pyth, 16 15 bytes
lef!.E%vT3./`*3
Try it online here.
Pyth, 16 15 bytes
lef!.E%vT3./`*3
Try it online here.
edited 4 mins ago
answered 12 mins ago


Sok
2,941722
2,941722
add a comment |Â
add a comment |Â
up vote
0
down vote
05AB1E, 14 12 bytes
3*.œʒ3ÖP}€gÃÂ
Or alternatively €gÃÂ
can be éθg
.
Try it online or verify the first 1000 items
add a comment |Â
up vote
0
down vote
05AB1E, 14 12 bytes
3*.œʒ3ÖP}€gÃÂ
Or alternatively €gÃÂ
can be éθg
.
Try it online or verify the first 1000 items
add a comment |Â
up vote
0
down vote
up vote
0
down vote
05AB1E, 14 12 bytes
3*.œʒ3ÖP}€gÃÂ
Or alternatively €gÃÂ
can be éθg
.
Try it online or verify the first 1000 items
05AB1E, 14 12 bytes
3*.œʒ3ÖP}€gÃÂ
Or alternatively €gÃÂ
can be éθg
.
Try it online or verify the first 1000 items
edited 3 mins ago
answered 13 mins ago


Kevin Cruijssen
30.5k553167
30.5k553167
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%2f172910%2fhow-many-threes%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
2
It would be great to have some examples on the form
n -> f(n)
, wheref(n)
is the answer. As it is now, I can't even tell if your 6561 entries are 0-indexed or 1-indexed.– maxb
32 mins ago
@maxb There are too many examples to do that format. My list is zero indexed.
– W W
31 mins ago
Of course, but some select few would be great, in addition to the first example. And from what I can see, we are allowed to split the number $3n$ any way we want? So a brute force implementation would be required (in some languages) to find the maximum number of multiples of 3? Also, do you define 0 as a multiple of 3? From your question it seems like it.
– maxb
28 mins ago
Your list contains 2188 entries (~6561 / 3).
– Arnauld
17 mins ago
@maxb There are two tricks that can be used to get solutions in shorter and faster ways. (hint 3 is special) and yes 0 is a multiple of 3. I dont know how else it could be.
– W W
13 mins ago