Skip to content

Instantly share code, notes, and snippets.

View flemdizzle's full-sized avatar

Steven Fleming flemdizzle

View GitHub Profile
@flemdizzle
flemdizzle / bubkis.rb
Last active August 20, 2018 20:21
CODE GOLF: bubkis frequency calculation in ruby for 10K iterations
p Array.new(10000){Array.new(6){rand(1..6)}}.reject{|r|r.include?(1)||r.include?(5)||r.any?{|d|r.count(d)>2}||r.sort.chunk_while{|p,c|p==c}.count!=4}.size.to_f/10000
@flemdizzle
flemdizzle / bubkis.rb
Last active August 20, 2018 20:12
Readable
p Array
.new(10000){Array.new(6){rand(1..6)}}
.reject do |roll|
roll.include?(1) ||
roll.include?(5) ||
roll.select{ |die| roll.count(die) > 2 }.any? ||
roll.sort.chunk_while{ |previous_die, current_die| previous_die == current_die }.count != 4 }
end
.count.to_f/10000
{"marketplace"=>"Sennheiser Amazon", "customer_data"=>{"first_name"=>"Pending", "last_name"=>"AmazonCustomer", "phone_number"=>"1234567890", "email"=>"pending_amazon@optiturn.com"}, "billing_address"=>nil, "shipping_address"=>nil, "marketplace_identifier"=>"113-0740836-1481042", "shipping_method"=>"Two-Day", "status"=>"pending", "sold_price_cents"=>0, "shipping_cents"=>0, "tax_cents"=>0, "purchased_at"=>"2018-10-08T19:48:29.044Z", "marketplace_order_items"=>[{"sku"=>"15-1425632-9", "marketplace_identifier"=>"47908235845746", "sold_price_cents"=>0, "shipping_cents"=>0, "tax_cents"=>0, "unit"=>{"bulk_listing_id"=>nil, "cached_condition_multiple"=>0.797136, "cached_current_asking_price_cents"=>23070, "cached_current_condition_id"=>9, "client_catalog_entry_id"=>10344021, "client_lp"=>nil, "client_sku"=>"507390", "client_vendor_id"=>nil, "created_at"=>"2018-06-27T09:56:35-04:00", "current_appraisal_id"=>21944865, "details"=>nil, "grouping_condition_id"=>nil, "id"=>16277136, "internal_id"=>nil, "listing_reservation