Skip to content

Instantly share code, notes, and snippets.

View slothC0der's full-sized avatar

Alfonso Vergara slothC0der

  • Fordham
  • Miami, Florida
View GitHub Profile
@seanreed1111
seanreed1111 / bfs.rb
Last active September 21, 2016 01:31
BFS Implementation. (Not defined as a Class)
require '../lib/Queue'
frontier = Queue.new
neighbors = {}
neighbors = {:a => [:b,:f],
:b => [:a,:c,:d],
:c => [:b,:e],
:d => [:b,:e],
:e => [:c,:d],
:f => [:a,:g,:h,:i],
:g => [:f],
@tsiege
tsiege / The Technical Interview Cheat Sheet.md
Last active April 11, 2025 17:09
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

ANNOUNCEMENT

I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!






\

@shoken0x
shoken0x / breadth_first_search.rb
Last active September 21, 2016 01:34
PCC Book: 幅優先探索(BFS: Breadth-First Seach)
# input
MAX_N, MAX_M = 100, 100
$INF = 100_000_000
str = <<"EOS"
#S.#.....#
#.....##.#
#.#.#..#..#
#..#..####
####G#####
""" https://en.wikipedia.org/wiki/Golomb_sequence """
def golomb(n):
d = [1]
for i in range(0, n - 1):
next_val = d[len(d) - 1] + 1
d.append(next_val)
for j in range(0, d[next_val - 1] - 1):
d.append(next_val)
return d