Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grains #33

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
7b775c8
gigasecond program
mayur-kambariya Jan 11, 2017
2ac4569
gigasecond program
mayur-kambariya Jan 11, 2017
8fcd19d
Update Comment code Gigasecond
mayur-kambariya Jan 12, 2017
58d392b
rna Transcription Upload 1
mayur-kambariya Jan 12, 2017
f9116be
Update rna_transcription 2
mayur-kambariya Jan 12, 2017
0a0bbe8
raindrops upload succefully 1
mayur-kambariya Jan 12, 2017
a6c9790
Difference of squares is upload 1
mayur-kambariya Jan 12, 2017
4773c7c
this pangram program using .each loop
mayur-kambariya Jan 12, 2017
bb87e42
Roman Numerals Uploaded succefully
mayur-kambariya Jan 13, 2017
2990202
Binary Digit convert into Decimal number 1
mayur-kambariya Jan 13, 2017
6ffa5bb
phone Number upload ok 1
mayur-kambariya Jan 13, 2017
75d3630
Roman numerals in short logic program second
mayur-kambariya Jan 16, 2017
f6a72ee
Roman numerals in short logic program second
mayur-kambariya Jan 16, 2017
70e859f
Space age Problem first
mayur-kambariya Jan 16, 2017
18d67fa
Rail fence cipher uploaded
mayur-kambariya Jan 16, 2017
63823ec
Hexadecimal Convert to Decimal number 1
mayur-kambariya Jan 17, 2017
8c4b22c
Queen attack Check 1
mayur-kambariya Jan 17, 2017
8b355f5
Atbash cipher is uploaded 1
mayur-kambariya Jan 17, 2017
eabfa8b
String convert into Maths equation successfull 1
mayur-kambariya Jan 18, 2017
fb7389d
largest series product find inside given string
mayur-kambariya Jan 18, 2017
b0637af
pascals triangle uploaded
mayur-kambariya Jan 18, 2017
8601653
isogram return letter is or not
mayur-kambariya Jan 19, 2017
412471b
ETL Commit Successfully 1
mayur-kambariya Jan 20, 2017
6072c09
Sum of Multiples is uploaded 1
mayur-kambariya Jan 20, 2017
e0ed246
binary number update 2
mayur-kambariya Jan 20, 2017
41cfb29
clock time without dates
mayur-kambariya Jan 20, 2017
0b7b184
allergiries problem uploaded 1
mayur-kambariya Jan 23, 2017
7a2450a
Bracket push checking uploaded 1
mayur-kambariya Jan 24, 2017
be92a91
Triangle is uploaded 1
mayur-kambariya Jan 24, 2017
c9aee23
Binary Search faster uploaded 1
mayur-kambariya Jan 25, 2017
cf338b2
Abbreviate is Uploaded 1
mayur-kambariya Jan 25, 2017
8324ea3
say In english word 1
mayur-kambariya Jan 26, 2017
77df6d1
Sieve find prime number upto Given number 1
mayur-kambariya Jan 26, 2017
de98217
Robot Name display every time different 1
mayur-kambariya Jan 26, 2017
8873524
Nth prime number 1
mayur-kambariya Jan 26, 2017
7a90373
check Year is leap or not 1
mayur-kambariya Jan 26, 2017
b2d44e8
Grains chechborad uploaded 1
mayur-kambariya Jan 26, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions acronym/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Acronym

Convert a long phrase to its acronym

Techies love their TLA (Three Letter Acronyms)!

Help generate some jargon by writing a program that converts a long name
like Portable Network Graphics to its acronym (PNG).


* * * *

For installation and learning resources, refer to the
[exercism help page](http://exercism.io/languages/ruby).

For running the tests provided, you will need the Minitest gem. Open a
terminal window and run the following command to install minitest:

gem install minitest

If you would like color output, you can `require 'minitest/pride'` in
the test file, or note the alternative instruction, below, for running
the test file.

In order to run the test, you can run the test file from the exercise
directory. For example, if the test suite is called
`hello_world_test.rb`, you can run the following command:

ruby hello_world_test.rb

To include color from the command line:

ruby -r minitest/pride hello_world_test.rb

The test files may have the execution bit set so you may also be able to
run it like this:

./hello_world_test.rb

## Source

Julien Vanier [https://github.com/monkbroc](https://github.com/monkbroc)

## Submitting Incomplete Problems
It's possible to submit an incomplete solution so you can see how others have completed the exercise.

9 changes: 9 additions & 0 deletions acronym/acronym.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Acronym
def self.abbreviate(string)
string_con = ''
string.gsub!(/[-]/,' ')
string.gsub!(/(?<=[a-z])(?=[A-Z])/, ' ')
string.split(' ').to_a.each{|i| string_con += "#{i[0,1]}" }
string_con.upcase
end
end
59 changes: 59 additions & 0 deletions acronym/acronym_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env ruby
gem 'minitest', '>= 5.0.0'
require 'minitest/autorun'
require_relative 'acronym'

# Test data version:
# 5b5e807
class AcronymTest < Minitest::Test
def test_basic
assert_equal 'PNG', Acronym.abbreviate('Portable Network Graphics')
end

def test_lowercase_words
# skip
assert_equal 'ROR', Acronym.abbreviate('Ruby on Rails')
end

def test_camelcase
# skip
assert_equal 'HTML', Acronym.abbreviate('HyperText Markup Language')
end

def test_punctuation
# skip
assert_equal 'FIFO', Acronym.abbreviate('First In, First Out')
end

def test_all_caps_words
# skip
assert_equal 'PHP', Acronym.abbreviate('PHP: Hypertext Preprocessor')
end

def test_hyphenated
# skip
assert_equal 'CMOS', Acronym.abbreviate('Complementary metal-oxide semiconductor')
end

# Problems in exercism evolve over time, as we find better ways to ask
# questions.
# The version number refers to the version of the problem you solved,
# not your solution.
#
# Define a constant named VERSION inside of the top level BookKeeping
# module, which may be placed near the end of your file.
#
# In your file, it will look like this:
#
# module BookKeeping
# VERSION = 1 # Where the version number matches the one in the test.
# end
#
# If you are curious, read more about constants on RubyDoc:
# http://ruby-doc.org/docs/ruby-doc-bundle/UsersGuide/rg/constants.html

def test_bookkeeping
skip
assert_equal 2, BookKeeping::VERSION
end
end
68 changes: 68 additions & 0 deletions allergies/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Allergies

Write a program that, given a person's allergy score, can tell them whether or not they're allergic to a given item, and their full list of allergies.

An allergy test produces a single numeric score which contains the
information about all the allergies the person has (that they were
tested for).

The list of items (and their value) that were tested are:

* eggs (1)
* peanuts (2)
* shellfish (4)
* strawberries (8)
* tomatoes (16)
* chocolate (32)
* pollen (64)
* cats (128)

So if Tom is allergic to peanuts and chocolate, he gets a score of 34.

Now, given just that score of 34, your program should be able to say:

- Whether Tom is allergic to any one of those allergens listed above.
- All the allergens Tom is allergic to.

Note: a given score may include allergens **not** listed above (i.e.
allergens that score 256, 512, 1024, etc.). Your program should
ignore those components of the score. For example, if the allergy
score is 257, your program should only report the eggs (1) allergy.


* * * *

For installation and learning resources, refer to the
[exercism help page](http://exercism.io/languages/ruby).

For running the tests provided, you will need the Minitest gem. Open a
terminal window and run the following command to install minitest:

gem install minitest

If you would like color output, you can `require 'minitest/pride'` in
the test file, or note the alternative instruction, below, for running
the test file.

In order to run the test, you can run the test file from the exercise
directory. For example, if the test suite is called
`hello_world_test.rb`, you can run the following command:

ruby hello_world_test.rb

To include color from the command line:

ruby -r minitest/pride hello_world_test.rb

The test files may have the execution bit set so you may also be able to
run it like this:

./hello_world_test.rb

## Source

Jumpstart Lab Warm-up [http://jumpstartlab.com](http://jumpstartlab.com)

## Submitting Incomplete Problems
It's possible to submit an incomplete solution so you can see how others have completed the exercise.

41 changes: 41 additions & 0 deletions allergies/allergies.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
class Allergies
def initialize(allergies_number)

@allergy_score = {
cats: 128 ,
pollen: 64 ,
chocolate: 32 ,
tomatoes: 16 ,
strawberries: 8 ,
shellfish: 4 ,
peanuts: 2 ,
eggs: 1
}
allergies_number -=256 if allergies_number > 256
calculate_allergy(allergies_number)
end

def calculate_allergy(number)
@store_allergy = []
@allergy_score.each do |key,value|
if value.to_i <= number
number -= value.to_i
@store_allergy << key.to_s
end
end
end

def allergic_to?(allergies_string)
@store_allergy.include?(allergies_string)
end

def list
@store_allergy.reverse
end
end
# all = Allergies.new(8)
# all.allergic_to?("strawberries")
# all = Allergies.new(5)
# all.allergic_to?("strawberries")
# all = Allergies.new(509)

72 changes: 72 additions & 0 deletions allergies/allergies_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/env ruby
gem 'minitest', '>= 5.0.0'
require 'minitest/autorun'
require_relative 'allergies'

class AllergiesTest < Minitest::Test
def test_no_allergies_means_not_allergic
allergies = Allergies.new(0)
refute allergies.allergic_to?('peanuts')
refute allergies.allergic_to?('cats')
refute allergies.allergic_to?('strawberries')
end

def test_is_allergic_to_eggs
# skip
allergies = Allergies.new(1)
assert allergies.allergic_to?('eggs')
end

def test_allergic_to_eggs_in_addition_to_other_stuff
# skip
allergies = Allergies.new(5)
assert allergies.allergic_to?('eggs')
assert allergies.allergic_to?('shellfish')
refute allergies.allergic_to?('strawberries')
end

def test_no_allergies_at_all
# skip
allergies = Allergies.new(0)
assert_equal [], allergies.list
end

def test_allergic_to_just_eggs
# skip
allergies = Allergies.new(1)
assert_equal ['eggs'], allergies.list
end

def test_allergic_to_just_peanuts
# skip
allergies = Allergies.new(2)
assert_equal ['peanuts'], allergies.list
end

def test_allergic_to_eggs_and_peanuts
# skip
allergies = Allergies.new(3)
assert_equal %w(eggs peanuts), allergies.list
end

def test_allergic_to_lots_of_stuff
# skip
allergies = Allergies.new(248)
expected = %w(strawberries tomatoes chocolate pollen cats)
assert_equal expected, allergies.list
end

def test_allergic_to_everything
# skip
allergies = Allergies.new(255)
expected = %w(eggs peanuts shellfish strawberries tomatoes chocolate pollen cats)
assert_equal expected, allergies.list
end

def test_ignore_non_allergen_score_parts
# skip
allergies = Allergies.new(509)
expected = %w(eggs shellfish strawberries tomatoes chocolate pollen cats)
assert_equal expected, allergies.list
end
end
65 changes: 65 additions & 0 deletions atbash-cipher/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Atbash Cipher

Create an implementation of the atbash cipher, an ancient encryption system created in the Middle East.

The Atbash cipher is a simple substitution cipher that relies on
transposing all the letters in the alphabet such that the resulting
alphabet is backwards. The first letter is replaced with the last
letter, the second with the second-last, and so on.

An Atbash cipher for the Latin alphabet would be as follows:

```plain
Plain: abcdefghijklmnopqrstuvwxyz
Cipher: zyxwvutsrqponmlkjihgfedcba
```

It is a very weak cipher because it only has one possible key, and it is
a simple monoalphabetic substitution cipher. However, this may not have
been an issue in the cipher's time.

Ciphertext is written out in groups of fixed length, the traditional group size
being 5 letters, and punctuation is excluded. This is to make it harder to guess
things based on word boundaries.

## Examples
- Encoding `test` gives `gvhg`
- Decoding `gvhg` gives `test`
- Decoding `gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt` gives `The quick brown fox jumps over the lazy dog.`

* * * *

For installation and learning resources, refer to the
[exercism help page](http://exercism.io/languages/ruby).

For running the tests provided, you will need the Minitest gem. Open a
terminal window and run the following command to install minitest:

gem install minitest

If you would like color output, you can `require 'minitest/pride'` in
the test file, or note the alternative instruction, below, for running
the test file.

In order to run the test, you can run the test file from the exercise
directory. For example, if the test suite is called
`hello_world_test.rb`, you can run the following command:

ruby hello_world_test.rb

To include color from the command line:

ruby -r minitest/pride hello_world_test.rb

The test files may have the execution bit set so you may also be able to
run it like this:

./hello_world_test.rb

## Source

Wikipedia [http://en.wikipedia.org/wiki/Atbash](http://en.wikipedia.org/wiki/Atbash)

## Submitting Incomplete Problems
It's possible to submit an incomplete solution so you can see how others have completed the exercise.

Loading