Skip to content

Instantly share code, notes, and snippets.

@dreikanter
Last active January 28, 2016 11:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dreikanter/178a0e91a30e40a73e02 to your computer and use it in GitHub Desktop.
Save dreikanter/178a0e91a30e40a73e02 to your computer and use it in GitHub Desktop.
Likes collapse logic
USER_NAME_LENGTH_RANGE = 3..("хорошо хоть, что хуй цел".length)
LIKES_AMOUNT = 100
LENGTH_LIMIT = 80
visible = []
(1..LIKES_AMOUNT).each do |index|
next_like = (index.to_s * rand(USER_NAME_LENGTH_RANGE))[0, USER_NAME_LENGTH_RANGE.max]
visible.unshift next_like
joined_likes = -> { visible.join(', ') }
while joined_likes.call.length > LENGTH_LIMIT do visible.pop end
puts "step: #{index}; likes visible: #{visible.length}; other people: #{index - visible.length}"
puts joined_likes.call
puts
end
step: 1; likes visible: 1; other people: 0
11111111
step: 2; likes visible: 2; other people: 0
22222, 11111111
step: 3; likes visible: 3; other people: 0
3333333333, 22222, 11111111
step: 4; likes visible: 4; other people: 0
44444444444444444, 3333333333, 22222, 11111111
step: 5; likes visible: 5; other people: 0
5555555, 44444444444444444, 3333333333, 22222, 11111111
step: 6; likes visible: 6; other people: 0
66666, 5555555, 44444444444444444, 3333333333, 22222, 11111111
step: 7; likes visible: 7; other people: 0
777, 66666, 5555555, 44444444444444444, 3333333333, 22222, 11111111
step: 8; likes visible: 8; other people: 0
88888888888, 777, 66666, 5555555, 44444444444444444, 3333333333, 22222, 11111111
step: 9; likes visible: 6; other people: 3
99999999999999999, 88888888888, 777, 66666, 5555555, 44444444444444444
step: 10; likes visible: 6; other people: 4
101010101010101010101010, 99999999999999999, 88888888888, 777, 66666, 5555555
step: 11; likes visible: 3; other people: 8
111111111111111111111111, 101010101010101010101010, 99999999999999999
step: 12; likes visible: 3; other people: 9
121212121212121212121212, 111111111111111111111111, 101010101010101010101010
step: 13; likes visible: 3; other people: 10
131313131313131313131313, 121212121212121212121212, 111111111111111111111111
step: 14; likes visible: 3; other people: 11
141414141414141414141414, 131313131313131313131313, 121212121212121212121212
step: 15; likes visible: 3; other people: 12
151515151515151515151515, 141414141414141414141414, 131313131313131313131313
step: 16; likes visible: 3; other people: 13
161616161616161616161616, 151515151515151515151515, 141414141414141414141414
step: 17; likes visible: 3; other people: 14
171717171717171717171717, 161616161616161616161616, 151515151515151515151515
step: 18; likes visible: 3; other people: 15
181818181818181818181818, 171717171717171717171717, 161616161616161616161616
step: 19; likes visible: 3; other people: 16
191919191919191919191919, 181818181818181818181818, 171717171717171717171717
step: 20; likes visible: 3; other people: 17
202020202020202020202020, 191919191919191919191919, 181818181818181818181818
step: 21; likes visible: 3; other people: 18
212121212121212121212121, 202020202020202020202020, 191919191919191919191919
step: 22; likes visible: 3; other people: 19
222222222222222222222222, 212121212121212121212121, 202020202020202020202020
step: 23; likes visible: 3; other people: 20
23232323, 222222222222222222222222, 212121212121212121212121
step: 24; likes visible: 3; other people: 21
24242424242424242424, 23232323, 222222222222222222222222
step: 25; likes visible: 4; other people: 21
252525252525, 24242424242424242424, 23232323, 222222222222222222222222
step: 26; likes visible: 4; other people: 22
262626262626262626262626, 252525252525, 24242424242424242424, 23232323
step: 27; likes visible: 4; other people: 23
2727272727, 262626262626262626262626, 252525252525, 24242424242424242424
step: 28; likes visible: 4; other people: 24
282828282828282828282828, 2727272727, 262626262626262626262626, 252525252525
step: 29; likes visible: 3; other people: 26
29292929292929292929, 282828282828282828282828, 2727272727
step: 30; likes visible: 3; other people: 27
303030303030303030303030, 29292929292929292929, 282828282828282828282828
step: 31; likes visible: 3; other people: 28
31313131313131313131, 303030303030303030303030, 29292929292929292929
step: 32; likes visible: 3; other people: 29
32323232323232, 31313131313131313131, 303030303030303030303030
step: 33; likes visible: 3; other people: 30
333333333333333333333333, 32323232323232, 31313131313131313131
step: 34; likes visible: 3; other people: 31
343434343434343434343434, 333333333333333333333333, 32323232323232
step: 35; likes visible: 3; other people: 32
353535353535353535353535, 343434343434343434343434, 333333333333333333333333
step: 36; likes visible: 3; other people: 33
363636363636363636363636, 353535353535353535353535, 343434343434343434343434
step: 37; likes visible: 3; other people: 34
373737373737373737373737, 363636363636363636363636, 353535353535353535353535
step: 38; likes visible: 3; other people: 35
383838383838383838383838, 373737373737373737373737, 363636363636363636363636
step: 39; likes visible: 3; other people: 36
393939393939393939393939, 383838383838383838383838, 373737373737373737373737
step: 40; likes visible: 3; other people: 37
40404040404040404040, 393939393939393939393939, 383838383838383838383838
step: 41; likes visible: 3; other people: 38
414141414141414141414141, 40404040404040404040, 393939393939393939393939
step: 42; likes visible: 3; other people: 39
424242424242424242, 414141414141414141414141, 40404040404040404040
step: 43; likes visible: 4; other people: 39
43434343, 424242424242424242, 414141414141414141414141, 40404040404040404040
step: 44; likes visible: 4; other people: 40
444444444444444444444444, 43434343, 424242424242424242, 414141414141414141414141
step: 45; likes visible: 4; other people: 41
4545454545454545, 444444444444444444444444, 43434343, 424242424242424242
step: 46; likes visible: 4; other people: 42
4646464646464646464646, 4545454545454545, 444444444444444444444444, 43434343
step: 47; likes visible: 3; other people: 44
474747474747474747474747, 4646464646464646464646, 4545454545454545
step: 48; likes visible: 3; other people: 45
484848484848484848484848, 474747474747474747474747, 4646464646464646464646
step: 49; likes visible: 3; other people: 46
494949494949494949494949, 484848484848484848484848, 474747474747474747474747
step: 50; likes visible: 3; other people: 47
505050505050505050505050, 494949494949494949494949, 484848484848484848484848
step: 51; likes visible: 3; other people: 48
515151515151515151515151, 505050505050505050505050, 494949494949494949494949
step: 52; likes visible: 3; other people: 49
525252525252525252525252, 515151515151515151515151, 505050505050505050505050
step: 53; likes visible: 3; other people: 50
535353535353535353535353, 525252525252525252525252, 515151515151515151515151
step: 54; likes visible: 3; other people: 51
545454545454545454545454, 535353535353535353535353, 525252525252525252525252
step: 55; likes visible: 3; other people: 52
555555555555555555555555, 545454545454545454545454, 535353535353535353535353
step: 56; likes visible: 3; other people: 53
565656, 555555555555555555555555, 545454545454545454545454
step: 57; likes visible: 3; other people: 54
575757575757575757575757, 565656, 555555555555555555555555
step: 58; likes visible: 3; other people: 55
585858585858585858585858, 575757575757575757575757, 565656
step: 59; likes visible: 3; other people: 56
595959595959595959595959, 585858585858585858585858, 575757575757575757575757
step: 60; likes visible: 3; other people: 57
6060606060606060606060, 595959595959595959595959, 585858585858585858585858
step: 61; likes visible: 3; other people: 58
61616161, 6060606060606060606060, 595959595959595959595959
step: 62; likes visible: 3; other people: 59
6262626262626262626262, 61616161, 6060606060606060606060
step: 63; likes visible: 3; other people: 60
636363636363636363636363, 6262626262626262626262, 61616161
step: 64; likes visible: 4; other people: 60
6464646464646464, 636363636363636363636363, 6262626262626262626262, 61616161
step: 65; likes visible: 3; other people: 62
656565656565656565656565, 6464646464646464, 636363636363636363636363
step: 66; likes visible: 3; other people: 63
666666666666666666666666, 656565656565656565656565, 6464646464646464
step: 67; likes visible: 3; other people: 64
676767676767, 666666666666666666666666, 656565656565656565656565
step: 68; likes visible: 3; other people: 65
686868686868686868686868, 676767676767, 666666666666666666666666
step: 69; likes visible: 3; other people: 66
696969696969696969696969, 686868686868686868686868, 676767676767
step: 70; likes visible: 3; other people: 67
707070707070707070, 696969696969696969696969, 686868686868686868686868
step: 71; likes visible: 3; other people: 68
717171717171717171717171, 707070707070707070, 696969696969696969696969
step: 72; likes visible: 3; other people: 69
727272727272727272727272, 717171717171717171717171, 707070707070707070
step: 73; likes visible: 3; other people: 70
737373737373737373737373, 727272727272727272727272, 717171717171717171717171
step: 74; likes visible: 3; other people: 71
747474747474747474747474, 737373737373737373737373, 727272727272727272727272
step: 75; likes visible: 3; other people: 72
757575757575757575, 747474747474747474747474, 737373737373737373737373
step: 76; likes visible: 3; other people: 73
767676767676767676767676, 757575757575757575, 747474747474747474747474
step: 77; likes visible: 4; other people: 73
77777777, 767676767676767676767676, 757575757575757575, 747474747474747474747474
step: 78; likes visible: 4; other people: 74
787878787878787878787878, 77777777, 767676767676767676767676, 757575757575757575
step: 79; likes visible: 3; other people: 76
797979797979797979797979, 787878787878787878787878, 77777777
step: 80; likes visible: 3; other people: 77
808080808080808080808080, 797979797979797979797979, 787878787878787878787878
step: 81; likes visible: 3; other people: 78
818181818181818181818181, 808080808080808080808080, 797979797979797979797979
step: 82; likes visible: 3; other people: 79
828282828282828282828282, 818181818181818181818181, 808080808080808080808080
step: 83; likes visible: 3; other people: 80
838383838383838383838383, 828282828282828282828282, 818181818181818181818181
step: 84; likes visible: 3; other people: 81
848484848484848484848484, 838383838383838383838383, 828282828282828282828282
step: 85; likes visible: 3; other people: 82
858585858585858585858585, 848484848484848484848484, 838383838383838383838383
step: 86; likes visible: 3; other people: 83
868686868686868686868686, 858585858585858585858585, 848484848484848484848484
step: 87; likes visible: 3; other people: 84
878787, 868686868686868686868686, 858585858585858585858585
step: 88; likes visible: 3; other people: 85
888888888888888888888888, 878787, 868686868686868686868686
step: 89; likes visible: 3; other people: 86
898989898989898989898989, 888888888888888888888888, 878787
step: 90; likes visible: 3; other people: 87
909090909090909090909090, 898989898989898989898989, 888888888888888888888888
step: 91; likes visible: 3; other people: 88
91919191, 909090909090909090909090, 898989898989898989898989
step: 92; likes visible: 4; other people: 88
92929292929292, 91919191, 909090909090909090909090, 898989898989898989898989
step: 93; likes visible: 4; other people: 89
939393939393939393939393, 92929292929292, 91919191, 909090909090909090909090
step: 94; likes visible: 4; other people: 90
949494949494949494949494, 939393939393939393939393, 92929292929292, 91919191
step: 95; likes visible: 3; other people: 92
95959595959595, 949494949494949494949494, 939393939393939393939393
step: 96; likes visible: 3; other people: 93
969696969696969696969696, 95959595959595, 949494949494949494949494
step: 97; likes visible: 3; other people: 94
979797979797979797979797, 969696969696969696969696, 95959595959595
step: 98; likes visible: 3; other people: 95
989898989898989898989898, 979797979797979797979797, 969696969696969696969696
step: 99; likes visible: 3; other people: 96
9999999999999999, 989898989898989898989898, 979797979797979797979797
step: 100; likes visible: 3; other people: 97
100100100100100100100100, 9999999999999999, 989898989898989898989898
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment