at_coder_friends 0.6.3 → 0.6.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +3 -2
- data/.travis.yml +1 -3
- data/CHANGELOG.md +37 -0
- data/Gemfile.lock +53 -48
- data/README.md +1 -1
- data/at_coder_friends.gemspec +5 -7
- data/config/default.yml +146 -72
- data/docs/CONFIGURATION.md +222 -136
- data/lib/at_coder_friends.rb +1 -0
- data/lib/at_coder_friends/cli.rb +8 -0
- data/lib/at_coder_friends/config_loader.rb +11 -3
- data/lib/at_coder_friends/context.rb +10 -6
- data/lib/at_coder_friends/emitter.rb +2 -2
- data/lib/at_coder_friends/generator/base.rb +3 -2
- data/lib/at_coder_friends/generator/main.rb +2 -1
- data/lib/at_coder_friends/parser/constraints.rb +1 -0
- data/lib/at_coder_friends/parser/input_format.rb +2 -0
- data/lib/at_coder_friends/parser/input_type.rb +3 -2
- data/lib/at_coder_friends/parser/modulo.rb +1 -1
- data/lib/at_coder_friends/parser/sections.rb +3 -3
- data/lib/at_coder_friends/path_info.rb +51 -0
- data/lib/at_coder_friends/path_util.rb +0 -31
- data/lib/at_coder_friends/scraping/agent.rb +11 -2
- data/lib/at_coder_friends/scraping/custom_test.rb +5 -6
- data/lib/at_coder_friends/scraping/submission.rb +6 -7
- data/lib/at_coder_friends/scraping/tasks.rb +8 -3
- data/lib/at_coder_friends/test_runner/base.rb +17 -4
- data/lib/at_coder_friends/test_runner/judge.rb +7 -9
- data/lib/at_coder_friends/test_runner/sample.rb +2 -4
- data/lib/at_coder_friends/verifier.rb +2 -3
- data/lib/at_coder_friends/version.rb +1 -1
- data/templates/cxx_builtin.cxx.erb +26 -35
- data/templates/ruby_builtin.rb.erb +17 -18
- metadata +7 -16
- data/tasks/regression/check_const.rake +0 -137
- data/tasks/regression/check_diff.rake +0 -30
- data/tasks/regression/check_fmt.rake +0 -45
- data/tasks/regression/check_parse.rake +0 -69
- data/tasks/regression/list_handler.rb +0 -46
- data/tasks/regression/regression.rb +0 -38
- data/tasks/regression/report_handler.rb +0 -20
- data/tasks/regression/section_list.rake +0 -53
- data/tasks/regression/setup.rake +0 -48
@@ -4,19 +4,17 @@ module AtCoderFriends
|
|
4
4
|
module TestRunner
|
5
5
|
# run test cases for the specified program with sample input/output.
|
6
6
|
class Sample < Base
|
7
|
-
include PathUtil
|
8
|
-
|
9
7
|
attr_reader :data_dir
|
10
8
|
|
11
9
|
def initialize(ctx)
|
12
10
|
super(ctx)
|
13
|
-
@data_dir = smp_dir
|
11
|
+
@data_dir = ctx.path_info.smp_dir
|
14
12
|
end
|
15
13
|
|
16
14
|
def test_all
|
17
15
|
puts "***** test_all #{prg} (#{test_loc}) *****"
|
18
16
|
results = Dir["#{data_dir}/#{q}_*.in"].sort.map do |infile|
|
19
|
-
id = File.basename(infile, '.in').sub(
|
17
|
+
id = File.basename(infile, '.in').sub(/\A#{q}_/, '')
|
20
18
|
test(id)
|
21
19
|
end
|
22
20
|
!results.empty? && results.all?
|
@@ -10,9 +10,8 @@ module AtCoderFriends
|
|
10
10
|
attr_reader :path, :file, :vdir, :vpath
|
11
11
|
|
12
12
|
def initialize(ctx)
|
13
|
-
@path = ctx.
|
14
|
-
@
|
15
|
-
@vdir = tmp_dir(path)
|
13
|
+
@path, _dir, @file = ctx.path_info.components
|
14
|
+
@vdir = ctx.path_info.tmp_dir
|
16
15
|
@vpath = File.join(vdir, "#{file}.verified")
|
17
16
|
end
|
18
17
|
|
@@ -1,17 +1,20 @@
|
|
1
1
|
// <%= pbm.url %>
|
2
2
|
|
3
|
-
|
4
|
-
if pbm.options.interactive
|
5
|
-
%>#include <cstdio>
|
3
|
+
#include <cstdio>
|
4
|
+
<% if pbm.options.interactive -%>
|
6
5
|
#include <vector>
|
7
6
|
#include <string>
|
7
|
+
<% end -%>
|
8
8
|
|
9
9
|
using namespace std;
|
10
10
|
|
11
|
+
<% if pbm.options.interactive -%>
|
11
12
|
#define DEBUG
|
13
|
+
<% end -%>
|
12
14
|
#define REP(i,n) for(int i=0; i<(int)(n); i++)
|
13
15
|
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
|
14
16
|
|
17
|
+
<% if pbm.options.interactive -%>
|
15
18
|
//------------------------------------------------------------------------------
|
16
19
|
const int BUFSIZE = 1024;
|
17
20
|
char req[BUFSIZE];
|
@@ -33,11 +36,17 @@ void query() {
|
|
33
36
|
}
|
34
37
|
|
35
38
|
//------------------------------------------------------------------------------
|
36
|
-
|
39
|
+
<% end -%>
|
40
|
+
<% gen_consts.each do |line| -%>
|
41
|
+
<%= line %>
|
42
|
+
<% end -%>
|
37
43
|
|
38
|
-
|
44
|
+
<% gen_decls.each do |line| -%>
|
45
|
+
<%= line %>
|
46
|
+
<% end -%>
|
39
47
|
|
40
48
|
void solve() {
|
49
|
+
<% if pbm.options.interactive -%>
|
41
50
|
printf("! %s\n", ans);
|
42
51
|
fflush(stdout);
|
43
52
|
#ifdef DEBUG
|
@@ -47,44 +56,26 @@ void solve() {
|
|
47
56
|
puts(responses[i].c_str());
|
48
57
|
}
|
49
58
|
#endif
|
59
|
+
<% elsif (vs = pbm.options.binary_values) -%>
|
60
|
+
bool cond = false;
|
61
|
+
puts(cond ? "<%= vs[0] %>" : "<%= vs[1] %>");
|
62
|
+
<% else -%>
|
63
|
+
int ans = 0;
|
64
|
+
printf("%d\n", ans);
|
65
|
+
<% end -%>
|
50
66
|
}
|
51
67
|
|
52
68
|
void input() {
|
53
|
-
|
69
|
+
<% gen_inputs.each do |line| -%>
|
70
|
+
<%= line %>
|
71
|
+
<% end -%>
|
72
|
+
<% if pbm.options.interactive -%>
|
54
73
|
#ifdef DEBUG
|
55
74
|
scanf("%s", source);
|
56
75
|
#endif
|
57
|
-
|
58
|
-
else
|
59
|
-
%>#include <cstdio>
|
60
|
-
|
61
|
-
using namespace std;
|
62
|
-
|
63
|
-
#define REP(i,n) for(int i=0; i<(int)(n); i++)
|
64
|
-
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
|
65
|
-
|
66
|
-
/*** CONSTS ***/
|
67
|
-
|
68
|
-
/*** DCLS ***/
|
69
|
-
|
70
|
-
void solve() {
|
71
|
-
<%
|
72
|
-
if (vs = pbm.options.binary_values)
|
73
|
-
%> bool cond = false;
|
74
|
-
puts(cond ? "<%= vs[0] %>" : "<%= vs[1] %>");<%
|
75
|
-
else
|
76
|
-
%> int ans = 0;
|
77
|
-
printf("%d\n", ans);<%
|
78
|
-
end
|
79
|
-
%>
|
76
|
+
<% end -%>
|
80
77
|
}
|
81
78
|
|
82
|
-
void input() {
|
83
|
-
/*** INPUTS ***/
|
84
|
-
}<%
|
85
|
-
end
|
86
|
-
%>
|
87
|
-
|
88
79
|
int main() {
|
89
80
|
input();
|
90
81
|
solve();
|
@@ -1,8 +1,7 @@
|
|
1
1
|
# <%= pbm.url %>
|
2
2
|
|
3
|
-
<%
|
4
|
-
|
5
|
-
%>def query(*args)
|
3
|
+
<% if pbm.options.interactive -%>
|
4
|
+
def query(*args)
|
6
5
|
puts "? #{args.join(' ')}"
|
7
6
|
STDOUT.flush
|
8
7
|
if $DEBUG
|
@@ -15,15 +14,23 @@ end
|
|
15
14
|
|
16
15
|
$DEBUG = true
|
17
16
|
|
18
|
-
|
17
|
+
<% end -%>
|
18
|
+
<% gen_consts.each do |line| -%>
|
19
|
+
<%= line %>
|
20
|
+
<% end -%>
|
19
21
|
|
20
|
-
|
22
|
+
<% gen_decls.each do |line| -%>
|
23
|
+
<%= line %>
|
24
|
+
<% end -%>
|
25
|
+
<% if pbm.options.interactive -%>
|
21
26
|
|
22
27
|
if $DEBUG
|
23
28
|
@responses = []
|
24
29
|
@source = gets.chomp
|
25
30
|
end
|
31
|
+
<% end -%>
|
26
32
|
|
33
|
+
<% if pbm.options.interactive -%>
|
27
34
|
puts "! #{ans}"
|
28
35
|
STDOUT.flush
|
29
36
|
|
@@ -33,17 +40,9 @@ if $DEBUG
|
|
33
40
|
puts "query results:"
|
34
41
|
@responses.each { |res| puts res }
|
35
42
|
puts "----------------------------------------"
|
36
|
-
end<%
|
37
|
-
else
|
38
|
-
%>### CONSTS ###
|
39
|
-
|
40
|
-
### DCLS ###
|
41
|
-
|
42
|
-
<%
|
43
|
-
if (vs = pbm.options.binary_values)
|
44
|
-
%>puts cond ? '<%= vs[0] %>' : '<%= vs[1] %>'<%
|
45
|
-
else
|
46
|
-
%>puts ans<%
|
47
|
-
end
|
48
43
|
end
|
49
|
-
|
44
|
+
<% elsif (vs = pbm.options.binary_values) -%>
|
45
|
+
puts cond ? '<%= vs[0] %>' : '<%= vs[1] %>'
|
46
|
+
<% else -%>
|
47
|
+
puts ans
|
48
|
+
<% end -%>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: at_coder_friends
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nejiko96
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -28,14 +28,14 @@ dependencies:
|
|
28
28
|
name: launchy
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 2.4.3
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 2.4.3
|
41
41
|
- !ruby/object:Gem::Dependency
|
@@ -174,6 +174,7 @@ files:
|
|
174
174
|
- lib/at_coder_friends/parser/sample_data.rb
|
175
175
|
- lib/at_coder_friends/parser/section_wrapper.rb
|
176
176
|
- lib/at_coder_friends/parser/sections.rb
|
177
|
+
- lib/at_coder_friends/path_info.rb
|
177
178
|
- lib/at_coder_friends/path_util.rb
|
178
179
|
- lib/at_coder_friends/problem.rb
|
179
180
|
- lib/at_coder_friends/scraping/agent.rb
|
@@ -187,15 +188,6 @@ files:
|
|
187
188
|
- lib/at_coder_friends/test_runner/sample.rb
|
188
189
|
- lib/at_coder_friends/verifier.rb
|
189
190
|
- lib/at_coder_friends/version.rb
|
190
|
-
- tasks/regression/check_const.rake
|
191
|
-
- tasks/regression/check_diff.rake
|
192
|
-
- tasks/regression/check_fmt.rake
|
193
|
-
- tasks/regression/check_parse.rake
|
194
|
-
- tasks/regression/list_handler.rb
|
195
|
-
- tasks/regression/regression.rb
|
196
|
-
- tasks/regression/report_handler.rb
|
197
|
-
- tasks/regression/section_list.rake
|
198
|
-
- tasks/regression/setup.rake
|
199
191
|
- templates/cxx_builtin.cxx.erb
|
200
192
|
- templates/ruby_builtin.rb.erb
|
201
193
|
homepage: https://github.com/nejiko96/at_coder_friends
|
@@ -213,15 +205,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
213
205
|
requirements:
|
214
206
|
- - ">="
|
215
207
|
- !ruby/object:Gem::Version
|
216
|
-
version: 2.
|
208
|
+
version: 2.5.0
|
217
209
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
218
210
|
requirements:
|
219
211
|
- - ">="
|
220
212
|
- !ruby/object:Gem::Version
|
221
213
|
version: '0'
|
222
214
|
requirements: []
|
223
|
-
|
224
|
-
rubygems_version: 2.5.2.3
|
215
|
+
rubygems_version: 3.2.18
|
225
216
|
signing_key:
|
226
217
|
specification_version: 4
|
227
218
|
summary: AtCoder support tool
|
@@ -1,137 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'regression'
|
4
|
-
|
5
|
-
module AtCoderFriends
|
6
|
-
# tasks for regression
|
7
|
-
module Regression
|
8
|
-
module_function
|
9
|
-
|
10
|
-
CONST_PAT = {
|
11
|
-
mod: /
|
12
|
-
(.{,30}(?:
|
13
|
-
で割った|modulo|mod\b|divided\s+by|dividing\s+by
|
14
|
-
).{,30})
|
15
|
-
/xmi,
|
16
|
-
max: /
|
17
|
-
(.{,30}(?:
|
18
|
-
≦|≤|\\le|&leq?;
|
19
|
-
|<|\\lt|<
|
20
|
-
|以上.{1,25}以下の整数
|
21
|
-
).{,30})
|
22
|
-
/xmi
|
23
|
-
}.freeze
|
24
|
-
|
25
|
-
def collect(tgt)
|
26
|
-
open_const_report('collect', tgt) do |f|
|
27
|
-
local_pbm_list.each do |contest, q, url|
|
28
|
-
page = agent.get(url)
|
29
|
-
body = page.body.force_encoding('utf-8')
|
30
|
-
ms = body.scan(CONST_PAT[tgt.to_sym])
|
31
|
-
ms.each do |m|
|
32
|
-
s = m[0].delete("\r\n")
|
33
|
-
f.puts [contest, q, tsv_escape(s)].join("\t")
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def check_mod
|
40
|
-
open_const_report('check', 'mod') do |f|
|
41
|
-
local_pbm_list.each do |contest, q, url|
|
42
|
-
pbm = local_scraping_agent(nil, contest).fetch_problem(q, url)
|
43
|
-
Parser::Sections.process(pbm)
|
44
|
-
Parser::Modulo.process(pbm)
|
45
|
-
pbm.constants.each do |cnst|
|
46
|
-
f.puts [contest, q, cnst.value].join("\t")
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def check_max
|
53
|
-
open_const_report('check', 'max') do |f|
|
54
|
-
local_pbm_list.each do |contest, q, url|
|
55
|
-
pbm = local_scraping_agent(nil, contest).fetch_problem(q, url)
|
56
|
-
Parser::Sections.process(pbm)
|
57
|
-
Parser::Constraints.process(pbm)
|
58
|
-
pbm.constants.each do |cns|
|
59
|
-
f.puts [contest, q, "#{cns.name}:#{cns.value}"].join("\t")
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def merge_list(tgt)
|
66
|
-
tbl = load_merge_list(tgt)
|
67
|
-
save_merge_list(tgt, tbl)
|
68
|
-
end
|
69
|
-
|
70
|
-
def load_merge_list(tgt)
|
71
|
-
tbl = {}
|
72
|
-
%w[collect check]
|
73
|
-
.map { |act| load_const_report(act, tgt) }
|
74
|
-
.each
|
75
|
-
.with_index(1) do |data, n|
|
76
|
-
data
|
77
|
-
.group_by { |contest, q, _| "#{contest}\t#{q}" }
|
78
|
-
.map { |key, grp| [key, grp.map { |row| row[2] }.join("\n")] }
|
79
|
-
.each do |key, txt|
|
80
|
-
tbl[key] ||= { 'v1' => '', 'v2' => '' }
|
81
|
-
tbl[key]["v#{n}"] = '"' + txt + '"'
|
82
|
-
end
|
83
|
-
end
|
84
|
-
tbl
|
85
|
-
end
|
86
|
-
|
87
|
-
def save_merge_list(tgt, tbl)
|
88
|
-
open_const_report('merge', tgt) do |f|
|
89
|
-
tbl.sort.each do |k, h|
|
90
|
-
f.puts [k, h['v1'], h['v2']].join("\t")
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
def open_const_report(act, tgt)
|
96
|
-
open_report("#{act}_#{tgt}.txt") { |f| yield f }
|
97
|
-
end
|
98
|
-
|
99
|
-
def load_const_report(act, tgt)
|
100
|
-
file = report_path("#{act}_#{tgt}.txt")
|
101
|
-
Encoding.default_external = 'utf-8'
|
102
|
-
CSV.read(file, col_sep: "\t", headers: false)
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
namespace :regression do
|
108
|
-
desc 'list all mod values'
|
109
|
-
task :collect_mod do
|
110
|
-
AtCoderFriends::Regression.collect('mod')
|
111
|
-
end
|
112
|
-
|
113
|
-
desc 'check extracted mod values'
|
114
|
-
task :check_mod do
|
115
|
-
AtCoderFriends::Regression.check_mod
|
116
|
-
end
|
117
|
-
|
118
|
-
desc 'merge mod values list'
|
119
|
-
task :merge_mod do
|
120
|
-
AtCoderFriends::Regression.merge_list('mod')
|
121
|
-
end
|
122
|
-
|
123
|
-
desc 'list all max values'
|
124
|
-
task :collect_max do
|
125
|
-
AtCoderFriends::Regression.collect('max')
|
126
|
-
end
|
127
|
-
|
128
|
-
desc 'check extracted max values'
|
129
|
-
task :check_max do
|
130
|
-
AtCoderFriends::Regression.check_max
|
131
|
-
end
|
132
|
-
|
133
|
-
desc 'merge max values list'
|
134
|
-
task :merge_max do
|
135
|
-
AtCoderFriends::Regression.merge_list('max')
|
136
|
-
end
|
137
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'regression'
|
4
|
-
|
5
|
-
module AtCoderFriends
|
6
|
-
# tasks for regression
|
7
|
-
module Regression
|
8
|
-
module_function
|
9
|
-
|
10
|
-
def check_diff
|
11
|
-
emit_dir = format(EMIT_DIR_FMT, now: Time.now.strftime('%Y%m%d%H%M%S'))
|
12
|
-
rmdir_force(emit_dir)
|
13
|
-
|
14
|
-
local_pbm_list.each do |contest, q, url|
|
15
|
-
pbm = local_scraping_agent(emit_dir, contest).fetch_problem(q, url)
|
16
|
-
pipeline(pbm)
|
17
|
-
end
|
18
|
-
|
19
|
-
diff_log = report_path('check_diff.txt')
|
20
|
-
system("diff -r --exclude=.git #{EMIT_ORG_DIR} #{emit_dir} > #{diff_log}")
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
namespace :regression do
|
26
|
-
desc 'run regression check'
|
27
|
-
task :check_diff do
|
28
|
-
AtCoderFriends::Regression.check_diff
|
29
|
-
end
|
30
|
-
end
|