Results 1 to 3 of 3

Thread: Can you win in lotto?

  1. #1
    Join Date
    Nov 2009
    Posts
    471
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default Can you win in lotto?

    Hello this is a little lotto script, go ahead and see how many tries you will use to win first price, i know i will never bet as the chances is near 0%... lol

    Code:
    var
    a,b,c,d,e,f,g,h:integer;
    premie,premie2,premie3,premie4,premie5,premie6:integer;
    
    
    begin
    
    premie:=1;premie2:=1;premie3:=1;premie4:=1;premie5:=1;premie6:=1;
    
    repeat
    
    
    a:=(0)+random(47);
    b:=(0)+random(47);
    c:=(0)+random(47);
    d:=(0)+random(47);
    e:=(0)+random(47);
    f:=(0)+random(47);
    g:=(0)+random(47);
    
    if  not(a=b) or (a=c) or (a=d) or (a=e) or (a=f) or (a=g) then begin
    if  not(b=a) or (b=c) or (b=d) or (b=e) or (b=f) or (b=g) then begin
    if  not(c=a) or (c=b) or (c=d) or (c=e) or (c=f) or (b=g) then begin
    if  not(d=a) or (d=b) or (d=c) or (d=e) or (c=f) or (b=g) then begin
    if  not(e=a) or (e=b) or (e=c) or (e=b) or (e=f) or (e=g) then begin
    if  not(f=a) or (f=b) or (f=c) or (f=d) or (f=e) or (b=g) then begin
    if  not(g=a) or (g=b) or (g=c) or (g=d) or (g=e) or (g=f) then begin
    
    writeln(a);
    writeln(b);
    writeln(c);
    writeln(d);
    writeln(e);
    writeln(f);
    writeln(g);
    inc(h);
    
    end;
    end;
    end;
    end;
    end;
    end;
    end;
    if(a=5) and (b=11) and (c=15) and (d=3) and (f=8) and (g=20) then
    begin
    addtoreport('You won first price! prices won '+inttostr(premie));
    terminatescript;
    inc(premie);
    end;
    
    if(a=5) and (b=11) and (c=15) and (d=3) and (f=8)then
    begin
    addtoreport('You won second price! prices won '+inttostr(premie2));
    inc(premie2);
    end;
    
    if(a=5) and (b=11) and (c=15) and (d=3)  then
    begin
    addtoreport('You won third price! prices won '+inttostr(premie3));
    inc(premie3);
    end;
    if(a=5) and (b=11) and (c=15) then
    begin
    addtoreport('You won fourth price! prices won '+inttostr(premie4));
    inc(premie4);
    end;
    
    
    if(a=5) and (b=11)  then
    begin
    addtoreport('You won fivth price! prices won '+inttostr(premie5));
    inc(premie5);
    end;
    
    writeln('');
    writeln('Number of attempts '+inttostr(h));
     until(h>9999)
    
    
    end.

  2. #2
    Join Date
    Nov 2006
    Posts
    2,369
    Mentioned
    4 Post(s)
    Quoted
    78 Post(s)

    Default

    I think there is something wrong with your logic. For example if I get all bug g right I wouldn't win second price...

    this is a lottery script I wrote for fun
    SCAR Code:
    program New;

    var
      RNumbers, YourNumber: TIntegerArray;
      RNumber, I, Right, Attempts: Integer;
     
    procedure DeclareNumbers;
    begin
      SetLength(YourNumber, 7);
      YourNumber[0] := 1;
      YourNumber[1] := 2;
      YourNumber[2] := 3;
      YourNumber[3] := 4;
      YourNumber[4] := 5;
      YourNumber[5] := 6;
      YourNumber[6] := 7;
    end;
     
     
    begin
      DeclareNumbers;
      ClearSameIntegers(YourNumber);
      if Length(YourNumber) < 7 then
      begin
        WriteLn('Do not choose same numbers!');
        Exit;
      end;
     
      for I := 0 to 6 do
        if not Inrange(YourNumber[I], 1, 42) then
        begin
          WriteLn('All numbers must be between 1 and 42!');
          Exit;
        end;
      repeat
        Inc(Attempts);
        for I := 0 to 6 do
        begin
          repeat
            RNumber := Random(1+42);
          until(not InIntArray(RNumbers, RNumber));
          SetLength(RNumbers, I+1);
          RNumbers[I] := RNumber;
          if InIntArray(YourNumber, RNumber) then Inc(Right);
        end;
        if Right > 4 then
        begin
          if Right = 5 then WriteLn(IntToStr(Right)+' right!   Attempts: '+IntToStr(Attempts));
          if Right = 6 then WriteLn(IntToStr(Right)+' right!   Attempts: '+IntToStr(Attempts)+'. Well done!');
          if Right = 7 then
          begin
            WriteLn(IntToStr(Right)+' right!   Attempts: '+IntToStr(Attempts)+'. WTFFFFFFFFF!');
            Exit;
          end;
        end;
        Right := 0;
      until(false);

    end.

    Also fixed ur standards a little bit so it's easier to read:
    SCAR Code:
    var
    a,b,c,d,e,f,g,h:integer;
    premie,premie2,premie3,premie4,premie5,premie6:integer;


    begin

      premie:=1;premie2:=1;premie3:=1;premie4:=1;premie5:=1;premie6:=1;

      repeat


        a:=(0)+random(47);
        b:=(0)+random(47);
        c:=(0)+random(47);
        d:=(0)+random(47);
        e:=(0)+random(47);
        f:=(0)+random(47);
        g:=(0)+random(47);

        if  not(a=b) or (a=c) or (a=d) or (a=e) or (a=f) or (a=g) then
        if  not(b=a) or (b=c) or (b=d) or (b=e) or (b=f) or (b=g) then
        if  not(c=a) or (c=b) or (c=d) or (c=e) or (c=f) or (b=g) then
        if  not(d=a) or (d=b) or (d=c) or (d=e) or (c=f) or (b=g) then
        if  not(e=a) or (e=b) or (e=c) or (e=b) or (e=f) or (e=g) then
        if  not(f=a) or (f=b) or (f=c) or (f=d) or (f=e) or (b=g) then
        if  not(g=a) or (g=b) or (g=c) or (g=d) or (g=e) or (g=f) then begin

          writeln(a);
          writeln(b);
          writeln(c);
          writeln(d);
          writeln(e);
          writeln(f);
          writeln(g);
          inc(h);


        end;
        if(a=5) and (b=11) and (c=15) and (d=3) and (f=8) and (g=20) then
        begin
          addtoreport('You won first price! prices won '+inttostr(premie));
          terminatescript;
          inc(premie);
        end;

        if(a=5) and (b=11) and (c=15) and (d=3) and (f=8)then
        begin
          addtoreport('You won second price! prices won '+inttostr(premie2));
          inc(premie2);
        end;

        if(a=5) and (b=11) and (c=15) and (d=3)  then
        begin
          addtoreport('You won third price! prices won '+inttostr(premie3));
          inc(premie3);
        end;
        if(a=5) and (b=11) and (c=15) then
        begin
          addtoreport('You won fourth price! prices won '+inttostr(premie4));
          inc(premie4);
        end;


        if(a=5) and (b=11)  then
        begin
          addtoreport('You won fivth price! prices won '+inttostr(premie5));
          inc(premie5);
        end;

        writeln('');
        writeln('Number of attempts '+inttostr(h));
      until(h>9999)
    end.


    Edit: Woot I got 7 right with my script: 7 right! Attempts: 51845837. WTFFFFFFFFF!
    Last edited by weequ; 02-23-2011 at 07:56 PM.

  3. #3
    Join Date
    Aug 2008
    Location
    Kelowna, B.C
    Posts
    188
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Well now I know how the and and or operators work in Simba :P
    I was trying to use | like in C++.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •