|
-
Jul 11th, 2005, 09:48 AM
#1
[RESOLVED] Very simple sequence problem
Given the input sequence 1,2,3,4,5,6,7,8,9........
how do you convert it to 2,1,0,2,1,0,2,1,0.........
All I have at the moment is this:
Output = (3-(Input mod 3)) mod 3
Which does work but it looks a bit clumsy, anyone know a better way?
I don't live here any more.
-
Jul 11th, 2005, 03:49 PM
#2
Re: Very simple sequence problem
Yes, its clumsy
I'd use
Output = 3-(Input mod 3)
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Jul 12th, 2005, 05:06 AM
#3
Re: Very simple sequence problem
Despite the fact it doesn't work?
if input is 0 then your version will output (3-0 = 3) there are no threes in my desired sequence, hence the extra mod.
I don't live here any more.
-
Jul 12th, 2005, 04:29 PM
#4
Re: [RESOLVED] Very simple sequence problem
Don't reckon you'll find a better way, my furry friend. It's a repeating sequence, so there's no 1 to 1 correspondence between the first and second sequences. It does, however, repeat with a period of 3 and the obvious (natural) way to do this is to do a "mod". It's in inverse order, so you need a "3 - ". And if you want to use 0 rather than 3, you need to "mod" it again. Three transformations, three operations. Couldn't be easier.
Obviously you knew this, so I don't know why I'm bothering.
zaza
Have you noticed how mendhak has a barcode as his avatar now instead of a three-eyed frog (see other posts in this section)? Is that because he has a price on his head?
-
Jul 24th, 2005, 03:37 AM
#5
New Member
Re: [RESOLVED] Very simple sequence problem
<head>
<script>
for(x=1;x<15;x++) document.write(2-((x+2)%3));
</script>
</head>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|