Skip to content

Instantly share code, notes, and snippets.

@per-gron
per-gron / 3.rs
Created December 7, 2017 07:17
Advent of Code 3 2017 part 1
/*
the largest number in the square of (odd) width x is a(x) = x^2
the smallest number in the square of (odd) width x is b(x) = a(x-2)+1 = (x-2)^2+1 = x^2 - 4x5
the number x is in the square of width c(x) = ceil((x^0.5-1)/2)*2+1
the number of steps that x is from the smallest number in its square is d(x) = x - b(c(x))
assuming the number x is on the top row, its distance from the rightmost number is e(x) = d(x) - c(x) + 2
the distance from the centermost number out to the edge is then h(x) = floor(c(x)/2))
@per-gron
per-gron / gist:8270630
Created January 5, 2014 16:52
My girlfriend just wrote a text based adventure game in Ruby!
# encoding: utf-8
____ = <<EOS
Welcome to the amazing maze!
You can go in these directions:
* North
* South
* East
* West
@per-gron
per-gron / npm output
Created June 22, 2012 11:31
npm install --link
npm WARN facebook-signed-request@0.0.2 package.json: bugs['web'] should probably be bugs['url']
npm ERR! 404 'npm-test' is not in the npm registry.
npm ERR! 404 You could maybe bug the author to publish it
npm ERR! 404 Note that you can also install from a tarball or folder.
npm ERR!
npm ERR! System Darwin 11.4.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "--link"
npm ERR! cwd /Users/per/prog/node/npm-test2
npm ERR! node -v v0.6.15
npm ERR! npm -v 1.0.106