Discuss Scratch

Molive
Scratcher
100+ posts

Odd Counting Algorithm Help

FIXED

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

Last edited by Molive (Aug. 30, 2016 14:01:50)


“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 -


asivi
Scratcher
1000+ posts

Odd Counting Algorithm Help

Actually your request doesn't belong to help with scripts, it is pretty much belonging to help with maths. Try it in Advanced Topics.
Molive
Scratcher
100+ posts

Odd Counting Algorithm Help

asivi wrote:

Actually your request doesn't belong to help with scripts, it is pretty much belonging to help with maths. Try it in Advanced Topics.
ok.

asivi wrote:

Actually your request doesn't belong to help with scripts, it is pretty much belonging to help with maths. Try it in Advanced Topics.

ok.
https://scratch.mit.edu/discuss/topic/215806/

“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

The expression “(floor ((i-1)/27) )*3 + 1” gives you 27 ones followed by 27 fours, then 27 sevens, etc.

Now you need to add zero, one or two, going up by one every three items, but back down to zero after 9 items.

So add something like “(floor ((i-1)/3)) mod 3” to above.


EDIT: oops, started typing this before replies above…

Here, done it in scratchblocks:
((( [floor v] of (((i)-(1))/(27)) ) * (3)) + ( (([floor v] of (((i)-(1))/(3)) ) mod (3)) + (1) ) )
Hope I got all the brackets in the right places!

Last edited by TheLogFather (Aug. 30, 2016 14:01:37)


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 - - - -

Molive
Scratcher
100+ posts

Odd Counting Algorithm Help

TheLogFather wrote:

The expression “(floor ((i-1)/27) )*3 + 1” gives you 27 ones followed by 27 fours, then 27 sevens, etc.

Now you need to add zero, one or two, going up by one every three items, but back down to zero after 9 items.

So add something like “(floor ((i-1)/3)) mod 3” to above.


EDIT: oops, started typing this before replies above…

Here, done it in scratchblocks:
((( [floor v] of (((i)-(1))/(27)) ) * (3)) + ( (([floor v] of (((i)-(1))/(3)) ) mod (3)) + (1) ) )
Hope I got all the brackets in the right places!


Looks right, Thanks

Last edited by Molive (Aug. 30, 2016 14:03:06)


“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 -


asivi
Scratcher
1000+ posts

Odd Counting Algorithm Help

TheLogFather wrote:

The expression “(floor ((i-1)/27) )*3 + 1” gives you 27 ones followed by 27 fours, then 27 sevens, etc.

Now you need to add zero, one or two, going up by one every three items, but back down to zero after 9 items.

So add something like “floor ( (i-1)/3 mod 3 )” to above.


EDIT: oops, started typing this before replies above…

Here, done it in scratchblocks:
((( [floor v] of (((i)-(1))/(27)) ) * (3)) + ( (([floor v] of (((i)-(1))/(3)) ) mod (3)) + (1) ) )
Hope I got all the brackets in the right places!

Lol, i can't believe this response being so quickly, obviously you are a great mathematician.
Greetings.
Paddle2See
Scratch Team
1000+ posts

Odd Counting Algorithm Help

So now I'm curious - why would you want that odd looking output sequence?

Scratch Team Member, kayak and pickleball enthusiast, cat caregiver.

This is my forum signature! On a forum post, it is okay for Scratchers to advertise in their forum signature. The signature is the stuff that shows up below the horizontal line on the post. It will show up on every post I make.
(credit to Za-Chary)



;
IcyCoder
Scratcher
1000+ posts

Odd Counting Algorithm Help

Paddle2See wrote:

So now I'm curious - why would you want that odd looking output sequence?
me too

Because JS is the future (echos) future future futur futu fut fu f
Molive
Scratcher
100+ posts

Odd Counting Algorithm Help

Paddle2See wrote:

So now I'm curious - why would you want that odd looking output sequence?

When wrapped around in nines it looks like this:

1 1 1 2 2 2 3 3 3 /n
1 1 1 2 2 2 3 3 3 /n
1 1 1 2 2 2 3 3 3 /n
4 4 4 5 5 5 6 6 6 /n
4 4 4 5 5 5 6 6 6 /n
4 4 4 5 5 5 6 6 6 /n
7 7 7 8 8 8 9 9 9 /n
7 7 7 8 8 8 9 9 9 /n
7 7 7 8 8 8 9 9 9 /n

It's for a Sudoku solver - I can take a number's position in a list and know what box it's in.

https://scratch.mit.edu/projects/119524351/

Last edited by Molive (Aug. 31, 2016 09:22:23)


“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 -


Molive
Scratcher
100+ posts

Odd Counting Algorithm Help

Now released:
https://scratch.mit.edu/projects/119524351/

“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 -


Powered by DjangoBB