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
    
  
  
    
  | <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
| <meta http-equiv="X-UA-Compatible" content="ie=edge" /> | |
| <title>Web Components</title> | |
| <style> | |
| * { | |
| box-sizing: border-box; | 
  
    
      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
    
  
  
    
  | Dir.foreach('broken_links_data') do |filename| | |
| next if filename == '.' or filename == '..' | |
| grouped_data = {} | |
| File.foreach("broken_links_data/#{filename}") do |line| | |
| line_data = line.split(',') | |
| grouped_data[line_data.last.chomp] ||= [] | |
| grouped_data[line_data.last.chomp] << "#{line_data[0..2].join(',')},\"#{line_data[3..-2].join(',')}\"" | |
| end | 
  
    
      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
    
  
  
    
  | RSpec.shared_examples 'validates url' do |attribute, validation_options = {}| | |
| describe "##{attribute}" do | |
| if validation_options[:allow_blank] | |
| context 'when blank' do | |
| let(:value) { '' } | |
| it { is_expected.to allow_value(value).for(attribute) } | |
| end | |
| end | 
  
    
      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
    
  
  
    
  | def solution(input_array) | |
| missing_numbers_array = (1..input_array.size + 1).to_a - input_array | |
| missing_numbers_array.first | |
| end | 
  
    
      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
    
  
  
    
  | def solution(counters_count, initial_counters) | |
| current_max_value = 0 | |
| max_value_to_set = 0 | |
| counters = Array.new(counters_count, 0) | |
| initial_counters.each do |current_counter| | |
| if current_counter > counters_count | |
| max_value_to_set = current_max_value | |
| else | |
| current_counter -= 1 | 
  
    
      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
    
  
  
    
  | def solution(array) | |
| sorted_array = array.sort | |
| return 0 if sorted_array[0] != 1 | |
| sorted_array.size.times do |index| | |
| break if sorted_array[index + 1] == nil | |
| return 0 if sorted_array[index] + 1 != sorted_array[index + 1] | |
| end | 
  
    
      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
    
  
  
    
  | # Using Array#each_with_index | |
| def solution(desired_position, fallings) | |
| covered_positions = [] | |
| fallings.each_with_index do |falling_position, second| | |
| if falling_position <= desired_position && !covered_positions.include?(falling_position) | |
| covered_positions << falling_position | |
| end | |
| return second if covered_positions.size == desired_position | 
  
    
      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
    
  
  
    
  | def solution(a) | |
| last_index = a.size - 1 | |
| head = a[0] | |
| tail = a[1..last_index].inject(0, :+) | |
| min_diff = (head - tail).abs | |
| (1..last_index-1).each do |arr_index| | |
| head += a[arr_index] | |
| tail -= a[arr_index] | 
  
    
      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
    
  
  
    
  | def solution(a) | |
| # write your code in Ruby 2.2 | |
| return 1 if a.size == 0 | |
| n = a.size + 1 | |
| (n * (n + 1) / 2) - a.inject(0, :+) | |
| end | 
  
    
      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
    
  
  
    
  | def solution(x, y, d) | |
| # write your code in Ruby 2.2 | |
| distantion = y - x | |
| (distantion / d.to_f).ceil | |
| end | 
NewerOlder
        