Skip to content

Instantly share code, notes, and snippets.

@huemorgan
Created January 8, 2017 19:49
Show Gist options
  • Save huemorgan/754a639d9a59cb13a5e006cefd3c34e9 to your computer and use it in GitHub Desktop.
Save huemorgan/754a639d9a59cb13a5e006cefd3c34e9 to your computer and use it in GitHub Desktop.
calculate excel cohort diagonals fields in ruby by dapulse
x = ['c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
y = [11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34]
length = y.length
strings = []
for index in 0..length
substring = "="
for i in 0..(index)
substring = substring + "+" if substring != "="
substring << "#{x[i]}#{y[index-i]}"
end
strings << substring
end
strings.each{|s| puts s }
@huemorgan
Copy link
Author

it's always horrible to make diagonal field fetching in excel for cohorts, manual and annoying, this scripts creates the formulas, just copy & paste each field - still annoying but much less.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment