4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/arb/files/other_solutions.rb', line 4
def self.download(year:, day:)
year_directory = File.join("others", year)
Dir.mkdir("others") unless Dir.exist?("others")
Dir.mkdir(year_directory) unless Dir.exist?(year_directory)
file_paths = %w[1 2].map do |part|
file_path = File.join(year_directory, "#{day}_#{part}.rb")
if File.exist?(file_path)
puts "Already exists: #{file_path}"
else
other_solutions = Api::OtherSolutions.new.other_solutions(year:, day:, part:)
File.write(file_path, other_solutions)
end
file_path
end
file_paths
end
|