Bartosz-Slowik / mine_number_problem

Solution to a recruitment coding challenge

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Solution

The number 22523122706112554941 at line 5231 will crumble the mine.

My solution to the following problem:

Welcome to Number Associative Mining and Trading Inc, or NAMT for short! Your duties are to make sure our turtles, working in difficult environments, are making correct associations, and stopping their operations when the tunnel is about to crumble. For that, our mathematicians finally found with absolute certainty the pattern the numbers mined follow before going too far.

The Problem:

The first 100 numbers of the mine are always secure, but after that, the next number is only safe if it is the sum of 2 numbers in the previous 100.

Description

I used both Vector and Hashmap for this challenge to reduce time complexity.

Vector allows me to ratain order of numbers adn easily pop the first index

Hashmap allows me to easily search if desired number is in the last 100 with skipping duplicates.

Installation

  1. Clone the repository
  2. Run cargo build to build the project
  3. Run cargo run to run the project

License

This project is licensed under the MIT License.

About

Solution to a recruitment coding challenge


Languages

Language:Rust 100.0%