Skip to content

Instantly share code, notes, and snippets.

@sedrickcz
Last active June 1, 2017 09:56
Show Gist options
  • Save sedrickcz/0365270bfde39f632157 to your computer and use it in GitHub Desktop.
Save sedrickcz/0365270bfde39f632157 to your computer and use it in GitHub Desktop.
1. What's your proudest achievement? It can be a personal project or something you've worked on professionally. Just a short paragraph is fine, but I'd love to know why you're proud of it.
My proudest achievement was that I was part of the very successful Kickstarter campaign (https://www.kickstarter.com/projects/1294225970/kingdom-come-deliverance). I created the official game website based on Ruby on Rails and the official forum based on awesome platform Discourse. The campaign went very well and we hit our target price only after 2 days. After this campaign I upgraded the official website to support pledging. Users could pledge some money and got some rewards such as an early access to the game, an access to forums, a digital copy of the game or even a real sword. The official website has around 110 000 active users per month. Thanks to the created pledging system the game was able to collect another 1 million € since January 2014. I am very happy, that I was part of this. I learned how to solve problems very quickly, creating a content for thousands of people and many other things.
2. Write some code, that will flatten an array of arbitrarily nested arrays of integers into a flat array of integers. e.g. [[1,2,[3]],4] -> [1,2,3,4].
See flattify.rb and flattify_spec.rb
3. We have some customer records in a text file (customers.json) -- one customer per line, JSON-encoded. We want to invite any customer within 100km of our Dublin office (GPS coordinates 53.3381985, -6.2592576) for some food and drinks on us.
See GitHub link: https://github.com/sedrickcz/invite_service/tree/master
class Array
def flattify
new_array = []
self.each { |item| item.kind_of?(Array) ? new_array += item.flattify : new_array << item }
new_array
end
end
#TEST
require './flattify'
RSpec.describe Array, "#flattify" do
context "with empty array" do
it "returns empty array" do
expect([].flattify).to eq([])
end
end
context "with flatten array" do
it "returns same array" do
expect([1,2,3,4].flattify).to eq([1,2,3,4])
end
end
context "with very deep array" do
it "returns flatten array" do
expect([[[[[[[[[[[[[[[[[[[[[1]]]]]]]]]]]]]]]]]]],2,3],4].flattify).to eq([1,2,3,4])
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment