Skip to content

Instantly share code, notes, and snippets.

View cameronbourke's full-sized avatar

Cameron Bourke cameronbourke

View GitHub Profile
@cameronbourke
cameronbourke / .inputrc
Last active December 14, 2020 21:02
Simple Input RC
# Controls what happens when Readline wants to ring the terminal bell.
set bell-style none
# When pressing up or down arrows,
# show only history entries that match what was already typed.
"\ep":history-search-backward
"\en":history-search-forward
"\C-x\C-r": re-read-init-file
# Turn on case insensitivity for tab-completion.
#! /bin/bash
decimal=243881281
function dec2ip {
local v=$1
local i1=$((v>>24 & 255))
local i2=$((v>>16 & 255))
local i3=$((v>>8 & 255))
local i4=$((v & 255))
@cameronbourke
cameronbourke / frugal-atronomer.md
Created March 2, 2021 04:53
The Frugal Astronomer

The Frugal Astronomer

🤔 The Problem

You are known as one of the most distinguished astronomers in the country, capturing images sky for decades on end. In the mail, arrives an invite to an art exhibition in New York. You've been invited to star in an exhibition! However, you are only allowed to submit one photo. What to show? You could show a photo of a single planet, but that's been done before. Then, you have an idea! What about two planets that are close to each other? You quickly realise that in order to have the highest resolution photo possible, you will need to find the closest pair of planets in your collection. The problem is, you've captured billions of planets over the years, and don't have time to compare every pair of planets! Lucky for you, you remember that lying around are the (x, y) co-ordinates for the positions of each and every planet in the night sky. You've heard talk around the town, that a technique called divide and conquer might be able to help!

We need to design an algorithm