Git Product home page Git Product logo

crack-coding-interview-in-rust's Introduction

Crack code interview problems in Rust ๐Ÿฆ€

This repo contains the problems solved during the Crack code interview problems in Rust series from the Microsoft Reactor.

You can find details for the upcoming episodes, and register on the Microsoft Reactor site.

Season 1

Episode 1 - number of islands

You have a map based off a grid of size X by Y. Each grid cell is either marked as land or sea. Assuming all around the grid is sea, your job is to calculate the number of islands on the map.

An island is defined as a continuous set of grid cells of land that connect either above, below, left or right with another land cell. Diagonal connections are not allowed.

You can catch the recording by selecting the image below

Recording

Example

Here is a grid of 6x12:

A 6 by 12 grid of blue sea with 6 green islands

The blue cells are sea, the green cells are land. This map has 6 islands:

A 6 by 12 grid of blue sea with 6 green islands numbered 1 to 6

Code

You can find the final code for this in the number-of-islands folder.

Episode 2 and 3 - Conway's game of life

The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970.

The board is made up of an m x n grid of cells, where each cell has an initial state: live (represented by a 1) or dead (represented by a 0). Each cell interacts with its eight neighbors (horizontal, vertical, diagonal) using the following four rules:

  • Any live cell with fewer than two live neighbors dies as if caused by under-population.
  • Any live cell with two or three live neighbors lives on to the next generation.
  • Any live cell with more than three live neighbors dies, as if by over-population.
  • Any dead cell with exactly three live neighbors becomes a live cell, as if by reproduction.

The next state is created by applying the above rules simultaneously to every cell in the current state, where births and deaths occur simultaneously. Given the current state of the m x n grid board, return the next state.

In this problem, given an initial state compute the next state.

We attempted this over 2 sessions, and didn't manage to complete in time as we had too much fun discussing rust features with the audience!

Episode 2 recording:

Recording

Episode 3 recording:

Recording

Example

The state on the left gives the one on the right as the next state.

0 1 0    0 0 0
0 0 1 -> 1 0 1
1 1 1    0 1 1
0 0 0    0 1 0
1 1 -> 1 1
1 0    1 1

Season 2

Register for season 2 now!

Episode 1 and 2 - Word Search

Given a board made of a grid of characters, and a word, get if the word exists in the grid as contiguous characters.

The word can be constructed from any adjacent cells, up, down, left or right (but not diagonally).

Episode 1 recording:

Recording

Episode 2 recording:

Recording

Example 1:

Given this board:

a board of letters

and the word HELLO, the result would be true.

a board of letters with the word hello highlighted

Example 2:

Given this board:

a board of letters

and the word WORLD, the result would be true.

a board of letters with the word hello highlighted

Example 3:

Given this board:

a board of letters

and the word RUST, the result would be false. The letters are there, but only by connecting diagonally.

crack-coding-interview-in-rust's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.