Solutions for problems given in ETH course Algorithms Lab in Fall 2020

Overview

Algolab2020

Solutions for problems given in ETH course Algorithms Lab in Fall 2020.

The code for these problems is written with the following in mind:

  • Readability. It is prevalent in competitive programming to use macros, and extremely dense and unreadable code. I dont find the price for longer names and few more lines too high. I often rewrite the problems to try something new or to see performance gain/loss therefore even I appreciate this.
  • Performance. Lot of the problems could be solved with considerably less code. It would pass within the time limits. However, I tried to make the code run fast to a reasonable extent.
  • Code quality. I know this is competitive programming and it does not matter much here but I found out I do better when I go a bit slower in terms of writing code and then avoid some of small bugs/issues. This is the main reason why you can see const everywhere and special function to load data (to have the loaded data also const).

Should you find some typo, bug, improvement or anything related feel free to message me at my email simon.hrabec on gmail.

How to use this repository:

  • Copy-paste relevant code snippets to begin your work
  • If stuck and gave the problem already some time read the minimal amount of problem solution to get yourself unstuck
  • After finishing the task check the solutions for alternative ways to approach it
  • Check the code if you just wanna compare the code of your solution and see how other people write C++

Featured solutions

Week Problem of the Week 1st problem 2nd problem 3rd problem 4th problem
3 Antenna First Hit Hit
5 Motorcycles Asterix the Gaul
6 Tracking
7 Inball Radiation What is the Maximum
8 Surveillance Photograph Germs
9 Legions
10 Asterix and the Chariot Race Asterix in Switzerland New York
11 Fleetrace Fighting Pits of Meereen Hand Lestrade Return of the Jedi
12 Car Sharing Hong Kong India Moving Books
13 Evolution Marathon Punch Sith

Techniques/algorithms/data structures

Code snippets

One of the most annoying thing about ALGOLAB (after the hard thinking ^^) is to always copy paste the right definitions for boost graphs, CGAL LP or flow edge adder. For this reason I put together a small set of useful snippets that should cover all your basic needs. It shoud prevent you from always searching the lecture notes or code examples for the relevant lines or going to the CGAL docs for basic syntax. You should find it here at one place. Some of the snippets are in fact the code from lectures or code examples (modified to some extent), some are written from scratch. The all attributions are listed in the code snippet descriptions.

You might also like...
Given two arrays X and Y of positive integers, find the number of pairs such that x^y y^x (raised to power of) where x is an element from X and y is an element from Y.

Number-of-pairs Given two arrays X and Y of positive integers, find the number of pairs such that x^y y^x (raised to power of) where x is an element

The problem consists in determining all shortest paths between pairs of nodes in a given graph.

All-Pairs-Shortest-Path-Problem-Parallel-Computing The problem consists in determining all shortest paths between pairs of nodes in a given graph. Exe

πŸ‘¨β€πŸ’» Solution of everyday coding problem given in 30DaysofCode contest held on Hackerrank.
πŸ‘¨β€πŸ’» Solution of everyday coding problem given in 30DaysofCode contest held on Hackerrank.

πŸ‘¨β€πŸ’»30DaysOfCode-PhoenixClub This repository gives you the solution of everyday problems given in 30DaysOfCode contest which is held on Hackerrank. N

180+ Algorithm & Data Structure Problems using C++
180+ Algorithm & Data Structure Problems using C++

180+ Algorithm & Data Structure Problems using C++

LeetCode Coding Problems

LeetCode LeetCode Coding Problems Author: Abhishek Kumar My C++ Code for LeetCode OJ. Please give this repo a ⭐️ if it inspires you. Thanks. ☺️ # Titl

Problem solution of Quera's Problems with different programming language and approach.

Quera-Problem-Solution Problem solution of Quera's Problems with different programming language and approach. How to use Each folder is the category o

Leetcode solutions in C++ for coding interviews.

LeetCode Solutions This repository will consist solutions focusing on the concepts of DataStructures and Algorithms. Daily updates! Please come back a

Leetcode solutions collection

Leetcode Questions This repository aims to have solutions to all Leetcode Questions that are available for free. List Of Questions The list of all que

Comments
  • Add code snippets

    Add code snippets

    Add snippets with the following:

    • Dijsktra
    • max flow
    • max flow min cost
    • EMST
    • Graph coloring (two colors)
    • DT - vertices with data
    • DT - faces with data
    • iterating over vertex (circulator)
    • data loading
    • edge adder - max flow
    • edge adder - max flow (lambda)
    • edge adder - max flow min cost
    • edge adder - max flow min cost (lambda)
    • Binary search (all variants)
    opened by simon-hrabec 0
Owner
null
This repository aims to contain solutions and explanations to various competitive programming problems, which may be important for interviews and online tests of different companies.

Competitive Programming Solutions Compilation Hello everyone ?? This repository contains solutions and explanations to various competitive programming

Abhinav Agrawal 34 Oct 9, 2022
My solutions to problems of Global Coding Challenge 2021

Global Coding Challenge 2021 Organized by Credit Suisse This repo contains all the problems of the competition and solutions to them submitted by bpan

Bibek Panthi 1 Nov 7, 2021
Solutions of assignments, problems of DSA bootcamp in C++ by Kunal kushwaha OR Community Classroom

Problem-solution Solutions of assignments, problems of DSA bootcamp in C++ by Kunal kushwaha OR Community Classroom DSA-Bootcamp ?? Assignments ✨ Solu

kapil vaishnav 1 Nov 6, 2021
LeetCode Problems' Solutions

leetcode LeetCode Problems' Solutions # Title Solution Difficulty 6 Remove Duplicates from Sorted List C++ Easy 5 Palindrome Number C++ Easy 4 Median

Sandro 1 Dec 28, 2021
This Repository is based on Striver DSA Sheet problems solved by me for Interview preparation. All solutions are coded in C++ language.

Striver DSA Sheet Striver DSA Sheet Link This Repository is based on Striver DSA Sheet problems solved by me (sometimes with help from different resou

Sayantan Banerjee 13 Nov 11, 2022
Data Structure and Algorithms problems across various platforms.

Covering various practice problems of Arrays, Stacks, queue, tree, graph and different Algorithms. A collection of solutions for Data Structure and Algorithms problems across various platforms in different languages.

Nivedita Singh 42 Oct 29, 2022
Data structures and algorithms topicwise practice problems in C++

Data-Structure-and-Algorithm data structures and algorithms topicwise practice problems in C++ Q. find maximum element in an array Q. Sum of all Subar

Kamdev Kumar 2 Jan 10, 2022
Data structures and algorithms course, winter 2021/22

Data Structures and Algorithms 2021/22 Repository for the "Data structures and algorithms" course for the 2021/22 academic year. Structure lectures --

Atanas Semerdzhiev 19 Jul 21, 2022
Data Structures and Algorithms course (IIC2133-PUC)

Data-Structures-And-Algorithms This are the homeworks of Jose Antonio Castro from Data Structures and Algorithms course (IIC2133) in Pontificia Univer

Jose Antonio Castro 3 Aug 26, 2022