<commit_before>c_stations, start, destination = STDIN.gets.chomp.split(',').map{|value| value.to_i}

# p "#{c_stations}, #{start}, #{destination}"

direction = start < destination ? 1 : -1
stopped = Array.new(c_stations) {0}

def move stopped, direction, destination
  patterns = 0
  stopped.each_with_index do |station, i|
    patterns += 1 if i = destination
    overslept = destination == 1 && destination < i && station == 0
    overslept = overslept || (destination == -1 && destination > i && station == 0)
    if overslept
      stopped[i] = 1
      patterns += move stopped, -1*direction, destination
      stopped[i] = 0
    end
  end
  return patterns
end

puts move stopped, direction, destination<commit_msg>implement code which is able to solve 10,8,4 but slow #20<commit_after>c_stations, start, destination = STDIN.gets.chomp.split(',').map{|value| value.to_i}

# p "#{c_stations}, #{start}, #{destination}"

direction = start < destination ? 1 : -1
stopped = Array.new(c_stations) {0}
stopped[start-1] = 1

def move stopped, direction, destination
  patterns = 0
  stopped.each_with_index do |station, i|
    patterns += 1 if i == destination
    overslept = (direction == 1 && destination < i && station == 0)
    overslept = overslept || (direction == -1 && destination > i && station == 0)
    if overslept
      stopped[i] = 1
      patterns += move stopped, -1*direction, destination
      stopped[i] = 0
    end
  end
  return patterns
end

puts move stopped, direction, destination-1
{'fraction_non_alphanumeric': 0.13213811420982735, 'fraction_numerical': 0.021912350597609563, 'mean_word_length': 3.6512345679012346, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7269442', 'n_tokens_mistral': 494, 'n_tokens_neox': 488, 'n_words': 149}