solve_pb 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +41 -0
- data/LICENSE.txt +21 -0
- data/README.md +46 -0
- data/Rakefile +6 -0
- data/bin/setup +8 -0
- data/bin/solve +9 -0
- data/lib/solve_pb.rb +26 -0
- data/lib/solve_pb/command_line.rb +33 -0
- data/lib/solve_pb/file_generator.rb +100 -0
- data/lib/solve_pb/problem.rb +17 -0
- data/lib/solve_pb/problem_parser.rb +70 -0
- data/lib/solve_pb/version.rb +3 -0
- data/solve_pb.gemspec +38 -0
- data/template/C++/compile.sh +8 -0
- data/template/C++/main.cpp +43 -0
- data/template/ruby/main.rb +17 -0
- metadata +109 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ba213c905f9975e975cdac7d25bb6bcd8c05cc2b8f3858f1c699cf15fd9a757c
|
4
|
+
data.tar.gz: 457ad104217ccc6720a87d898e7e812d872897813bc35d76d42034adcdf824c7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4a05fce420d4befcd6da1f5f5bf72083a71c6cca041713714fd2479a2651f288e48d956b58497418db9793d4cbbb9e63b7419f0cd11ed1c2c60a77fd3257da3f
|
7
|
+
data.tar.gz: a90650d519aebe905da9d463ea321813bcefc092316c656a5d70d2a7c6c72d680ece1927de5bea7a9980132b94f8718a647edd231d4ccea6aeb27e0b49112e02
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at nctruong861990@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
solve_pb (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
byebug (10.0.2)
|
10
|
+
diff-lcs (1.3)
|
11
|
+
mini_portile2 (2.1.0)
|
12
|
+
nokogiri (1.6.8.1)
|
13
|
+
mini_portile2 (~> 2.1.0)
|
14
|
+
rake (10.5.0)
|
15
|
+
rspec (3.8.0)
|
16
|
+
rspec-core (~> 3.8.0)
|
17
|
+
rspec-expectations (~> 3.8.0)
|
18
|
+
rspec-mocks (~> 3.8.0)
|
19
|
+
rspec-core (3.8.0)
|
20
|
+
rspec-support (~> 3.8.0)
|
21
|
+
rspec-expectations (3.8.1)
|
22
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
23
|
+
rspec-support (~> 3.8.0)
|
24
|
+
rspec-mocks (3.8.0)
|
25
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
26
|
+
rspec-support (~> 3.8.0)
|
27
|
+
rspec-support (3.8.0)
|
28
|
+
|
29
|
+
PLATFORMS
|
30
|
+
ruby
|
31
|
+
|
32
|
+
DEPENDENCIES
|
33
|
+
bundler (~> 1.16)
|
34
|
+
byebug
|
35
|
+
nokogiri (~> 1.6.7)
|
36
|
+
rake (~> 10.0)
|
37
|
+
rspec (~> 3.0)
|
38
|
+
solve_pb!
|
39
|
+
|
40
|
+
BUNDLED WITH
|
41
|
+
1.16.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 will
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# SolvePb
|
2
|
+
|
3
|
+
Supporting to create folders and files needed for solving problem on hackerrank.com
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'nokogiri', '~> 1.6.7'
|
11
|
+
gem 'solve_pb'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install solve_pb
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
bundle exec rake solve [hackerrank problem url]
|
26
|
+
```
|
27
|
+
|
28
|
+
We currently support Ruby (default) and C++.
|
29
|
+
|
30
|
+
## Development
|
31
|
+
|
32
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
33
|
+
|
34
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
35
|
+
|
36
|
+
## Contributing
|
37
|
+
|
38
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/solve_pb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
39
|
+
|
40
|
+
## License
|
41
|
+
|
42
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
43
|
+
|
44
|
+
## Code of Conduct
|
45
|
+
|
46
|
+
Everyone interacting in the SolvePb project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/solve_pb/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/setup
ADDED
data/bin/solve
ADDED
data/lib/solve_pb.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require "byebug"
|
2
|
+
require "solve_pb/version"
|
3
|
+
require "solve_pb/version"
|
4
|
+
require "solve_pb/problem"
|
5
|
+
require "solve_pb/problem_parser"
|
6
|
+
require "solve_pb/command_line"
|
7
|
+
require "solve_pb/file_generator"
|
8
|
+
|
9
|
+
module SolvePb
|
10
|
+
def self.root
|
11
|
+
File.dirname __dir__
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.test
|
15
|
+
File.join root, "test"
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.main
|
19
|
+
args = SolvePb::Commandline.new.parse
|
20
|
+
if args
|
21
|
+
SolvePb::FileGenerator.new.generate(args)
|
22
|
+
else
|
23
|
+
puts "Doing nothing. Abort!"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module SolvePb
|
2
|
+
class Commandline
|
3
|
+
def parse
|
4
|
+
args = [:url, :lang]
|
5
|
+
@args = {}
|
6
|
+
ARGV.each_with_index do |arg, index|
|
7
|
+
@args[args[index]] = arg if index < 2
|
8
|
+
end
|
9
|
+
if @args[:lang].nil?
|
10
|
+
puts "Using default language: Ruby"
|
11
|
+
@args[:lang] = "ruby"
|
12
|
+
end
|
13
|
+
if @args[:url].nil?
|
14
|
+
puts "Please specify at least the problem's URL. Example:"
|
15
|
+
puts "$ SolvePb https://www.hackerrank.com/challenges/acm-icpc-team"
|
16
|
+
return nil
|
17
|
+
end
|
18
|
+
if @args.size > 2
|
19
|
+
puts "More than 2 parameters specified. Ignored last #{ARGV.size - 2} params."
|
20
|
+
end
|
21
|
+
unless supported_language? @args[:lang]
|
22
|
+
puts "#{@args[:lang]} is not supported yet."
|
23
|
+
return nil
|
24
|
+
end
|
25
|
+
return @args
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
def supported_language?(lang)
|
30
|
+
["c++", "ruby"].include?(lang)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'solve_pb/problem_parser'
|
4
|
+
|
5
|
+
module SolvePb
|
6
|
+
class FileGenerator
|
7
|
+
attr_reader :problem, :language
|
8
|
+
|
9
|
+
def generate(args)
|
10
|
+
@problem = ProblemParser.new.parse(args[:url])
|
11
|
+
@language = args[:lang]
|
12
|
+
if problem
|
13
|
+
puts "Preparing workspace"
|
14
|
+
create_directory
|
15
|
+
create_readme
|
16
|
+
create_main_program
|
17
|
+
create_sample_input
|
18
|
+
create_sample_output
|
19
|
+
download_pb_statement
|
20
|
+
# create_runsh(problem, language)
|
21
|
+
else
|
22
|
+
puts "Couldn't fetch problem information. Please raise an issue on https://github.com/nctruong/solve_pb"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def create_directory
|
29
|
+
puts "\tcreate #{File.join(problem.name, '')}"
|
30
|
+
Dir.mkdir(problem.name)
|
31
|
+
end
|
32
|
+
|
33
|
+
def create_main_program
|
34
|
+
main_file_name = get_main_file_name
|
35
|
+
main_file_path = File.join(
|
36
|
+
SolvePb.root, "template",
|
37
|
+
language, main_file_name)
|
38
|
+
des_path = File.join(problem.name, main_file_name)
|
39
|
+
puts "\tcreate #{des_path}"
|
40
|
+
FileUtils.cp(main_file_path, des_path)
|
41
|
+
end
|
42
|
+
|
43
|
+
def create_sample_input
|
44
|
+
path = File.join(problem.name, "sample.input")
|
45
|
+
unless file_exists?(path)
|
46
|
+
open(path, 'w') do |f|
|
47
|
+
f.write(problem.sample_input)
|
48
|
+
end
|
49
|
+
puts "\tcreate #{path}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def create_sample_output
|
54
|
+
path = File.join(problem.name, "sample.output")
|
55
|
+
unless file_exists?(path)
|
56
|
+
open(path, 'w') do |f|
|
57
|
+
f.write(problem.sample_output)
|
58
|
+
end
|
59
|
+
puts "\tcreate #{path}"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def create_runsh
|
64
|
+
runsh_path = File.join(
|
65
|
+
SolvePb.root, "template", language, "compile.sh")
|
66
|
+
des_path = File.join(problem.name, "run.sh")
|
67
|
+
puts "\tcreate #{des_path}"
|
68
|
+
FileUtils.cp(runsh_path, des_path)
|
69
|
+
FileUtils.chmod("a+x", des_path)
|
70
|
+
end
|
71
|
+
|
72
|
+
def get_main_file_name
|
73
|
+
return "main.rb" if language == "ruby"
|
74
|
+
end
|
75
|
+
|
76
|
+
def create_readme
|
77
|
+
path = File.join(problem.name, "readme.md")
|
78
|
+
unless file_exists?(path)
|
79
|
+
open(path, 'w') do |f|
|
80
|
+
f.write("[#{problem.name.capitalize} url](#{problem.url})")
|
81
|
+
end
|
82
|
+
puts "\tcreate #{path}"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def download_pb_statement
|
87
|
+
path = File.join(problem.name, "#{problem.name}.pdf")
|
88
|
+
unless file_exists?(path)
|
89
|
+
download = open(problem.download_pdf)
|
90
|
+
IO.copy_stream(download, path)
|
91
|
+
puts "\tcreate #{path}"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def file_exists?(path)
|
96
|
+
raise "\tignore #{path}. It already exists." if File.exist?(path)
|
97
|
+
false
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module SolvePb
|
2
|
+
class Problem
|
3
|
+
|
4
|
+
attr_accessor :url, :name, :sample_input, :sample_output
|
5
|
+
|
6
|
+
def initialize(url, name, sample_input, sample_output)
|
7
|
+
self.url = url
|
8
|
+
self.name = name
|
9
|
+
self.sample_input = sample_input
|
10
|
+
self.sample_output = sample_output
|
11
|
+
end
|
12
|
+
|
13
|
+
def download_pdf
|
14
|
+
"https://www.hackerrank.com/rest/contests/master/challenges/#{name}/download_pdf?language=English"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
3
|
+
require 'uri'
|
4
|
+
require 'nokogiri'
|
5
|
+
|
6
|
+
module SolvePb
|
7
|
+
class ProblemParser
|
8
|
+
def parse(url)
|
9
|
+
uri = URI(get_problem_info_url(url))
|
10
|
+
problem_info = nil
|
11
|
+
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
|
12
|
+
request = Net::HTTP::Get.new uri
|
13
|
+
response = http.request request
|
14
|
+
problem_info = response.body
|
15
|
+
end
|
16
|
+
@problem_json = JSON.parse(problem_info)
|
17
|
+
Problem.new(
|
18
|
+
url,
|
19
|
+
get_problem_name_from_json,
|
20
|
+
get_problem_sample_input_from_json,
|
21
|
+
get_problem_sample_output_from_json)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
def get_problem_name_from_json
|
26
|
+
return @problem_json['model']['slug']
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_problem_sample_input_from_json
|
30
|
+
result = doc.css("div.challenge_sample_input_body code").text
|
31
|
+
if result.strip.size == 0
|
32
|
+
result = doc.css("div.challenge_sample_input_body p").text
|
33
|
+
end
|
34
|
+
if result.strip.size == 0
|
35
|
+
result = doc.xpath('//strong[contains(text(), "Sample Input")]').first
|
36
|
+
.parent.next_element.text
|
37
|
+
end
|
38
|
+
return result
|
39
|
+
end
|
40
|
+
|
41
|
+
def get_problem_sample_output_from_json
|
42
|
+
result = doc.css("div.challenge_sample_output_body code").text
|
43
|
+
if result.strip.size == 0
|
44
|
+
result = doc.css("div.challenge_sample_output_body p").text
|
45
|
+
end
|
46
|
+
if result.strip.size == 0
|
47
|
+
result = doc.xpath('//strong[contains(text(), "Sample Output")]').first
|
48
|
+
.parent.next_element.text
|
49
|
+
end
|
50
|
+
return result
|
51
|
+
end
|
52
|
+
|
53
|
+
def get_problem_slug(url)
|
54
|
+
uri = URI(url)
|
55
|
+
uri.path.split('/').last
|
56
|
+
end
|
57
|
+
|
58
|
+
def get_problem_info_url(url)
|
59
|
+
"https://www.hackerrank.com/rest/contests/master/challenges/#{get_problem_slug(url)}"
|
60
|
+
end
|
61
|
+
|
62
|
+
def doc
|
63
|
+
@doc ||= Nokogiri::HTML(
|
64
|
+
@problem_json['model']['body_html'].force_encoding('UTF-8').tap do |html|
|
65
|
+
# puts html
|
66
|
+
end
|
67
|
+
)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
data/solve_pb.gemspec
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "solve_pb/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "solve_pb"
|
8
|
+
spec.version = SolvePb::VERSION
|
9
|
+
spec.authors = ["Will Nguyen"]
|
10
|
+
spec.email = ["nctruong861990@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Prepare source to solve problem}
|
13
|
+
spec.description = %q{Prepare source to solve problem}
|
14
|
+
spec.homepage = "https://github.com/nctruong/solve_pb"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
# if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata["allowed_push_host"] = "Set to 'https://rubygems.org'"
|
21
|
+
# else
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
# "public gem pushes."
|
24
|
+
# end
|
25
|
+
|
26
|
+
# Specify which files should be added to the gem when it is released.
|
27
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
28
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
29
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
30
|
+
end
|
31
|
+
spec.bindir = "bin"
|
32
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
33
|
+
spec.require_paths = ["lib"]
|
34
|
+
|
35
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
36
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
37
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
38
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
echo "Compile your solution:"
|
4
|
+
g++ main.cpp -o solution
|
5
|
+
echo "Running your solution with sample input: sample.input. Output is directed to: my_result.output"
|
6
|
+
./solution < sample.input > my_result.output
|
7
|
+
echo "Compare your result to sample.output"
|
8
|
+
cmp --silent my_result.output sample.output && echo "Result: Accepted" || echo "Result: Wrong Answer"
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#include <cstdio>
|
2
|
+
|
3
|
+
// Input macros
|
4
|
+
#define s(n) scanf("%d",&n)
|
5
|
+
#define sc(n) scanf("%c",&n)
|
6
|
+
#define sl(n) scanf("%lld",&n)
|
7
|
+
#define sf(n) scanf("%lf",&n)
|
8
|
+
#define ss(n) scanf("%s",n)
|
9
|
+
|
10
|
+
// Useful iteration macros
|
11
|
+
#define rep(i,n) for(int i=0, _##i=(n); i<_##i; ++i)
|
12
|
+
#define dwn(i,n) for(int i=(n); --i>=0; )
|
13
|
+
#define repr(i,l,r) for(int i=(l), _##i=(r); i<_##i; ++i)
|
14
|
+
#define dwnr(i,l,r) for(int i=(r), _##i=(l); --i>=_##i; )
|
15
|
+
|
16
|
+
// Useful constants
|
17
|
+
#define INF (int)1e9
|
18
|
+
#define EPS 1e-9
|
19
|
+
|
20
|
+
// Useful hardware instructions
|
21
|
+
#define bitcount __builtin_popcount
|
22
|
+
#define gcd __gcd
|
23
|
+
|
24
|
+
// Useful container manipulation / traversal macros
|
25
|
+
#define forall(i,a,b) for(int i=a;i<b;i++)
|
26
|
+
#define foreach(v, c) for( typeof( (c).begin()) v = (c).begin(); v != (c).end(); ++v)
|
27
|
+
#define all(a) a.begin(), a.end()
|
28
|
+
#define in(a,b) ( (b).find(a) != (b).end())
|
29
|
+
#define pb push_back
|
30
|
+
#define fill(a,v) memset(a, v, sizeof a)
|
31
|
+
#define sz(a) ((int)(a.size()))
|
32
|
+
#define mp make_pair
|
33
|
+
|
34
|
+
// Some common useful functions
|
35
|
+
#define maX(a,b) ( (a) > (b) ? (a) : (b))
|
36
|
+
#define miN(a,b) ( (a) < (b) ? (a) : (b))
|
37
|
+
#define checkbit(n,b) ( (n >> b) & 1)
|
38
|
+
#define DREP(a) sort(all(a)); a.erase(unique(all(a)),a.end())
|
39
|
+
#define INDEX(arr,ind) (lower_bound(all(arr),ind)-arr.begin())
|
40
|
+
|
41
|
+
int main() {
|
42
|
+
return 0;
|
43
|
+
}
|
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: solve_pb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Will Nguyen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-08-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: Prepare source to solve problem
|
56
|
+
email:
|
57
|
+
- nctruong861990@gmail.com
|
58
|
+
executables:
|
59
|
+
- setup
|
60
|
+
- solve
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- ".gitignore"
|
65
|
+
- ".rspec"
|
66
|
+
- ".travis.yml"
|
67
|
+
- CODE_OF_CONDUCT.md
|
68
|
+
- Gemfile
|
69
|
+
- Gemfile.lock
|
70
|
+
- LICENSE.txt
|
71
|
+
- README.md
|
72
|
+
- Rakefile
|
73
|
+
- bin/setup
|
74
|
+
- bin/solve
|
75
|
+
- lib/solve_pb.rb
|
76
|
+
- lib/solve_pb/command_line.rb
|
77
|
+
- lib/solve_pb/file_generator.rb
|
78
|
+
- lib/solve_pb/problem.rb
|
79
|
+
- lib/solve_pb/problem_parser.rb
|
80
|
+
- lib/solve_pb/version.rb
|
81
|
+
- solve_pb.gemspec
|
82
|
+
- template/C++/compile.sh
|
83
|
+
- template/C++/main.cpp
|
84
|
+
- template/ruby/main.rb
|
85
|
+
homepage: https://github.com/nctruong/solve_pb
|
86
|
+
licenses:
|
87
|
+
- MIT
|
88
|
+
metadata: {}
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options: []
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
requirements: []
|
104
|
+
rubyforge_project:
|
105
|
+
rubygems_version: 2.7.6
|
106
|
+
signing_key:
|
107
|
+
specification_version: 4
|
108
|
+
summary: Prepare source to solve problem
|
109
|
+
test_files: []
|