Skip to content

Med-Elalj/Lem-in

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lem-in

Description

lem-in is a program that simulates ants moving through a colony of rooms and tunnels. The objective is to calculate and display the quickest way to get a specified number of ants from the starting room (##start) to the ending room (##end) with as few moves as possible.

How it works

  • The colony consists of rooms connected by tunnels.
  • All ants start in the ##start room, and the goal is to move them to the ##end room.
  • The program must find and display the fastest way to achieve this.
  • The shortest path is not always the most optimal due to the potential for traffic jams.

Input

  • The program reads from a file passed as an argument, which contains:
    • The number of ants.
    - Descriptions of rooms and their coordinates. - Tunnels connecting the rooms. - - Rooms marked as start or end. ##start -- or ##end - NOTE: -- Other than "##start" and "##end" any thing after a (#) is a comment. # -- Empty lines are ignored.
  • Example of file format:
$ go run . test0.txt
3
##start
1 23 3 # room 1 is the start room.
2 16 7
3 16 3 # room 3 is at ( X = 16 ) and ( Y = 3 ).
4 16 5
5 9 3  # commnent.
6 1 5
7 4 8
##end
0 9 5
0-4 # Room 0 is connected to room 4 and 4 is connected to room 0.
0-6
1-3
4-3
5-2
3-5
4-2
2-1
# this line and the next one are ignored.

7-6
7-2
7-4
6-5

Error Handling

  • The program must handle a variety of invalid inputs, such as:
  • No start or end room.
  • Invalid number of ants.
  • Invalid room or tunnel descriptions.
  • When an error is encountered, an appropriate message such as ERROR: invalid data format should be returned.

Features

  • Multiple paths can be taken by the ants at the same time.
  • A tunnel can only be used by one ant per move.
  • Each room can only hold one ant at a time, except for the ##start and ##end rooms, which can hold multiple ants.

Usage

To run the program, use the following command:

$ go run . <file.txt>

or

$ go build .
$ ./lem-in <file.txt>

Replace file.txt with the name of your input file.

testing :

Clone the repository:

https://github.com/Med-Elalj/lemin-test
git clone https://github.com/Med-Elalj/lemin-test

Authors

special thanks to our friend @yaouzddou for helping us with the logic to make the RemoveRepetition function.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages