Skip to content

Instantly share code, notes, and snippets.

@adilsoncarvalho
Last active August 29, 2015 14:01
Show Gist options
  • Save adilsoncarvalho/ac3a001ce11fbc7666e2 to your computer and use it in GitHub Desktop.
Save adilsoncarvalho/ac3a001ce11fbc7666e2 to your computer and use it in GitHub Desktop.
On Strategy: What Managers Can Learn form The Great Philosophers
#!/usr/bin/env ruby
require 'yaml'
DOUBLED = /aa|bb|cc|dd|ee|ff|gg|hh|ii|jj|kk|ll|mm|nn|oo|pp|qq|rr|ss|tt|uu|vv|ww|xx|yy|zz/i
names = [
"Aber&Crombie", "Apple", "BMW", "Boss", "Burger King", "Carlsberg", "Caterpillar",
"Coca-cola", "Dior", "Disney", "Ebay", "Emirates", "Google", "IBM", "Ikea", "Kodak",
"Lacoste", "Lenovo", "Levi’s", "L’oréal", "Michelin", "Mittal", "Monsanto", "Nestlé", "Nike",
"Nikon", "Nutella", "Pampers", "Pfizer", "Philips", "Procter&Gamble", "Redbull",
"Samsung", "Swatch", "Tata", "The North Face", "Total", "Toyota", "Versace", "Wenger"
].reduce({}) do |o, name|
size = name.size.to_f
size += name.scan(DOUBLED).size.to_f * (size / 2.0)
o[name] = size
o
end.sort_by do |name, size|
20 - size
end.map do |name, _|
name
end
puts names.to_yaml
#!/usr/bin/env ruby
require 'yaml'
DOUBLED = /aa|bb|cc|dd|ee|ff|gg|hh|ii|jj|kk|ll|mm|nn|oo|pp|qq|rr|ss|tt|uu|vv|ww|xx|yy|zz/i
names = [
"Aber&Crombie", "Apple", "BMW", "Boss", "Burger King", "Carlsberg", "Caterpillar",
"Coca-cola", "Dior", "Disney", "Ebay", "Emirates", "Google", "IBM", "Ikea", "Kodak",
"Lacoste", "Lenovo", "Levi’s", "L’oréal", "Michelin", "Mittal", "Monsanto", "Nestlé", "Nike",
"Nikon", "Nutella", "Pampers", "Pfizer", "Philips", "Procter&Gamble", "Redbull",
"Samsung", "Swatch", "Tata", "The North Face", "Total", "Toyota", "Versace", "Wenger"
].reduce({}) do |o, name|
o[name] = name.scan(DOUBLED).flatten.sort.join.size
o
end.sort_by do |k, v|
v
end.map do |k, _|
k
end.reverse
puts names.to_yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment