Recent

Author Topic: Can you Help to make a program using Berger Table a game schedule  (Read 2188 times)

marioorosa

  • Newbie
  • Posts: 6
can you help me to make a game schedule

af0815

  • Hero Member
  • *****
  • Posts: 1407
regards
Andreas

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Can you Help to make a program using Berger Table a game schedule
« Reply #2 on: April 20, 2023, 12:46:59 pm »
can you help me to make a game schedule
Sure, what have you tried, where are you stuck?
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

marioorosa

  • Newbie
  • Posts: 6
Re: Can you Help to make a program using Berger Table a game schedule
« Reply #3 on: April 24, 2023, 08:01:02 am »
I saw a sample program

set((x, y) for x in teams for y in teams if x != y)

from random import sample
def season_schedule_order(teams, pairs):
    n_games_per_round = len(teams) // 2
    last_pairs = set()
    while pairs:
        r_pairs = set(sample(pairs, n_games_per_round))
        # Check that each team is present once in the round.
        r_teams = set(x for (x, y) in r_pairs) | set(y for (x, y) in r_pairs)
        if r_teams != teams:
            continue
        # Check that two teams doesn't face each other again.
        rev_pairs = set((y, x) for (x, y) in r_pairs)
        if rev_pairs & last_pairs:
            continue
        pairs -= r_pairs
        for p in r_pairs:
            yield p
        last_pairs = r_pairs

teams = set(['aik', 'djurgarden', 'elfsborg', 'gais',
             'gefle', 'hacken', 'halmstad', 'helsingborg'])
pairs = set((x, y) for x in teams for y in teams if x != y)
for (ht, at) in season_schedule_order(teams, pairs):
    print '%-20s %-20s' % (ht, at)

 is this a pascal programming language?


Zvoni

  • Hero Member
  • *****
  • Posts: 3226
Re: Can you Help to make a program using Berger Table a game schedule
« Reply #4 on: April 24, 2023, 08:07:27 am »
looks like python
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12593
  • FPC developer.
Re: Can you Help to make a program using Berger Table a game schedule
« Reply #5 on: April 24, 2023, 08:49:11 am »
And it is not exactly the best algorithm. It randomly seems to try something and then check if there are conflicts.


Doesn't seem appropriate as a homework result

marioorosa

  • Newbie
  • Posts: 6
Re: Can you Help to make a program using Berger Table a game schedule
« Reply #6 on: April 24, 2023, 09:30:13 am »
can you help make a simple program in pascal?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12593
  • FPC developer.
Re: Can you Help to make a program using Berger Table a game schedule
« Reply #7 on: April 24, 2023, 10:03:12 am »
can you help make a simple program in pascal?

Surely we can help, and point out mistakes. What do you have so far ?

marioorosa

  • Newbie
  • Posts: 6
Re: Can you Help to make a program using Berger Table a game schedule
« Reply #8 on: April 24, 2023, 10:48:59 am »
this my first time to make a program.
this my program so far
Program game_shedule(input, output);
uses crt;
var numteam,numgames:integer;
     
begin
       clrscr;
       writeln('Enter Number of Teams : ');
       readln(numteam);
       writeln('Enter Number of Games: ');
       readln(numgames);
end.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12593
  • FPC developer.
Re: Can you Help to make a program using Berger Table a game schedule
« Reply #9 on: April 24, 2023, 10:54:51 am »
Very good! I see no problems in that code.

marioorosa

  • Newbie
  • Posts: 6
Re: Can you Help to make a program using Berger Table a game schedule
« Reply #10 on: April 25, 2023, 04:41:02 am »
i don't know how to generate the games schedule

marioorosa

  • Newbie
  • Posts: 6
Re: Can you Help to make a program using Berger Table a game schedule
« Reply #11 on: April 25, 2023, 04:54:35 am »
what is the best to use the procedure or the functional method

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Can you Help to make a program using Berger Table a game schedule
« Reply #12 on: April 25, 2023, 05:46:01 am »
Both do the same, they execute code.
The biggest difference between those methods is, that a function returns a result.
So it depend on what you try to do, to choose what is best.
Code: Pascal  [Select][+][-]
  1. function Example(Argument: Type): ResultType;
Code: Pascal  [Select][+][-]
  1. procedure Example(Argument: Type);
What happen in the methods you define with a simple
Code: Pascal  [Select][+][-]
  1. begin
  2.   ...your code...
  3. end;
Best would be that you read a Pascal Handbook to get a little common to its syntax.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

MarkMLl

  • Hero Member
  • *****
  • Posts: 8525
Re: Can you Help to make a program using Berger Table a game schedule
« Reply #13 on: April 25, 2023, 10:12:27 am »
what is the best to use the procedure or the functional method

That depends on /exactly/ what you mean.

Pascal is a procedural or imperative language.

LISP is often considered to be a functional language.

Pascal supports language structures called procedures and functions, but that doesn't mean that it's a functional language.

As everybody else has said: demonstrate that you've made some attempt to solve the problem yourself.

Oh, and if this is homework or a project associated with a course, assume that your instructor is reading this thread and will not be impressed if you don't at least /try/ to do some relevant work.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

 

TinyPortal © 2005-2018