Sunday, 30 August 2015

Simple Password Encryption Program Using Brainfuck Programming Language.

/*Simple Password Encryption Program.*/


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.
+++++++++++++++++++++++++++++++++++++++++.
++++++.
---------------.
+++++++++++++.
----------------------------------------------------------------------------------.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.
----------.
++++++.
---.
----------------------------------------------------------------------------------.
++++++++++++++++++++.
++++++++++++++++++++++++++++++++++++++++++++++++.
+++++.
--.
+++++++++++++.
------------------------------------------------------------------------------------.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.
---------------.
++++++++++++++++++..
++++.
--------.
+++.
--------------.
------------------------------------------.
,>,>,>,

>
++++++++++.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.
++++++++++++++++++++++.
++++++.
---.
----------------------------------------------------------------------------------.
+++++++++++++++++++++++++++++++++++++.
+++++++++++++++++++++++++++++++++++++++++.
-----------.
+++++++++++++++.
+++++++.
---------.
++++.
---------------.
-.
--------------------------------------------------------------------.
++++++++++++++++++++++++++++++++++++++++++++++++.
+++++++++++++++++.
++++++++++++++++++..
++++.
--------.
+++.
--------------.
--------------------------------------------------------------------.
+++++++++++++++++++++++++++++++++++++++++.
++++++++++++++++++++++++++++++++++++++++++.
---------------------------------------------------------.
<

<<<
+++++++++++++++++++++++++++++++++++++++++++++++++++++
>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
--------------
>
--------------------

<<<
.>.>.>.

>>
++++++++++.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.
++++++++++++++++++++++.
++++++.
---.
----------------------------------------------------------------------------------.

++++++++++++++++++++++++++++++++++++++++++++++++.
+++++++++++++++++.
++++++++++++++++++..
++++.
--------.
+++.
--------------.
--------------------------------------------------------------------.
+++++++++++++++++++++++++++++++++++++++++.
++++++++++++++++++++++++++++++++++++++++++.
---------------------------------------------------------.
<<

<<<
-----------------------------------------------------
>
------------------------------------------------------------
>
++++++++++++++
>
++++++++++++++++++++
<<<
.>.>.>.



Input:  ABCD

Output:

Enter your 4digt password:
     Your Encrypted Password Is:v~50
     Your Password Is:ABCD

Wednesday, 26 August 2015

Given a number, convert it into a Hexa-Decimal number Code Fight Problem Solution Using C++.

/*

Given a number, convert it into a Hexa-Decimal number.
Example: For h=12 the output should be C. For h=29 the output should be 1D.


Input 1 (h) → integer :

A positive number, h <= 10^6.
Output → string :

The converted number. Keep in mind that the letters should be in UpperCase.
*/

Solution:

#include <iostream>
using namespace std;
/*
    *
    * Prosen Ghosh
    * American International University - Bangladesh (AIUB)
    *
*/
string hexa(int h) {
  char Result[15];
  sprintf(Result,"%X",h);
  return Result;
}
int main() {

  int h;
  cin >> h;
  cout << hexa(h) << endl;
  return 0;
}

Code Fight HackIt Problem Solution Using C++.

/*
                                             HackIt
Once there was a hacker called Encryptor who used to hack complex things. One time he got stuck with a simple problem: he was not able to decode a string (probably because he had been working only on complex problems before). So he needs your help.
Given some sample cases, build an algorithm that decodes the given string. To decode a string you have to reverse each letter in it. Letter a is replaced with z,b with y , ..., z with a. Remember that the output will always consist of meaningful English words.
Sample cases Case 1 --> svool is decoded as hello. Case 2--> XlwvUrtsgh is decoded as CodeFights.


Input 1 (str) → string :

A string that can contain capital letters, small letters, numbers and spaces.
Output → string :

A combination of meaningful English words.
*/

Solution:

#include <bits/stdc++.h>
using namespace std;
/*
    *
    * Prosen Ghosh
    * American International University - Bangladesh (AIUB)
    *
*/
string HackIt(string s) {

  for(int i = 0; i < s.size(); i++){
   if(s[i] >= 97 && s[i] <= 122)s[i] = 'a'-s[i]+25+'a';
    if(s[i] >= 65 && s[i] <= 90)s[i] = 'A'-s[i]+25+'A';
  }
  return s;
}
int main() {
  string str;
  cin >> str;
  cout << HackIt(str) << endl;
  return 0;
}

Sherlock and Squares Hacker Rank Problem Solution Using C++.

/*

         Sherlock and Squares


Problem Statement
Watson gives two integers (A and B) to Sherlock and asks if he can count the number of square integers between A and B (both inclusive).
Note: A square integer is an integer which is the square of any integer. For example, 149, and 16 are some of the square integers as they are squares of 123, and 4, respectively.
Input Format
The first line contains T, the number of test cases. T test cases follow, each in a new line.
Each test case contains two space-separated integers denoting A and B.
Output Format
For each test case, print the required answer in a new line.
Constraints
1T100
1AB109
Sample Input
2
3 9
17 24
Sample output
2
0
Explanation
Test Case #00: In range [3,9]4 and 9 are the two square numbers.
Test Case #01: In range [17,24], there are no square numbers.
TAG: C++,Algorithm Implementation , Simple Program , Hacker Rank , Math Problem .
Problem Link: https://www.hackerrank.com/challenges/sherlock-and-squares
*/

Solution:

#include<bits/stdc++.h>
using namespace std;
/*
    *
    * Prosen Ghosh
    * American International University - Bangladesh (AIUB)
    *
*/
int main() {
    int T,a,b;
    cin >> T;;
    while(T--){
        cin >> a >> b;
        printf("%d\n",(int)(floor(sqrt((double)b)) - ceil(sqrt((double)a))+1));
    }
    return 0;
}