Sha256: 0d3905b65f039e5b19ef2972ba57bffbc3a1d69ba6a51dd380d1baaf0707d0db

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

class Languages
  ALL_LANGUAGES = %w(rb cpp c hs)
  def initialize(solve_file)
    @solve_file = solve_file
  end

  def compile(problem_name)
    raise 'Error: Not Implemented'
  end

  def execute(input_path, output_path)
    raise 'Error: Not Implemented'
  end
end

class Rb < Languages
  def compile(problem_name)
    true
  end

  def execute(input_path, output_path)
    system "ruby #{@solve_file} < #{input_path} > #{output_path}"
  end
end

class Cpp < Languages
  def compile(problem_name)
    @exec_file = "#{problem_name}.out"
    system "g++ #{@solve_file} -o #{problem_name}.out"
  end

  def execute(input_path, output_path)
    system "./#{@exec_file} < #{input_path} > #{output_path}"
  end
end

class C < Languages
  def compile(problem_name)
    @exec_file = "#{problem_name}.out"
    system "gcc #{@solve_file} -o #{problem_name}.out"
  end

  def execute(input_path, output_path)
    system "./#{@exec_file} < #{input_path} > #{output_path}"
  end
end

class Hs < Languages
  def compile(problem_name)
    @exec_file = "#{problem_name}.out"
    system "ghc #{@solve_file} -o #{problem_name}.out"
  end

  def execute(input_path, output_path)
    system "./#{@exec_file} < #{input_path} > #{output_path}"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
atcoder_greedy-0.6.0 lib/atcoder_greedy/lib/languages.rb