Module: AtCoderFriends::Parser::Interactive

Defined in:
lib/at_coder_friends/parser/interactive.rb

Overview

detect interactive problem

Constant Summary collapse

INTERACTIVE_PAT =
/
  インタラクティブ
  |interactive
  |リアクティブ
  |reactive
/xi.freeze
FLUSH_PAT =
/flush/i.freeze

Class Method Summary collapse

Class Method Details

.process(pbm) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/at_coder_friends/parser/interactive.rb', line 17

def process(pbm)
  pbm.options.interactive = false

  body = pbm.body_content
  f_int = body =~ INTERACTIVE_PAT
  f_flush = body =~ FLUSH_PAT
  f_io = pbm.sections[Problem::SECTION_IO_FMT]
  f_tbl =
    pbm
    .sections[Problem::SECTION_IO_SMP]
    &.find_element(%w[table])
  return unless [f_int, f_flush, f_io, f_tbl].count(&:itself) > 1

  pbm.options.interactive = true
end