Skip to content

Instantly share code, notes, and snippets.

# A greedy algorithm for bin packing
class Array
def rest
self[1..-1]
end
end
def optimize_pack inventory, order
loop do
data = File.read(ARGV[0]).split("\n").map { |l| l.split(": ").map(&:to_i) }
layers = {}
data.each do |a, b|
layers[a] = b
end
max = ARGV[1].to_i
require 'graph'
require 'psych'
steps = Psych.load(File.read(ARGV[0]))["steps"]
previous_steps = []
digraph do
steps.each do |step|
id = step["id"] || step["name"]
colorTable:
colorWhite: &colorWhite
rgb: [255, 255, 255]
hex: "FFFFFF"
colorRed100: &colorRed100
rgb: [255, 255, 255]
hex: "FFFFFF"
colorRed300: &colorRed300
rgb: [255, 255, 255]
hex: "FFFFFF"
{
"products":[
{
"id":"eea560e7-86f3-4a9c-86ce-b57b8fdbc11a",
"name":"Mid-Century Modern Accent Chair",
"description":"This mid-century modern accent chair is a timeless piece that will add a touch of elegance to any room. It features a sleek, walnut frame and a comfortable, mustard yellow cushion. The chair is in excellent condition and has been well-maintained.",
"picture":"https://storage.googleapis.com/online-boutique-product-data/Mid-Century%20Modern%20Accent%20Chair165",
"priceUsd":{
"currencyCode":"USD",
"units":3884,