Discuss Scratch

Molive
Scratcher
100+ posts

Odd Counting Algorithm Help

Hi.

I know this is an odd request, but can I, using only operators, take a number counting up as shown:

1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20..80,81 (the variable i)

and output a sequence as shown?

1,1,1,2,2,2,3,3,3,1,1,1,2,2,2,3,3,3,1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,4,4,4,5,5,5,6,6,6,4,4,4,5,5,5,6,6,6,7,7,7,8,8,8,9,9,9,7,7,7,8,8,8,9,9,9,7,7,7,8,8,8,9,9,9

Thanks,
~Molive

“You're not a sailor?”
“No, I make money off of other people's talent.”
“…You're a project lead on a computer game?”
-The Curse Of Monkey Island

- TW9saXZlJ3Mgc2lnbmF0dXJlIGlzIHRoZSBCZXN0IFNpZ25hdHVyZSAg -


TheLogFather
Scratcher
1000+ posts

Odd Counting Algorithm Help

Oh, oops, I just answered in other topic…

Last edited by TheLogFather (Aug. 30, 2016 13:52:52)


Siggy the Kumquat slayer:
Main account: DadOfMrLog –– Frameworks for basic pen-rendered 3D in scratch (see studio). Examples:

- - - - 3D Text - - - - - - Simple shapes - - - Controllable structures - - - On the ground - - - - - - In space - - - -

PullJosh
Scratcher
1000+ posts

Odd Counting Algorithm Help

TheLogFather wrote:

Oh, oops, I just answered in other topic…

Hmm… Wouldn't it be simpler to do this?

(((([ceiling v] of ((i) / (3))) - (1)) mod (3)) + (1))

I'm pretty sure that should work just as well.
Molive
Scratcher
100+ posts

Odd Counting Algorithm Help

PullJosh wrote:

TheLogFather wrote:

Oh, oops, I just answered in other topic…

Hmm… Wouldn't it be simpler to do this?

(((([ceiling v] of ((i) / (3))) - (1)) mod (3)) + (1))

I'm pretty sure that should work just as well.

Do you mean that on its own or as a replacement for the last bit of the other one?
Because it only generates 1,1,1,2,2,2,3,3,3.

“You're not a sailor?”
“No, I make money off of other people's talent.”
“…You're a project lead on a computer game?”
-The Curse Of Monkey Island

- TW9saXZlJ3Mgc2lnbmF0dXJlIGlzIHRoZSBCZXN0IFNpZ25hdHVyZSAg -


PullJosh
Scratcher
1000+ posts

Odd Counting Algorithm Help

Molive wrote:

PullJosh wrote:

TheLogFather wrote:

Oh, oops, I just answered in other topic…

Hmm… Wouldn't it be simpler to do this?

(((([ceiling v] of ((i) / (3))) - (1)) mod (3)) + (1))

I'm pretty sure that should work just as well.

Do you mean that on its own or as a replacement for the last bit of the other one?
Because it only generates 1,1,1,2,2,2,3,3,3.
That will work on its own. Here's a project showing it in action: https://scratch.mit.edu/projects/119534305/
TheLogFather
Scratcher
1000+ posts

Odd Counting Algorithm Help

PullJosh wrote:

Molive wrote:

PullJosh wrote:

Hmm… Wouldn't it be simpler to do this?
(((([ceiling v] of ((i) / (3))) - (1)) mod (3)) + (1))
Do you mean that on its own or as a replacement for the last bit of the other one?
Because it only generates 1,1,1,2,2,2,3,3,3.
That will work on its own. Here's a project showing it in action: https://scratch.mit.edu/projects/119534305/
As Molive said, your expression only generates ones, twos and threes in a repeating pattern (unsurprisingly, given the “mod”). The required sequence continues with three 4s after the 27th item, and does tend towards infinity as the index increases – so it needs something extra that doesn't involve “mod”.

Take a look at Molive's original post again…


Siggy the Kumquat slayer:
Main account: DadOfMrLog –– Frameworks for basic pen-rendered 3D in scratch (see studio). Examples:

- - - - 3D Text - - - - - - Simple shapes - - - Controllable structures - - - On the ground - - - - - - In space - - - -

PullJosh
Scratcher
1000+ posts

Odd Counting Algorithm Help

TheLogFather wrote:

As Molive said, your expression only generates ones, twos and threes in a repeating pattern (unsurprisingly, given the “mod”). The required sequence continues with three 4s after the 27th item, and does tend towards infinity as the index increases – so it needs something extra that doesn't involve “mod”.

Take a look at Molive's original post again…

Oh wow, I totally didn't catch that!

Powered by DjangoBB