Skip to content

Instantly share code, notes, and snippets.

Maze escape 🏃

Given a two-dimensional array (the maze) and an array of steps, implement a solution to verify whether or not the player escaped the labyrinth.

  • The solution should output "Escaped" if the player reaches the maze's exit.
  • The solution should output "Dead" if the player hits a wall or goes outside the maze border.
  • The solution should output "Lost forever" if the player does not reach the maze's exit after taking all their steps.

The two-dimensional data structure that represents the maze looks like this:

openapi: 3.0.2
info:
version: 0.0.1
title: Rideshare API
description: |
The Rideshare API provides access to the rideshare service runned by [door2door](https://www.door2door.io/).
# Environments
This API can be consumed in two different environments, staging and production.
hello
world
from
berlin
@nicolasiensen
nicolasiensen / test-material-ui-event-simulation.js
Created December 20, 2016 11:38
Simulating events with Jest and Material UI
// Simulating clicks
const dashboardMount = mount(
<Dashboard />, {
context: { muiTheme },
childContextTypes: { muiTheme: React.PropTypes.object }
}
)
const menuButton = ReactDOM.findDOMNode(dashboardMount.find(AppBar).find(IconButton).find('button').node)
TestUtils.Simulate.touchTap(menuButton)
// This helper is required to test any component that renders material-ui components.
// If you are getting a message saying:
// 'undefined is not an object (evaluating this.context.muiTheme.prepareStyles)'
// you should use this helper.
// The usage is simple, you pass a component class to extendComponentWithMUITheme
// and it will return a new component class capable of rendering material-ui
// components
// const MyExtendedComponent = extendComponentWithMUITheme(MyComponent)
class CreateViewFacts < ActiveRecord::Migration
def up
create_view :facts, "
SELECT c.id, c.created_at, c.name, c.description_html, c.link, c.mobilization_id, 'campaigns' as relname FROM campaigns c
UNION ALL
SELECT p.id, p.created_at, p.name, p.description as description_html, p.link, p.mobilization_id, 'problems' as relname FROM problems p;"
end
def down
drop_view :facts
@nicolasiensen
nicolasiensen / gist:6196787
Created August 9, 2013 20:12
Distance between two geospatial points in MySql
SET @orig_lat = "50";
SET @orig_lng = "5";
SET @dest_lat = "45";
SET @dest_lng = "30";
SELECT 3956 * 2 * ASIN(SQRT( POWER(SIN((@orig_lat - @dest_lat) * pi()/180 / 2), 2) + COS(@orig_lat * pi()/180) * COS(@dest_lat * pi()/180) * POWER(SIN((@orig_lng - @dest_lng) * pi()/180 / 2), 2) ));
@nicolasiensen
nicolasiensen / .bash_profile
Last active December 16, 2015 21:50
My .bash_profile
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
function parse_git_branch_and_add_brackets {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\ \[\1\]/'
}
export PATH="/usr/local/bin:$PATH"
export PS1="\[\e[1;29;42m\]\w\$(parse_git_branch_and_add_brackets)\[\e[m\] "
export CLICOLOR=1
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
Bundle 'wincent/Command-T.git'
Bundle 'bbommarito/vim-slim.git'
Bundle 'digitaltoad/vim-jade.git'
Bundle 'pangloss/vim-javascript.git'
Bundle 'vim-ruby/vim-ruby.git'
Bundle 'https://github.com/tpope/vim-fugitive.git'
@nicolasiensen
nicolasiensen / game.rb
Last active December 14, 2015 04:49
Ordering games by achievements completeness
# by @diogob
def self.by_completeness user
user.games.order("
CASE WHEN (SELECT count(*) FROM achievements a WHERE a.game_id = games.id) = 0 THEN 0 ELSE
(SELECT count(DISTINCT a.id)
FROM
achievements_users au
JOIN achievements a ON a.id = au.achievement_id
WHERE a.game_id = games.id AND au.user_id = #{user.id})::numeric /
(SELECT count(*)