Browse Source

Merge pull request #450 from 01-edu/lem-in

Lem in
content-update
LEEDASILVA 4 years ago committed by GitHub
parent
commit
cab52d5dfa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 297
      subjects/lem-in/lem-in-examples.en.md
  2. 339
      subjects/lem-in/lem-in.audit.en.md
  3. 187
      subjects/lem-in/lem-in.en.md

297
subjects/lem-in/lem-in-examples.en.md

@ -0,0 +1,297 @@
## lem-in-examples
- Create your file and copy the examples into it.
### example00
```
4
##start
0 0 3
2 2 5
3 4 0
##end
1 8 3
0-2
2-3
3-1
```
### example01
```
10
##start
start 1 6
0 4 8
o 6 8
n 6 6
e 8 4
t 1 9
E 5 9
a 8 9
m 8 6
h 4 6
A 5 2
c 8 1
k 11 2
##end
end 11 6
start-t
n-e
a-m
A-c
0-o
E-a
k-end
start-h
o-n
m-end
t-E
start-0
h-A
e-end
c-k
n-m
h-n
```
### example02
```
20
##start
0 2 0
1 4 1
2 6 0
##end
3 4 1
0-1
0-3
1-2
3-2
```
### example03
```
4
4 5 4
##start
0 1 4
1 3 6
##end
5 6 4
2 3 4
3 3 1
0-1
2-4
1-4
0-2
4-5
3-0
4-3
```
### example04
```
9
##start
richard 0 6
gilfoyle 6 3
erlich 9 6
dinish 6 9
jimYoung 11 7
##end
peter 14 6
richard-dinish
dinish-jimYoung
richard-gilfoyle
gilfoyle-peter
gilfoyle-erlich
richard-erlich
erlich-jimYoung
jimYoung-peter
```
### example05
```
9
#rooms
##start
start 0 3
##end
end 10 1
C0 1 0
C1 2 0
C2 3 0
C3 4 0
I4 5 0
I5 6 0
A0 1 2
A1 2 1
A2 4 1
B0 1 4
B1 2 4
E2 6 4
D1 6 3
D2 7 3
D3 8 3
H4 4 2
H3 5 2
F2 6 2
F3 7 2
F4 8 2
G0 1 5
G1 2 5
G2 3 5
G3 4 5
G4 6 5
H3-F2
H3-H4
H4-A2
start-G0
G0-G1
G1-G2
G2-G3
G3-G4
G4-D3
start-A0
A0-A1
A0-D1
A1-A2
A1-B1
A2-end
A2-C3
start-B0
B0-B1
B1-E2
start-C0
C0-C1
C1-C2
C2-C3
C3-I4
D1-D2
D1-F2
D2-E2
D2-D3
D2-F3
D3-end
F2-F3
F3-F4
F4-end
I4-I5
I5-end
```
### example06
```
100
##start
richard 0 6
gilfoyle 6 3
erlich 9 6
dinish 6 9
jimYoung 11 7
##end
peter 14 6
richard-dinish
dinish-jimYoung
richard-gilfoyle
gilfoyle-peter
gilfoyle-erlich
richard-erlich
erlich-jimYoung
jimYoung-peter
```
### example07
```
1000
##start
richard 0 6
gilfoyle 6 3
erlich 9 6
dinish 6 9
jimYoung 11 7
##end
peter 14 6
richard-dinish
dinish-jimYoung
richard-gilfoyle
gilfoyle-peter
gilfoyle-erlich
richard-erlich
erlich-jimYoung
jimYoung-peter
```
### badexample00
```
0
4 5 4
##start
0 1 4
1 3 6
##end
5 6 4
2 3 4
3 3 1
0-1
2-4
1-4
0-2
4-5
3-0
4-3
```
### badexample01
```
20
##start
0 2 0
1 7 0
2 13 0
3 18 0
##end
4 23 0
5 7 6
6 10 6
7 13 6
8 16 6
9 7 2
10 7 4
11 13 2
12 15 2
13 17 2
14 19 2
15 21 2
16 9 4
0-1
0-5
0-9
0-10
1-2
2-3
3-3
5-6
6-7
7-8
8-7
9-2
10-16
1-11
11-12
12-13
13-14
14-15
15-1
16-7
```

339
subjects/lem-in/lem-in.audit.en.md

@ -0,0 +1,339 @@
#### Functional
##### Try to run `"./lem-in example00.txt"`.
###### Is the program able to read the ant farm in this standard input?
###### Does the program accept only the commands `##star` and `##end`?
##### Try running the program with a valid example of your choice.
```console
number_of_ants
the_rooms
the_links
Lx-y
Lx-y Lx-y
Lx-y Lx-y Lx-y
Lx-y Lx-y
Lx-y
```
###### Are the commands and the ants movements printed with the right format? One line per turn, `N` movements per turn, movements defined by `Lx-y` `x` being the ant and `y` being the room, as it shows above?
##### Try running the program with [example00](https://public.01-edu.org/subjects/lem-in/lem-in-examples.en).
```
student$ ./lem-in example00.txt
4
##start
0 0 3
2 2 5
3 4 0
##end
1 8 3
0-2
2-3
3-1
L1-2
L1-3 L2-2
L1-1 L2-3 L3-2
L2-1 L3-3 L4-2
L3-1 L4-3
L4-1
student$
```
###### Does it present the quickest path possible with the same number of turns as the result above?
##### Try running the program with [example01](https://public.01-edu.org/subjects/lem-in/lem-in-examples.en).
```
student$ ./lem-in example01.txt
10
##start
start 1 6
0 4 8
o 6 8
n 6 6
e 8 4
t 1 9
E 5 9
a 8 9
m 8 6
h 4 6
A 5 2
c 8 1
k 11 2
##end
end 11 6
start-t
n-e
a-m
A-c
0-o
E-a
k-end
start-h
o-n
m-end
t-E
start-0
h-A
e-end
c-k
n-m
h-n
L1-t L2-h L3-0
L1-E L2-A L3-o L4-t L5-h L6-0
L1-a L2-c L3-n L4-E L5-A L6-o L7-t L8-h L9-0
L1-m L2-k L3-e L4-a L5-c L6-n L7-E L8-A L9-o L10-t
L1-end L2-end L3-end L4-m L5-k L6-e L7-a L8-c L9-n L10-E
L4-end L5-end L6-end L7-m L8-k L9-e L10-a
L7-end L8-end L9-end L10-m
L10-end
student$
```
###### Does it present the quickest path possible with the same number of turns as the result above?
##### Try running the program with [example02](https://public.01-edu.org/subjects/lem-in/lem-in-examples.en).
```
student$ ./lem-in example02.txt
20
##start
0 2 0
1 4 1
2 6 0
##end
3 4 1
0-1
0-3
1-2
3-2
L1-3 L2-3 L3-3 L4-3 L5-3 L6-3 L7-3 L8-3 L9-3 L10-3 L11-3 L12-3 L13-3 L14-3 L15-3 L16-3 L17-3 L18-3 L19-3 L20-3
student$
```
###### Does it present the quickest path possible with the same number of turns as the result above?
##### Try running the program with [example03](https://public.01-edu.org/subjects/lem-in/lem-in-examples.en).
```
student$ ./lem-in example03.txt
4
4 5 4
##start
0 1 4
1 3 6
##end
5 6 4
2 3 4
3 3 1
0-1
2-4
1-4
0-2
4-5
3-0
4-3
L1-1
L1-4 L2-1
L1-5 L2-4 L3-1
L2-5 L3-4 L4-1
L3-5 L4-4
L4-5
student$
```
###### Does it present the quickest path possible with the same number of turns as the result above?
##### Try running the program with [example04](https://public.01-edu.org/subjects/lem-in/lem-in-examples.en).
```
student$ ./lem-in example04.txt
9
##start
richard 0 6
gilfoyle 6 3
erlich 9 6
dinish 6 9
jimYoung 11 7
##end
peter 14 6
richard-dinish
dinish-jimYoung
richard-gilfoyle
gilfoyle-peter
gilfoyle-erlich
richard-erlich
erlich-jimYoung
jimYoung-peter
L1-gilfoyle L3-dinish
L1-peter L2-gilfoyle L3-jimYoung L5-dinish
L2-peter L3-peter L4-gilfoyle L5-jimYoung L7-dinish
L4-peter L5-peter L6-gilfoyle L7-jimYoung L9-dinish
L6-peter L7-peter L8-gilfoyle L9-jimYoung
L8-peter L9-peter
student$
```
###### Does it present the quickest path possible with the same number of turns as the result above?
##### Try running the program with [example05](https://public.01-edu.org/subjects/lem-in/lem-in-examples.en).
```
student$ ./lem-in example05.txt
9
#rooms
##start
start 0 3
##end
end 10 1
C0 1 0
C1 2 0
C2 3 0
C3 4 0
I4 5 0
I5 6 0
A0 1 2
A1 2 1
A2 4 1
B0 1 4
B1 2 4
E2 6 4
D1 6 3
D2 7 3
D3 8 3
H4 4 2
H3 5 2
F2 6 2
F3 7 2
F4 8 2
G0 1 5
G1 2 5
G2 3 5
G3 4 5
G4 6 5
H3-F2
H3-H4
H4-A2
start-G0
G0-G1
G1-G2
G2-G3
G3-G4
G4-D3
start-A0
A0-A1
A0-D1
A1-A2
A1-B1
A2-end
A2-C3
start-B0
B0-B1
B1-E2
start-C0
C0-C1
C1-C2
C2-C3
C3-I4
D1-D2
D1-F2
D2-E2
D2-D3
D2-F3
D3-end
F2-F3
F3-F4
F4-end
I4-I5
I5-end
L1-A0 L4-B0 L6-C0
L1-A1 L2-A0 L4-B1 L5-B0 L6-C1
L1-A2 L2-A1 L3-A0 L4-E2 L5-B1 L6-C2 L9-B0
L1-end L2-A2 L3-A1 L4-D2 L5-E2 L6-C3 L7-A0 L9-B1
L2-end L3-A2 L4-D3 L5-D2 L6-I4 L7-A1 L8-A0 L9-E2
L3-end L4-end L5-D3 L6-I5 L7-A2 L8-A1 L9-D2
L5-end L6-end L7-end L8-A2 L9-D3
L8-end L9-end
student$
```
###### Does it present the quickest path possible with the same number of turns as the result above?
##### Try running the program with [badexample00](https://public.01-edu.org/subjects/lem-in/lem-in-examples.en).
```
student$ ./lem-in badexample00.txt
ERROR: invalid data format
student$
```
###### Does it present the right result as above?
##### Try running the program with [badexample01](https://public.01-edu.org/subjects/lem-in/lem-in-examples.en).
```
student$ ./lem-in badexample01.txt
ERROR: invalid data format
student$
```
###### Does it present the right result as above?
##### Try running the program with example06.txt and with 100 ants.
###### Is the real time less than 0.5 seconds?
##### Try running the program with example07.txt and with 1000 ants.
###### Is the real time less than 1.5 seconds?
##### Try running the program with a valid example of your choice.
###### Are the ants alone in each room?
##### Try running the program with a valid example of your choice.
###### At the end can you confirm that all the ants present in the `##end` room?
##### Try to run the program with an example of your choice multiple times.
###### Are the results always correct?
###### Does the program handles all the error cases with a message?
###### Is the solution making the ants cross the farm from `##start` to `##end` properly?
#### General
###### +Does the program present an ant farm visualizer?
###### +Is it possible to see the ants moving?
###### +Is the visualizer in 3D?·4
#### Basic
###### +Does the project run quickly and effectively (favoring of recursive, no unnecessary data requests, etc.)?
###### +Is there a test file for this code?
###### +Are the tests checking each possible case?
###### +Does the code obey the [good practices](https://public.01-edu.org/subjects/good-practices.en)?
#### Social
###### +Did you learn anything from this project?
###### +Would you recommend/nominate this program as an example for the rest of the school?

187
subjects/lem-in/lem-in.en.md

@ -0,0 +1,187 @@
## lem-in
### Objectives
This project is meant to make you code a digital version of an ant farm.
Create a program `lem-in` that will read from a file (describing the ants and the colony) given in the arguments.
Upon successfully finding the quickest path, `lem-in` will display the content of the file passed as argument and each move the ants make from room to room.
How does it work?
- You make an ant farm with tunnels and rooms.
- You place the ants on one side and look at how they find the exit.
You need to find the quickest way to get `n` ants across a colony (composed of rooms and tunnels).
- At the beginning of the game, all the ants are in the room `##start`. The goal is to bring them to the room `##end` with as few moves as possible.
- The shortest path is not necessarily the simplest.
- Some colonies will have many rooms and many links, but no path between `##start` and `##end`.
- Some will have rooms that link to themselves, sending your path-search spinning in circles, some will have too many/too few ants, no `##start` or `##end`, duplicated rooms, links to unknown rooms, rooms with invalid coordinates and a variety of other invalid or poorly-formatted input. In this cases the program will return an error message `ERROR: invalid data format`.
You must display your results on the standard output in the following format :
```console
number_of_ants
the_rooms
the_links
Lx-y Lz-w Lr-o ...
```
- x, z, r represents the ants numbers (going from 1 to number_of_ants) and y,
w, o represents the rooms names.
- A room is defined by `"name coord_x coord_y"`, and will usually look like `"Room 1 2", "nameoftheroom 1 6", "4 6 7"`.
- The links are defined by `"name1-name2"` and will usually look like `"1-2", "2-5"`.
Here is an example of this in practice :
```
##start
1 23 3
2 16 7
#comment
3 16 3
4 16 5
5 9 3
6 1 5
7 4 8
##end
0 9 5
0-4
0-6
1-3
4-3
5-2
3-5
#another comment
4-2
2-1
7-6
7-2
7-4
6-5
```
Which corresponds to the following representation :
```console
_________________
/ \
____[5]----[3]--[1] |
/ | / |
[6]---[0]----[4] / |
\ ________/| / |
\ / [2]/________/
[7]_________/
```
This project will help you learn about :
- Algorithmics
- Ways to receive data
- Ways to output data
- Manipulation of strings
- Manipulation of structures
### Bonus
- As a bonus you have to create an ant farm visualizer that shows the ants moving trough the colony.
- Here is an usage example : `./lem-in ant-farm.txt | ./visualizer`
- The coordinates of the room will be useful only here.
### Instructions
- You need to create tunnels and rooms.
- A room will never start with the letter `L` or with `#` and must have no spaces.
- You join the rooms together with as many tunnels as you need.
- A tunnel joins only two rooms together never more than that.
- A room can be linked to an infinite number of rooms and by as many tunnels as deemed necessary.
- Each room can only contain one ant at a time (except at `##start` and `##end` which can contain as many ants as necessary).
- To be the first to arrive, ants will need to take the shortest path or paths. They will also need to avoid traffic jams as well as walking all over their fellow ants.
- You will only display the ants that moved at each turn, and you can move each ant only once and through a tunnel (the room at the receiving end must be empty).
- The rooms names will not necessarily be numbers, and in order.
- Any unknown command will be ignored.
- The program must handle errors carefully. In no way can it quit in an unexpected manner.
- The coordinates of the rooms will always be `int`.
- Your project must be written in **Go**.
- The code must respect the [**good practices**](https://public.01-edu.org/subjects/good-practices.en).
- It is recommended that the code should present a **test file**.
### Usage
Example 1 :
```
student$ ./lem-in test0.txt
3
##start
1 23 3
2 16 7
##end
0 9 5
0-4
0-6
1-3
4-3
5-2
3-5
L1-2
L1-4 L2-2
L1-0 L2-4 L3-2
L2-0 L3-4
L3-0
student$
```
Example 2 :
```
student$ ./lem-in test1.txt
3
##start
0 1 0
##end
1 5 0
2 9 0
3 13 0
0-2
2-3
3-1
L1-2
L1-3 L2-2
L1-1 L2-3 L3-2
L2-1 L3-3
L3-1
student$
```
Example 3 :
```
student$ ./lem-in test1.txt
3
2 5 0
##start
0 1 2
##end
1 9 2
3 5 4
0-2
0-3
2-1
3-1
2-3
L1- 2 L2- 3
L1- 1 L2- 1 L3- 2
L3- 1
student$
```
Loading…
Cancel
Save