do_not_download 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e8d9ebd22cd025c6e6e4c3cc365bc9dd66453ca1
4
+ data.tar.gz: 879a76ce32d14acd481e8a721fb24b4a5781f9a4
5
+ SHA512:
6
+ metadata.gz: 69ea620f5fec3c75a1b2bc70290f101a51d5d88831cba2f2362a4e0c7ee5ab2159af85f4f37ed28eb7756b54a8a929d2a35401f188ad28903886ea1ac634496a
7
+ data.tar.gz: 8028bfa4a8b0248039d966794a4aa35c47ffc884c120221d814eabfe72f4ef33fc7b6a443171461015fcf1890e1bf9843a4c84ecdc7f098f9b8f8058c744d0fc
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.3
4
+ before_install: gem install bundler -v 1.10.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in do_not_download.gemspec
4
+ gemspec
@@ -0,0 +1,36 @@
1
+ # DoNotDownload
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/do_not_download`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'do_not_download'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install do_not_download
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/do_not_download.
36
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "do_not_download"
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
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'do_not_download/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "do_not_download"
8
+ spec.version = DoNotDownload::VERSION
9
+ spec.authors = ["Hatter23"]
10
+ spec.email = ["i.mad.as.hatter@gmail.com"]
11
+
12
+ spec.summary = "a"
13
+ spec.description = "b"
14
+ spec.homepage = "https://github.com/Hatter23/Codebreaker"
15
+
16
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
17
+ # delete this section to allow pushing this gem to any host.
18
+ #if spec.respond_to?(:metadata)
19
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
20
+ #else
21
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
22
+ #end
23
+
24
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+
29
+ spec.add_development_dependency "bundler", "~> 1.10"
30
+ spec.add_development_dependency "rake", "~> 10.0"
31
+ spec.add_development_dependency "rspec"
32
+ end
@@ -0,0 +1,6 @@
1
+ require "do_not_download/version"
2
+ require "do_not_download/game"
3
+
4
+ module DoNotDownload
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,60 @@
1
+ module Codebreaker
2
+ class Game
3
+ attr_reader :marking
4
+
5
+ def initialize
6
+ @secret_code, @marking, @use_hint = "", "", 0
7
+ end
8
+
9
+ SIZE_CODE, FIRST_CHAR, LAST_CHAR, = 4, "1", "6"
10
+
11
+ def start
12
+ SIZE_CODE.times {@secret_code << (1 + rand(6)).to_s}
13
+ @secret_code
14
+ end
15
+
16
+ def shift(p, m)
17
+ plus, minus = 0, 0
18
+ p.map { |v| plus += v }
19
+ m.map { |v| minus += v }
20
+ blank = SIZE_CODE - plus - minus
21
+ ("+" * plus) + ("-" * minus) + (" " * blank)
22
+ end
23
+
24
+ def replase(str, i, rep_v)
25
+ str[0...i] + rep_v + str[i+1..str.size]
26
+ end
27
+
28
+ def win?(marking, i, n, h = @use_hint) # i - current iteration ; n - number iteration
29
+ marking.size == marking.count("+") ? ((n * 100) - ((i-1) * 100) - (100 * h)) : false
30
+ end
31
+
32
+ def hint(secret = @secret_code)
33
+ @use_hint, index, str = 1, Random.rand(SIZE_CODE), "*" * SIZE_CODE
34
+ replase(str, index, secret[index])
35
+ end
36
+
37
+ def progress(breake = "", secret = @secret_code)
38
+ @marking, plus, minus = "", [], []
39
+
40
+ (0...SIZE_CODE).each do |i|
41
+ breake[i] == secret[i] ? plus << 1 : plus << 0
42
+ end
43
+
44
+ plus.each_index do |i|
45
+ if plus[i] == 1
46
+ secret = replase(secret, i, "0")
47
+ breake = replase(breake, i, "#{LAST_CHAR.to_i + 1}")
48
+ end
49
+ end
50
+
51
+ (0...SIZE_CODE).each do |i|
52
+ secret[breake[i]] ? minus << 1 && secret = replase(secret, i-1, "0") : minus << 0
53
+ end
54
+
55
+ @marking = shift(plus, minus)
56
+ end
57
+
58
+ end
59
+ end
60
+
@@ -0,0 +1,3 @@
1
+ module DoNotDownload
2
+ VERSION = "0.1.2"
3
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: do_not_download
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Hatter23
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-06-01 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.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
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: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: b
56
+ email:
57
+ - i.mad.as.hatter@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".travis.yml"
65
+ - Gemfile
66
+ - README.md
67
+ - Rakefile
68
+ - bin/console
69
+ - bin/setup
70
+ - do_not_download.gemspec
71
+ - lib/do_not_download.rb
72
+ - lib/do_not_download/game.rb
73
+ - lib/do_not_download/version.rb
74
+ homepage: https://github.com/Hatter23/Codebreaker
75
+ licenses: []
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.4.7
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: a
97
+ test_files: []