hackerrankit 0.1.0
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 +50 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/hackerrankit +5 -0
- data/bin/setup +8 -0
- data/hackerrankit.gemspec +36 -0
- data/lib/hackerrankit/command_line.rb +33 -0
- data/lib/hackerrankit/file_generator.rb +81 -0
- data/lib/hackerrankit/problem.rb +12 -0
- data/lib/hackerrankit/problem_parser.rb +52 -0
- data/lib/hackerrankit/version.rb +3 -0
- data/lib/hackerrankit.rb +24 -0
- data/template/C++/compile.sh +8 -0
- data/template/C++/main.cpp +43 -0
- metadata +107 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 75ab49cacab002c0a5e70b0eed006fd0fd0b6b1d
|
4
|
+
data.tar.gz: 38450fcfbf380dc0a37f4f141ab2b48370a25b75
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 55d8923b39e1d317a897a151d37f28bf8aca10a9036f820beb097cc198edab79141abc68a070ffda5803035720648d9a02e7226820518e8717522b23bccb436e
|
7
|
+
data.tar.gz: 0ac95fb7c99ccf5ff22aa0c5968a1b87ba29bd0c1f5800dcddf9211fb9d82636e5e75ccf765ccaceca346aecbf32e7b92f7de4627fc28ccb11304c4814e64c96
|
data/.gitignore
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
## Specific to RubyMotion:
|
17
|
+
.dat*
|
18
|
+
.repl_history
|
19
|
+
build/
|
20
|
+
*.bridgesupport
|
21
|
+
build-iPhoneOS/
|
22
|
+
build-iPhoneSimulator/
|
23
|
+
|
24
|
+
## Specific to RubyMotion (use of CocoaPods):
|
25
|
+
#
|
26
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
27
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
28
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
29
|
+
#
|
30
|
+
# vendor/Pods/
|
31
|
+
|
32
|
+
## Documentation cache and generated files:
|
33
|
+
/.yardoc/
|
34
|
+
/_yardoc/
|
35
|
+
/doc/
|
36
|
+
/rdoc/
|
37
|
+
|
38
|
+
## Environment normalization:
|
39
|
+
/.bundle/
|
40
|
+
/vendor/bundle
|
41
|
+
/lib/bundler/man/
|
42
|
+
|
43
|
+
# for a library or gem, you might want to ignore these files since the code is
|
44
|
+
# intended to run in multiple environments; otherwise, check them in:
|
45
|
+
Gemfile.lock
|
46
|
+
.ruby-version
|
47
|
+
.ruby-gemset
|
48
|
+
|
49
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
50
|
+
.rvmrc
|
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 vu.tran54@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/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 tranvictor
|
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,41 @@
|
|
1
|
+
# HackerrankIt
|
2
|
+
Command line tool to initialize a small project directory to solve a problem.
|
3
|
+
|
4
|
+
## Supported Languages
|
5
|
+
1. C++
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
Assume you already have Ruby installed in your environment.
|
9
|
+
|
10
|
+
```
|
11
|
+
gem install hackerrankit
|
12
|
+
```
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
`hackerrankit` will treat your current working directory as the root point to create separated directory for each problem you are going to solve.
|
16
|
+
|
17
|
+
```
|
18
|
+
hackerrankit [url] [language]
|
19
|
+
```
|
20
|
+
|
21
|
+
where `[url]` is the url to the problem on Hackerrank.
|
22
|
+
|
23
|
+
`language` is the language you are going to solve the problem. To keep this gem simple, I don't consider the situation where you want to solve a problem with more than one language. Default: `C++`.
|
24
|
+
|
25
|
+
## What `hackerrankit` actually does
|
26
|
+
After you issue `hackerrankit`, it does the following steps:
|
27
|
+
|
28
|
+
1. Silently go to the url to extract information about that problem such as `name`, `sample input`, `sample output`.
|
29
|
+
2. Base on the `name`, it creates a directory inside your current working directory whose name equals to the problem's name replaced spaces with `-` character. Example: `ACM ICPC Team` -> `acm-icpc-team`.
|
30
|
+
3. Base on the language you specified in the command, it creates minimal necessary files for you to start working on the problem right a way. For example, with `C++`, it creates `main.cpp`, `sample.input`, `sample.out`, and `run.sh` for you to compile your solution, run it with `sample.input` and compare to `sample.output`. Its output is either `Accepted` or `Wrong Answer`.
|
31
|
+
4. `hackerrankit` will try its best to initialize your `main.cpp` with useful declarations so you don't need to worry about them everytime you want to practising problem solving. For example: with `C++`, it will have common includes and useful `#define`, `main` function.
|
32
|
+
|
33
|
+
## Want to contribute?
|
34
|
+
This is firstly my gem to make my problem solving practising less time consuming so I will only focus on the language that I use. Currently is `C++`.
|
35
|
+
|
36
|
+
If you want to support your preferred language such as `Ruby`, `Python`, `Java`, `C`, `Pascal` whatever. Feel free to folk and make a PR. Or you just want to make it for yourself, feel free to copy the tool. Even nicer if you can give this repository a star which would definitely make my day.
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "hackerrankit"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/hackerrankit
ADDED
data/bin/setup
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'hackerrankit/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "hackerrankit"
|
8
|
+
spec.version = Hackerrankit::VERSION
|
9
|
+
spec.authors = ["tranvictor"]
|
10
|
+
spec.email = ["vu.tran54@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Command line tool to initialize a small project directory to solve a problem.}
|
13
|
+
spec.description = %q{Command line tool to initialize a small project directory to solve a problem.}
|
14
|
+
spec.homepage = "https://github.com/tranvictor/hackerrankit"
|
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'] = "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
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
28
|
+
end
|
29
|
+
spec.bindir = "bin"
|
30
|
+
spec.executables = ['hackerrankit']
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
34
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
35
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
36
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Hackerrankit
|
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: C++"
|
11
|
+
@args[:lang] = "C++"
|
12
|
+
end
|
13
|
+
if @args[:url].nil?
|
14
|
+
puts "Please specify at least the problem's URL. Example:"
|
15
|
+
puts "$ hackerrankit 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++"].include?(lang)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'hackerrankit/problem_parser'
|
3
|
+
|
4
|
+
module Hackerrankit
|
5
|
+
class FileGenerator
|
6
|
+
def generate(args)
|
7
|
+
problem = ProblemParser.new.parse(args[:url])
|
8
|
+
language = args[:lang]
|
9
|
+
if problem
|
10
|
+
puts "Creating problem directory skeleton"
|
11
|
+
# create problem directory
|
12
|
+
create_directory(problem)
|
13
|
+
# create main program file base on language
|
14
|
+
create_main_program(problem, language)
|
15
|
+
# create sample.input
|
16
|
+
create_sample_input(problem)
|
17
|
+
# create sample.output
|
18
|
+
create_sample_output(problem)
|
19
|
+
# create run.sh base on language
|
20
|
+
create_runsh(problem, language)
|
21
|
+
else
|
22
|
+
puts "Couldn't fetch problem information. Please fire an issue on https://github.com/tranvictor/hackerrankit"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
def create_directory(problem)
|
28
|
+
puts "\tcreate #{File.join(problem.name, '')}"
|
29
|
+
Dir.mkdir(problem.name)
|
30
|
+
end
|
31
|
+
|
32
|
+
def create_main_program(problem, language)
|
33
|
+
main_file_name = get_main_file_name(language)
|
34
|
+
main_file_path = File.join(
|
35
|
+
Hackerrankit.root, "template",
|
36
|
+
language, main_file_name)
|
37
|
+
des_path = File.join(problem.name, main_file_name)
|
38
|
+
puts "\tcreate #{des_path}"
|
39
|
+
FileUtils.cp(main_file_path, des_path)
|
40
|
+
end
|
41
|
+
|
42
|
+
def create_sample_input(problem)
|
43
|
+
path = File.join(problem.name, "sample.input")
|
44
|
+
if File.exist?(path)
|
45
|
+
puts "\tignore #{path}. It already exists."
|
46
|
+
else
|
47
|
+
open(path, 'w') do |f|
|
48
|
+
f.write(problem.sample_input)
|
49
|
+
end
|
50
|
+
puts "\tcreate #{path}"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def create_sample_output(problem)
|
55
|
+
path = File.join(problem.name, "sample.output")
|
56
|
+
if File.exist?(path)
|
57
|
+
puts "\tignore #{path}. It already exists."
|
58
|
+
else
|
59
|
+
open(path, 'w') do |f|
|
60
|
+
f.write(problem.sample_output)
|
61
|
+
end
|
62
|
+
puts "\tcreate #{path}"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def create_runsh(problem, language)
|
67
|
+
runsh_path = File.join(
|
68
|
+
Hackerrankit.root, "template", language, "compile.sh")
|
69
|
+
des_path = File.join(problem.name, "run.sh")
|
70
|
+
puts "\tcreate #{des_path}"
|
71
|
+
FileUtils.cp(runsh_path, des_path)
|
72
|
+
FileUtils.chmod("a+x", des_path)
|
73
|
+
end
|
74
|
+
|
75
|
+
def get_main_file_name(language)
|
76
|
+
if language == "C++"
|
77
|
+
"main.cpp"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Hackerrankit
|
2
|
+
class Problem
|
3
|
+
attr_accessor :url, :name, :sample_input, :sample_output
|
4
|
+
|
5
|
+
def initialize(url, name, sample_input, sample_output)
|
6
|
+
self.url = url
|
7
|
+
self.name = name
|
8
|
+
self.sample_input = sample_input
|
9
|
+
self.sample_output = sample_output
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
3
|
+
require 'uri'
|
4
|
+
require 'nokogiri'
|
5
|
+
|
6
|
+
module Hackerrankit
|
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
|
+
doc.css("div.challenge_sample_input_body code").text
|
31
|
+
end
|
32
|
+
|
33
|
+
def get_problem_sample_output_from_json
|
34
|
+
doc.css("div.challenge_sample_output_body code").text
|
35
|
+
end
|
36
|
+
|
37
|
+
def get_problem_slug(url)
|
38
|
+
uri = URI(url)
|
39
|
+
uri.path.split('/').last
|
40
|
+
end
|
41
|
+
|
42
|
+
def get_problem_info_url(url)
|
43
|
+
"https://www.hackerrank.com/rest/contests/master/challenges/#{get_problem_slug(url)}"
|
44
|
+
end
|
45
|
+
|
46
|
+
def doc
|
47
|
+
@doc ||= Nokogiri::HTML(
|
48
|
+
@problem_json['model']['body_html'].force_encoding('UTF-8')
|
49
|
+
)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/hackerrankit.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require "hackerrankit/version"
|
2
|
+
require "hackerrankit/problem"
|
3
|
+
require "hackerrankit/problem_parser"
|
4
|
+
require "hackerrankit/command_line"
|
5
|
+
require "hackerrankit/file_generator"
|
6
|
+
|
7
|
+
module Hackerrankit
|
8
|
+
def self.root
|
9
|
+
File.dirname __dir__
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.test
|
13
|
+
File.join root, "test"
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.main
|
17
|
+
args = Hackerrankit::Commandline.new.parse
|
18
|
+
if args
|
19
|
+
Hackerrankit::FileGenerator.new.generate(args)
|
20
|
+
else
|
21
|
+
puts "Doing nothing. Abort!"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
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,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hackerrankit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- tranvictor
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-01-05 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.13'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.13'
|
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: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
description: Command line tool to initialize a small project directory to solve a
|
56
|
+
problem.
|
57
|
+
email:
|
58
|
+
- vu.tran54@gmail.com
|
59
|
+
executables:
|
60
|
+
- hackerrankit
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- .gitignore
|
65
|
+
- CODE_OF_CONDUCT.md
|
66
|
+
- Gemfile
|
67
|
+
- LICENSE.txt
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- bin/console
|
71
|
+
- bin/hackerrankit
|
72
|
+
- bin/setup
|
73
|
+
- hackerrankit.gemspec
|
74
|
+
- lib/hackerrankit.rb
|
75
|
+
- lib/hackerrankit/command_line.rb
|
76
|
+
- lib/hackerrankit/file_generator.rb
|
77
|
+
- lib/hackerrankit/problem.rb
|
78
|
+
- lib/hackerrankit/problem_parser.rb
|
79
|
+
- lib/hackerrankit/version.rb
|
80
|
+
- template/C++/compile.sh
|
81
|
+
- template/C++/main.cpp
|
82
|
+
homepage: https://github.com/tranvictor/hackerrankit
|
83
|
+
licenses:
|
84
|
+
- MIT
|
85
|
+
metadata:
|
86
|
+
allowed_push_host: https://rubygems.org
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 2.0.14.1
|
104
|
+
signing_key:
|
105
|
+
specification_version: 4
|
106
|
+
summary: Command line tool to initialize a small project directory to solve a problem.
|
107
|
+
test_files: []
|