Skip to content

kodefish/ETH-AlgoLab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

Algorithms Lab

This repo contains my solutions to the algorithms lab of ETH Zürich. The lab consists of problems every week that must be solved via an algorithm.

The primary language to solve the challenges is C++. I strive as much as possible to document my code and my algorithms. The description of the problems may be wonky, so I suggest that you give the associated PDF a read for a detailed explanation of the problem.

Overview

WeekProblemScoreSolution
1Even Pairs100Partial Sums
1Build The Sum100Common Sense
1Dominoes100Sliding over the dominoes
1Even Matrices70Precomputation
PotW 1Deck of Cards100Precomputation + sliding window
2Burning Coins100Dynamic Programming
2Beach Bars100Sliding Windowm & DP
2The Great Game100Bottom Up Dynamic Programming
2Search Snippets75Sliding Windowm
PotW 2Magician and the Coin100Dynamic Programming & Memoization
3Hit100CGAL intersection testing
3First Hit99CGAL intersection testing
3Antenna100CGAL Min Circle
3Almost Antenna100CGAL Min Circle and Support Points
PotW 3Defensive Line100Dynamic Programming
4First Steps with BGL100MST and Dijkstra Shortest Paths
4Ant Challenge100MST and Dijkstra Shortest Paths
4Important Bridges100Biconnected Components
4Buddy Selection100Set Intersection & Group Matching
4Shortest Paths100Dijkstra
PotW 4Hiking Maps100CGAL Predicate Testing & Sliding Window
5Boats100Greedy Algorithm
5Attack of the Clones0-
5Light at the Museum100Split & List
5Punch0-
5High School Teams0-
PotW 5Planet Express100Shortest Paths & Vertex Aggregation
6Coin Tossing100Flow Computation
6Shopping Trip100Flow Computation
6Kingdom Defence100Flow Computation with min/max per edge
6Tetris100Flow Computation & Vertex splitting
Potw 6Octopussy100Greedy Algorithm
7Maximum100CGAL LP/QP
7Diet100QP
7Portfolios100QP
7Inball100CGAL LP - have to set up right LP
PotW 7London100Flow Computation & Vertex Aggregation
8Graypes100Delaunay Triangulation
8Bistro100Delaunay Triangulagion
8H1N180Delaunay Triangulation + DFS
8Germs100Delaunay triangulation
PotW 8Suez100LP
8Satellites100Min Vertex Cover
8Algocoon100MinFlow-MaxCut
8Real Estate Market100MaxCost-MaxFlow (using MinCostMaxFlow)
8Canteen100MaxCost-MaxFlow
8Marathon20MinCost-MaxFlow with precomp and binary search
PotW 9GoldenEye100CGAL Proximity Structure (Vornoi)
9New Tiles0DP with bitmatching (not implemented)
9On Her Majesty’s Secret Service100Minimum bottleneck matching (minimizing edge weight
9Light the Stage100CGAL Proximity Checking
9Evolution30Naive path walk
9Return of the Jedi0-
9Poker Chips0DP with bitmatching
PotW 10India
10The Empire Strikes Back100LP + Delaunay triangulation precomputation
10Planks60Basically bruteforcing (Correct is to use Split & List
10Carsharing100MinCostMaxFlow
10San Fransisco
PotW 11New York
11Light Pattern
11Casino Royale100MinCostMaxFlow (same idea as carsharing)
11Radiation
11Hong Kong
PotW 12World Cup
12Bob’s Burden
12Corbusier
12Cantonal Courier
12Clues602-color BFS + Delaunay
12Moving Blocks100Greedy + multiset
PotW 13Fleetrace

Compilation and Running

STL/BGL Files

To compile the cpp files:

g++ -Wall -O3 filename.cpp -o filename.o

To run the file with a given input and redirect output to a file

./filename.o < testsets/test{i}.in > test{i}.out

To compare with the expected output, use `diff`

diff test{i}.out testsets/test{i}.out

Alternatively, you can do the previous in one line

diff <(./filename.o < testsets/test{i}.in) testsets/test{i}.out

CGAL

Compiling CGAL files is slightly different, it makes use of the cgal_create_cmake_script. In order to avoid to seperate the source code from compiled files, take advantage of an additional build folder. Compile as follows:

cgal_create_cmake_script
mkdir build && cd build
cmake ..
make

To run, the procedure is the same as for STL/BGL files.

About

ETH algorithms lab exercises

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published