a numbers puzzle?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Geoff Cox

    a numbers puzzle?

    Hello,

    say I have events numbered 1 to 7 and wish to prevent all except the
    current one.

    ie
    when 1 allowed prevent 2-7
    when 2 allowed prevent 1 and 3-7
    when 3 allowed prevent 1-2 and 4-7
    when 4 allowed prevent 1-3 and 5-7
    when 5 allowed prevent 1-4 and 6-7
    when 6 allowed prevent 1-5 and 7
    when 7 allowed prevent 1-6

    how do I do this in Javascript?

    Cheers

    Geoff
  • Lasse Reichstein Nielsen

    #2
    Re: a numbers puzzle?

    Geoff Cox <gcox@freeuk.no tcomwrites:
    say I have events numbered 1 to 7 and wish to prevent all except the
    current one.
    >
    ie
    when 1 allowed prevent 2-7
    when 2 allowed prevent 1 and 3-7
    when 3 allowed prevent 1-2 and 4-7
    when 4 allowed prevent 1-3 and 5-7
    when 5 allowed prevent 1-4 and 6-7
    when 6 allowed prevent 1-5 and 7
    when 7 allowed prevent 1-6
    >
    how do I do this in Javascript?
    if (eventNumber != currentEventNum ber) {
    disallowEvent() ;
    }

    Now, for us to do anything less generic, you should supply more detail.

    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    • Geoff Cox

      #3
      Re: a numbers puzzle?

      On Sun, 11 May 2008 21:34:19 +0200, Lasse Reichstein Nielsen
      <lrn@hotpop.com wrote:
      >Geoff Cox <gcox@freeuk.no tcomwrites:
      >
      >say I have events numbered 1 to 7 and wish to prevent all except the
      >current one.
      >>
      >ie
      >when 1 allowed prevent 2-7
      >when 2 allowed prevent 1 and 3-7
      >when 3 allowed prevent 1-2 and 4-7
      >when 4 allowed prevent 1-3 and 5-7
      >when 5 allowed prevent 1-4 and 6-7
      >when 6 allowed prevent 1-5 and 7
      >when 7 allowed prevent 1-6
      >>
      >how do I do this in Javascript?
      >
      if (eventNumber != currentEventNum ber) {
      disallowEvent() ;
      }
      >
      >Now, for us to do anything less generic, you should supply more detail.
      >
      >/L
      Lasse,

      Thanks for the above - I am using

      for (var count=1;count<t ;count++){
      if (count != t) {
      soundManager.st op('mySound'+co unt);
      document.getEle mentById('IMG'+ (count)).src=pl ayed2.src;
      }
      }

      Which doesn't quite work as it stops counting up once the count is not
      equal to t. How do I make the count continue?

      Cheers

      Geoff

      Comment

      • Geoff Cox

        #4
        Re: a numbers puzzle?

        On Sun, 11 May 2008 21:34:19 +0200, Lasse Reichstein Nielsen
        <lrn@hotpop.com wrote:

        Lasse,

        I think I've got it right now! I need count < 7 not count < t.

        Cheers

        Geoff

        for (var count=1;count<7 ;count++){
        if (count != t) {
        soundManager.st op('mySound'+co unt);
        document.getEle mentById('IMG'+ (count)).src=pl ayed2.src;
        }
        }

        Comment

        • Geoff Cox

          #5
          Re: a numbers puzzle?

          On Sun, 11 May 2008 21:34:19 +0200, Lasse Reichstein Nielsen
          <lrn@hotpop.com wrote:

          ah! should have been count < 8 ie 1 more than the number of events.

          Cheers

          Geoff

          Comment

          Working...