Repository concerning the test and the main problem of the Google Hashcode competition of 2022.
| Name | Surname | Github Username |
|---|---|---|
| Simone | Alghisi | Simone-Alghisi |
| Samuele | Bortolotti | samuelebortolotti |
| Francesco | Bozzo | FrancescoBozzo |
| Samuele | Conti | Samaretas |
The repository is structured in the following way:
├── practice-problem
│ ├── Gemfile
│ ├── Gemfile.lock
│ ├── input
│ │ ├── a_an_example.in.txt
│ │ ├── b_basic.in.txt
│ │ ├── c_coarse.in.txt
│ │ ├── d_difficult.in.txt
│ │ └── e_elaborate.in.txt
│ ├── lib
│ │ └── main.rb
│ ├── output
│ ├── problem_statement.pdf
│ └── Rakefile
├── qualification-round
│ ├── Gemfile
│ ├── Gemfile.lock
│ ├── input
│ │ ├── a_an_example.in.txt
│ │ ├── b_better_start_small.in.txt
│ │ ├── c_collaboration.in.txt
│ │ ├── d_dense_schedule.in.txt
│ │ ├── e_exceptional_skills.in.txt
│ │ └── f_find_great_mentors.in.txt
│ ├── lib
│ │ └── main.rb
│ ├── output
│ ├── problem_statement.pdf
│ └── Rakefile
└── README.mdInside of each folder there is everything you need to run the Ruby scripts.
The training problem has been adressed by me employing with a very basic genetic algorithm.
To run the project code you can either run:
ruby lib/main.rb path_to_input_file n_generation n_populationWhere:
- path_to_input_file [String] is the path of the input file you want to run
- n_generation [Integer] is the total number of generation you want to run
- n_population [Integer] is the total number of dna you want in the population
Or employ one of the following Rake tasks:
rake code:run_file['file_path']To run the file_path file with the default settings (specified in the Rakefile).
Or run:
rake code:zipTo run all the files in the 'input' directory with the default settings.
You can run:
rake code:run_allTo generate a folder named code.zip containing only the code of the repository.
For more information run
rake -T
The qualification problem has been adressed by the team employing a greedy strategy.
The code present in the repository is not the one submitted during the competition, altough is quite similar in the behaviour.
The original solution has been proposed in Python, and since we were in a hurry, the code was quite difficult to understand; for this reason I have restructured the code and upgrade it by writing it in Ruby (since I am more familiar with it).
To run the project code you can either run:
ruby lib/main.rb path_to_input_file strategyWhere:
- path_to_input_file [String] is the path of the input file you want to run
- strategy [Integer] either 0 or 1, which is the strategy to employ during the run
Or employ one of the following Rake tasks:
rake "code:run_file['file_path', 0]"Or equivalently with 1 instead of 0 for the other greedy approach.
To run the file_path file with the default settings (specified in the Rakefile).
Or run:
rake code:run_all[0]To run all the files in the 'input' directory with the default settings.
You can run:
rake code:zipTo generate a folder named code.zip containing only the code of the repository.
For more information run
rake -T