Last active
November 26, 2017 09:27
Revisions
-
rafaltrojanowski revised this gist
Nov 26, 2017 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,4 @@ def solution(n) binary_array = to_binary(n) i = 0 -
rafaltrojanowski renamed this gist
Nov 26, 2017 . 1 changed file with 0 additions and 3 deletions.There are no files selected for viewing
This file contains 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,3 @@ def solution(n) # write your code in Ruby 2.2 binary_array = to_binary(n) -
rafaltrojanowski revised this gist
Aug 15, 2017 . No changes.There are no files selected for viewing
-
rafaltrojanowski revised this gist
Aug 15, 2017 . No changes.There are no files selected for viewing
-
rafaltrojanowski revised this gist
Aug 15, 2017 . No changes.There are no files selected for viewing
-
rafaltrojanowski revised this gist
Aug 15, 2017 . 1 changed file with 0 additions and 8 deletions.There are no files selected for viewing
This file contains 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 charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,6 @@ # you can write to stdout for debugging purposes, e.g. # puts "this is a debug message" def solution(n) # write your code in Ruby 2.2 binary_array = to_binary(n) @@ -41,13 +36,10 @@ def to_binary(n) arr = [] while n > 0 i = n % 2 arr << i n = n / 2 end arr -
rafaltrojanowski revised this gist
Aug 15, 2017 . 1 changed file with 6 additions and 13 deletions.There are no files selected for viewing
This file contains 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 charactersOriginal file line number Diff line number Diff line change @@ -8,39 +8,32 @@ def solution(n) # write your code in Ruby 2.2 binary_array = to_binary(n) i = 0 j = 0 max = 0 counter = 0 while i < binary_array.size - 1 counter = 0 if binary_array[i] == 1 && binary_array[i+1] == 0 j = i + 1 while binary_array[j] == 0 counter += 1 j += 1 end if counter > max max = counter end end i += 1 end max end -
rafaltrojanowski revised this gist
Aug 15, 2017 . 1 changed file with 19 additions and 14 deletions.There are no files selected for viewing
This file contains 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 charactersOriginal file line number Diff line number Diff line change @@ -18,24 +18,29 @@ def solution(n) j = 0 counters = [] counter = 0 while i < binary_array.size - 1 counter = 0 if binary_array[i] == 1 && binary_array[i+1] == 0 puts "I: #{i}" j = i + 1 while binary_array[j] == 0 counter += 1 puts "COUNTER: #{counter}" j += 1 end counters << counter end i += 1 end counters.max end -
rafaltrojanowski revised this gist
Aug 15, 2017 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,11 @@ # you can write to stdout for debugging purposes, e.g. # puts "this is a debug message" # 561892, 74901729, 1376796946 def solution(n) # write your code in Ruby 2.2 -
rafaltrojanowski created this gist
Aug 15, 2017 .There are no files selected for viewing
This file contains 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,51 @@ # you can write to stdout for debugging purposes, e.g. # puts "this is a debug message" def solution(n) # write your code in Ruby 2.2 binary_array = to_binary(n) puts binary_array.inspect i = 0 j = 0 counters = [] while j < binary_array.size puts binary_array[j] if binary_array[i] == 0 i += 1 j += 1 else # 1 j += 1 while binary_array[j] == 0 j +=1 end i += 1 puts "I: #{i}, J: #{j}" counters << j - i end end counters.max end def to_binary(n) arr = [] while n > 0 i = n % 2 arr << i n = n / 2 end arr end