Skip to content

Instantly share code, notes, and snippets.

Mohammad Nasirifar farnasirim

Block or report user

Report or block farnasirim

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
farnasirim /
Created Dec 8, 2019
Solution to Surrounded Regions



We have to find all regions of O's that are surrounded by X's, and convert them to X's.

The most trivial approach here would be taking every cell that contains an O, and checking to see whether or not it is connected to at least one of the borders through other O cells. If this is the case, that cell is not surrounded. Otherwise that cell is part of a (possibly large) surrounded region and has to marked with X:

farnasirim / ternary_on_integer_domain.cpp
Last active Dec 8, 2019
Ternary search on integer domain + test drive
View ternary_on_integer_domain.cpp
#include <cmath>
#include <algorithm>
#include <vector>
#include <iostream>
#include <cassert>
using namespace std;
template <typename Compare>
int findMax(int from, int to, Compare lessFunctor) { // from and to are inclusive: [from, to]
View index.html
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="stylesheet" href="">
<script src="" charset="utf-8"></script>
<style>.cmx-user-scene4 .cmx-text-border .cmx-path {stroke: orange}</style>
<div style="max-width:800px; -webkit-transform:rotate(0deg)">
<scene width="600" id="scene1">
<label t="translate(0,346)">
farnasirim / .vimrc
Created Dec 16, 2017
Poor man's .vimrc
View .vimrc
set ts=4
set sw=4
set smartindent
set ai
set background=dark
colorscheme slate
syntax enable
set nocompatible
filetype plugin indent on
set hlsearch
farnasirim /
Last active Nov 2, 2017
navigate to a go project directory easily using `goto` command
if [ -z "$@" ]; then
echo "Usage: goto project-name"
for i in {1..3}; do
You can’t perform that action at this time.