View Single Post
  #15  
Old 11-20-2007, 12:49 AM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
PHP Code:
function getSets(a, b) {
  
temp.list = {};
  for (
temp.i = 0; i < a.size() - 2; i++) {
    if (!(
a[i] in b)) continue;
    for (
temp.j = i + 1; j < a.size() - 1; j++) {
      if (!(
a[j] in b)) continue;
      for (
temp.k = j + 1; k < a.size(); k++) {
        if (
a[k] in b) list.add({a[i], a[j], a[k]});
      }
    }
  }
  return list;
} 
Just slap this into the script to try it:

PHP Code:
function onCreated() {
  
temp.foo = {2,3,5,6,8,10};
  echo(
foo);
  
temp.bar = {1,5,3,10,6,9,2};
  echo(
bar);
  echo(
getSets(foo, bar));
} 
__________________
Do it with a DON!
Reply With Quote