This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-05-17 21:26:28

Vista4563
Scratcher
Registered: 2009-07-20
Posts: 500+

Lists, lists, lists... ugh.

I'm making a code solver, and I need help using lists and variables...

Take this script:
http://img688.imageshack.us/img688/5485/pentominosolverfix.gif

It really needs to be shortened....


Team Vista | TBG Moderator | #stopKony #Kony2012 | http://ls.gd/icgrin http://is.gd/78GWUZ
http://is.gd/jEY5Ihttp://is.gd/Vl19zR http://i.imgur.com/L4HIs.png

Offline

 

#2 2010-05-17 21:33:32

Lucario621
Community Moderator
Registered: 2007-10-03
Posts: 1000+

Re: Lists, lists, lists... ugh.

Ok, that can be shortened - you just have to think outside the box  tongue

Create a list, with all of those letters - f,i,l,n,p,t,u,v,w,x,y,z

Then, in that if block, just put:

if <list contains (answer)>

I hope that helps  smile

Last edited by Lucario621 (2010-05-17 21:33:43)


http://i.imgur.com/WBkM2QQ.png

Offline

 

#3 2010-05-17 21:40:36

Vista4563
Scratcher
Registered: 2009-07-20
Posts: 500+

Re: Lists, lists, lists... ugh.

Thanks!

However, what I really need to do is define a pentomino/number combination as a letter. I'm using three lists... the pentomino types, the numbers, and the end result where the message will unfold. Is there a way to do this with lists?


Team Vista | TBG Moderator | #stopKony #Kony2012 | http://ls.gd/icgrin http://is.gd/78GWUZ
http://is.gd/jEY5Ihttp://is.gd/Vl19zR http://i.imgur.com/L4HIs.png

Offline

 

#4 2010-05-17 22:29:00

Lucario621
Community Moderator
Registered: 2007-10-03
Posts: 1000+

Re: Lists, lists, lists... ugh.

I'm not really sure  neutral  I'm not really the right person to ask  tongue


http://i.imgur.com/WBkM2QQ.png

Offline

 

#5 2010-05-17 23:01:14

Dazachi
Retired Community Moderator
Registered: 2009-09-12
Posts: 1000+

Re: Lists, lists, lists... ugh.

Lucario621 wrote:

Ok, that can be shortened - you just have to think outside the box  tongue

Create a list, with all of those letters - f,i,l,n,p,t,u,v,w,x,y,z

Then, in that if block, just put:

if <list contains (answer)>

I hope that helps  smile

I was thinking the same thing. Too bad you beat me to posting it.


Dazachi, Retired Community Moderator
May also know me as OJACheung.

Offline

 

#6 2010-05-17 23:02:49

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: Lists, lists, lists... ugh.

Lucario621 wrote:

Ok, that can be shortened - you just have to think outside the box  tongue

Create a list, with all of those letters - f,i,l,n,p,t,u,v,w,x,y,z

Then, in that if block, just put:

if <list contains (answer)>

I hope that helps  smile

You know, that is a commonly used strategy in real programming, too - I've found it in my ventures.

By Pentomino, do you mean Strings?

Offline

 

#7 2010-05-17 23:03:25

Dazachi
Retired Community Moderator
Registered: 2009-09-12
Posts: 1000+

Re: Lists, lists, lists... ugh.

Vista4563 wrote:

Thanks!

However, what I really need to do is define a pentomino/number combination as a letter. I'm using three lists... the pentomino types, the numbers, and the end result where the message will unfold. Is there a way to do this with lists?

I'm a bit confused about what you mean. Do you mean to check if it is a letter?


Dazachi, Retired Community Moderator
May also know me as OJACheung.

Offline

 

#8 2010-05-17 23:13:09

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: Lists, lists, lists... ugh.

Dazachi wrote:

Vista4563 wrote:

Thanks!

However, what I really need to do is define a pentomino/number combination as a letter. I'm using three lists... the pentomino types, the numbers, and the end result where the message will unfold. Is there a way to do this with lists?

I'm a bit confused about what you mean. Do you mean to check if it is a letter?

If so, you can use the same method with one list for the letters, one for the numbers, and if it's in list A, it's a letter, list B, it's a number... Is that what you meant? I can post a more detailed description if such is the case.

Hope that helps  smile

Offline

 

#9 2010-05-17 23:47:44

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Lists, lists, lists... ugh.

coolstuff wrote:

Lucario621 wrote:

Ok, that can be shortened - you just have to think outside the box  tongue

Create a list, with all of those letters - f,i,l,n,p,t,u,v,w,x,y,z

Then, in that if block, just put:

if <list contains (answer)>

I hope that helps  smile

You know, that is a commonly used strategy in real programming, too - I've found it in my ventures.

By Pentomino, do you mean Strings?

I was going to suggest using a repeat loop to go though all the values of the list... then I noticed the "contains" feature. Often times in programming you will need to search your arrays and you use a for loop for this.

Last edited by archmage (2010-05-17 23:48:05)


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#10 2010-05-18 13:49:05

Vista4563
Scratcher
Registered: 2009-07-20
Posts: 500+

Re: Lists, lists, lists... ugh.

Here's the problem... I have three lists (one that holds the pentomino types, one that holds the numbers one, two and three, and one that holds the message once decoded.

If you enter in a certain combination of Pentomino_type and number, I want it to show as a certain letter in the "decoded message" list.


Team Vista | TBG Moderator | #stopKony #Kony2012 | http://ls.gd/icgrin http://is.gd/78GWUZ
http://is.gd/jEY5Ihttp://is.gd/Vl19zR http://i.imgur.com/L4HIs.png

Offline

 

#11 2010-05-18 18:52:42

infinitum3d
Scratcher
Registered: 2009-05-10
Posts: 100+

Re: Lists, lists, lists... ugh.

.


http://en.wikipedia.org/wiki/Pentomino

A pentomino is a tetris-like shape consisting of 5 squares. There are 12 different free pentominoes, F, L, N, P, Y, Z, I, T, U, V, W, and X.

Thank goodness for google (LOL).

Last edited by infinitum3d (2010-05-18 18:53:13)

Offline

 

#12 2010-05-18 20:25:47

Vista4563
Scratcher
Registered: 2009-07-20
Posts: 500+

Re: Lists, lists, lists... ugh.

I know that; that's out of the question.

Here's the problem... I have three lists (one that holds the pentomino types, one that holds the numbers one, two and three, and one that holds the message once decoded.

If you enter in a certain combination of Pentomino_type and number, I want it to show as a certain letter in the "decoded message" list.


Team Vista | TBG Moderator | #stopKony #Kony2012 | http://ls.gd/icgrin http://is.gd/78GWUZ
http://is.gd/jEY5Ihttp://is.gd/Vl19zR http://i.imgur.com/L4HIs.png

Offline

 

#13 2010-05-19 13:30:50

Vista4563
Scratcher
Registered: 2009-07-20
Posts: 500+

Re: Lists, lists, lists... ugh.

...I still need help.


Team Vista | TBG Moderator | #stopKony #Kony2012 | http://ls.gd/icgrin http://is.gd/78GWUZ
http://is.gd/jEY5Ihttp://is.gd/Vl19zR http://i.imgur.com/L4HIs.png

Offline

 

#14 2010-05-19 18:55:05

fullmoon
Retired Community Moderator
Registered: 2007-06-04
Posts: 1000+

Re: Lists, lists, lists... ugh.

Vista4563 wrote:

If you enter in a certain combination of Pentomino_type and number, I want it to show as a certain letter in the "decoded message" list.

Could you give an example what this input might look like?


http://i302.photobucket.com/albums/nn100/fullmoon32/wow.jpg

Offline

 

#15 2010-05-19 19:00:31

fullmoon
Retired Community Moderator
Registered: 2007-06-04
Posts: 1000+

Re: Lists, lists, lists... ugh.

Vista4563 wrote:

However, what I really need to do is define a pentomino/number combination as a letter.

So a combination like F1 would be "A", etc? Well, you could create a list of combinations:

Code:

List comboList
set i to 0
set j to 0
repeat (length of [pentonimoTypes]):
  change i by 1
  set j to 0
  repeat (length of [pentominoNumbers]):
    change j by 1
    add (join (item (i) of pentominoTypes) (item (j) of pentominoNumbers)) to comboList
  end
end

I'm still not sure how this would help you. Could you give an example of what the input and the output would look like?

Last edited by fullmoon (2010-05-19 19:00:46)


http://i302.photobucket.com/albums/nn100/fullmoon32/wow.jpg

Offline

 

#16 2010-05-19 20:54:10

Vista4563
Scratcher
Registered: 2009-07-20
Posts: 500+

Re: Lists, lists, lists... ugh.

That should work... The example input would be F, L, N, P, Y, Z, I, T, U, V, W, or X combined with a number from 1-3, and the result would be a letter from A-Z.

Last edited by Vista4563 (2010-05-19 20:54:33)


Team Vista | TBG Moderator | #stopKony #Kony2012 | http://ls.gd/icgrin http://is.gd/78GWUZ
http://is.gd/jEY5Ihttp://is.gd/Vl19zR http://i.imgur.com/L4HIs.png

Offline

 

#17 2010-05-19 21:02:12

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: Lists, lists, lists... ugh.

Vista4563 wrote:

That should work... The example input would be F, L, N, P, Y, Z, I, T, U, V, W, or X combined with a number from 1-3, and the result would be a letter from A-Z.

So, something like F3? Or Y2?

Offline

 

#18 2010-05-19 21:23:40

Vista4563
Scratcher
Registered: 2009-07-20
Posts: 500+

Re: Lists, lists, lists... ugh.

coolstuff wrote:

Vista4563 wrote:

That should work... The example input would be F, L, N, P, Y, Z, I, T, U, V, W, or X combined with a number from 1-3, and the result would be a letter from A-Z.

So, something like F3? Or Y2?

Exactly.


Team Vista | TBG Moderator | #stopKony #Kony2012 | http://ls.gd/icgrin http://is.gd/78GWUZ
http://is.gd/jEY5Ihttp://is.gd/Vl19zR http://i.imgur.com/L4HIs.png

Offline

 

Board footer