Created
January 10, 2015 00:30
-
-
Save hirokai/a3a87c09ccdb8b62083b to your computer and use it in GitHub Desktop.
Convert list of numbers to 0/1 column.
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
# Used in combination with yes/no checker (http://hirokai.github.io/yesnochecker/) | |
list = [ | |
[0,[90]], | |
[100,[22,25,38,39,40,43,45,46,52,53,54,55,56,59,62,68,69,70,71,72,73,74,75,76,77,79,80,81,85,86,87,89,90,93,94,95,96,97,98,99,100]], | |
[200,[1,2,3,4,5,6,7,9,10,11,12,13,14,16,17,18,19,20,21,22,23,24,25,26,28,29,30,31,32,33,34,35,42,44,45,48,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,67,69,70,71,72,73,75,76,77,78,79,81,82,83,84,85,86,87,88,89,90,91,92,93,95,96,97,98,100]], | |
[300,[4,6,10,11,12,13,15,17,18,21,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,56,57,58,59,63,64,65,66,67,68,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100]], | |
[400,[1,3,4,5,6,9,10,11,12,13,15,16,17,18,19,25,26,29,30,31,32,33,34,35,36,37,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54]] | |
] | |
nums = list.map{|l| l[1].map{|n| n+l[0]}}.flatten | |
(1..(nums.max)).map{|i| | |
puts ((nums.include? i) ? 1 : '') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment