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

Etl #20

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open

Etl #20

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 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
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
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.

31 changes: 31 additions & 0 deletions atbash-cipher/atbash_cipher.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
class Atbash
def self.encode(plain_value)
plain_value.gsub!(/[ .,]/,'')
plain_value.downcase!
@array_char=('a'..'z').to_a
string_to_array=plain_value.split('')
n=0
cipher_text=''
while n != string_to_array.length
if string_to_array[n] =~ /[a-z]/
temp_index=@array_char.index(string_to_array[n]).to_i
cipher_text += @array_char[25 - temp_index]
else
cipher_text += string_to_array[n].to_s
end
n += 1
end
contain_string=''
temp_div=0
temp_array=cipher_text.split('')
(0...temp_array.length).each do |i|
if(temp_div % 5 == 0)
contain_string += ' '
end
contain_string += temp_array[i]
temp_div += 1
end
return contain_string.gsub!(/^[ ]+/,'')

end
end
48 changes: 48 additions & 0 deletions atbash-cipher/atbash_cipher_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env ruby
gem 'minitest', '>= 5.0.0'
require 'minitest/autorun'
require_relative 'atbash_cipher'

class AtbashTest < Minitest::Test
def test_encode_no
assert_equal 'ml', Atbash.encode('no')
end

def test_encode_yes
# skip
assert_equal 'bvh', Atbash.encode('yes')
end

def test_encode_OMG
# skip
assert_equal 'lnt', Atbash.encode('OMG')
end

def test_encode_O_M_G
# skip
assert_equal 'lnt', Atbash.encode('O M G')
end

def test_encode_long_word
# skip
assert_equal 'nrmwy oldrm tob', Atbash.encode('mindblowingly')
end

def test_encode_numbers
# skip
assert_equal('gvhgr mt123 gvhgr mt',
Atbash.encode('Testing, 1 2 3, testing.'))
end

def test_encode_sentence
# skip
assert_equal 'gifgs rhurx grlm', Atbash.encode('Truth is fiction.')
end

def test_encode_all_the_things
# skip
plaintext = 'The quick brown fox jumps over the lazy dog.'
cipher = 'gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt'
assert_equal cipher, Atbash.encode(plaintext)
end
end
66 changes: 66 additions & 0 deletions binary/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Binary

Write a program that will convert a binary number, represented as a string (e.g. '101010'), to its decimal equivalent using first principles

Implement binary to decimal conversion. Given a binary input
string, your program should produce a decimal output. The
program should handle invalid inputs.

## Note
- Implement the conversion yourself.
Do not use something else to perform the conversion for you.

## About Binary (Base-2)
Decimal is a base-10 system.

A number 23 in base 10 notation can be understood
as a linear combination of powers of 10:

- The rightmost digit gets multiplied by 10^0 = 1
- The next number gets multiplied by 10^1 = 10
- ...
- The *n*th number gets multiplied by 10^*(n-1)*.
- All these values are summed.

So: `23 => 2*10^1 + 3*10^0 => 2*10 + 3*1 = 23 base 10`

Binary is similar, but uses powers of 2 rather than powers of 10.

So: `101 => 1*2^2 + 0*2^1 + 1*2^0 => 1*4 + 0*2 + 1*1 => 4 + 1 => 5 base 10`.

* * * *

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

All of Computer Science [http://www.wolframalpha.com/input/?i=binary&a=*C.binary-_*MathWorld-](http://www.wolframalpha.com/input/?i=binary&a=*C.binary-_*MathWorld-)

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

23 changes: 23 additions & 0 deletions binary/binary.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class Binary
def self.to_decimal(binary_string)
if (binary_string =~ /^[01]+$/)
binary_string_number=binary_string.to_i
sum=0
i=0
while binary_string_number != 0
digit=binary_string_number%10
if(digit!=0)
sum+=(digit*(2**i)).to_i
end
i+=1
binary_string_number/=10
end
return sum
else
raise ArgumentError
end
end
end
module BookKeeping
VERSION=3
end
104 changes: 104 additions & 0 deletions binary/binary_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#!/usr/bin/env ruby
# encoding: utf-8
gem 'minitest', '>= 5.0.0'
require 'minitest/autorun'
require_relative 'binary'

# Test data version:
# 82eb00d
class BinaryTest < Minitest::Test
def test_binary_0_is_decimal_0
# skip
assert_equal 0, Binary.to_decimal('0')
end

def test_binary_1_is_decimal_1
#skip
assert_equal 1, Binary.to_decimal('1')
end

def test_binary_10_is_decimal_2
#skip
assert_equal 2, Binary.to_decimal('10')
end

def test_binary_11_is_decimal_3
#skip
assert_equal 3, Binary.to_decimal('11')
end

def test_binary_100_is_decimal_4
#skip
assert_equal 4, Binary.to_decimal('100')
end

def test_binary_1001_is_decimal_9
#skip
assert_equal 9, Binary.to_decimal('1001')
end

def test_binary_11010_is_decimal_26
#skip
assert_equal 26, Binary.to_decimal('11010')
end

def test_binary_10001101000_is_decimal_1128
#skip
assert_equal 1128, Binary.to_decimal('10001101000')
end

def test_binary_ignores_leading_zeros
#skip
assert_equal 31, Binary.to_decimal('000011111')
end

def test_2_is_not_a_valid_binary_digit
#skip
assert_raises(ArgumentError) { Binary.to_decimal('2') }
end

def test_a_number_containing_a_non_binary_digit_is_invalid
#skip
assert_raises(ArgumentError) { Binary.to_decimal('01201') }
end

def test_a_number_with_trailing_non_binary_characters_is_invalid
#skip
assert_raises(ArgumentError) { Binary.to_decimal('10nope') }
end

def test_a_number_with_leading_non_binary_characters_is_invalid
#skip
assert_raises(ArgumentError) { Binary.to_decimal('nope10') }
end

def test_a_number_with_internal_non_binary_characters_is_invalid
#skip
assert_raises(ArgumentError) { Binary.to_decimal('10nope10') }
end

def test_a_number_and_a_word_whitespace_spearated_is_invalid
#skip
assert_raises(ArgumentError) { Binary.to_decimal('001 nope') }
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 3, BookKeeping::VERSION
end
end
53 changes: 53 additions & 0 deletions difference-of-squares/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Difference Of Squares

Find the difference between the sum of the squares and the square of the sums of the first N natural numbers.

The square of the sum of the first ten natural numbers is,

(1 + 2 + ... + 10)**2 = 55**2 = 3025

The sum of the squares of the first ten natural numbers is,

1**2 + 2**2 + ... + 10**2 = 385

Hence the difference between the square of the sum of the first
ten natural numbers and the sum of the squares is 2640:

3025 - 385 = 2640

* * * *

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

Problem 6 at Project Euler [http://projecteuler.net/problem=6](http://projecteuler.net/problem=6)

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

Loading