Last active
May 3, 2018 03:54
-
-
Save charusat09/b9d507fa25e3263e3284bfb0a197ef0a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PER_1 = 20 | |
PER_2 = 35 | |
PER_3 = 45 | |
POOL_SIZE = 10 | |
ids = [*(1..1000)] | |
a1 = (PER_1 / POOL_SIZE).ceil | |
a2 = (PER_2 / POOL_SIZE).ceil | |
a3 = POOL_SIZE - a1 - a2 | |
index_1 = [*(1..a1)] | |
index_2 = [*(index_1.last+1..index_1.last+a2)] | |
index_3 = [*(index_2.last+1..POOL_SIZE)] | |
url_1 = [] | |
url_2 = [] | |
url_3 = [] | |
ids.each do |i| | |
# here we are checking ids for redirecting | |
remender = i % POOL_SIZE | |
url_1 << i if index_1.include? (remender) | |
url_2 << i if index_2.include? (remender) | |
url_3 << i if (index_3.include? (remender)) || remender == 0 | |
end | |
puts "*"*50 | |
puts "url_1: #{url_1}" | |
puts "Count: #{url_1.count}" | |
puts "*"*50 | |
puts "url_2: #{url_2}" | |
puts "Count: #{url_2.count}" | |
puts "*"*50 | |
puts "url_3: #{url_3}" | |
puts "Count: #{url_3.count}" | |
puts "*"*50 | |
collected_ids = (url_1 + url_2 + url_3).uniq | |
remaining_ids = ids - collected_ids | |
puts "remaining_ids: #{remaining_ids}" | |
puts "Count: #{remaining_ids.count}" |
@charusat09 This output looks promising but will defer to others that can evaluate the code itself (I am unsure if remender is supposed to be remainder).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
OUtput: