Skip to main content

Iquanti Apptitude Test for ror

Iquanti Apptitude Test for ror ?

Anagrams
Max. Marks 100
Given two strings A and B, check if they are anagrams.

Two strings are said to be anagrams, if one string can be obtained by rearranging the letters of another.

Examples of anagrams are dog, god; abac, baac; 123, 312

abab, aaba; dab, baad are not anagrams.

INPUT :

First line of the input is the number of test cases T.
It is followed by T lines, each line has two space separated strings A and B;

OUTPUT For each test case, print "YES" if they are anagrams, otherwise print "NO". (without quotes)

Constraints
1 <= T <= 10
A and B both contain only lower case latin letters 'a' to 'z' and digits 0 to 9.
Length of each string A and B does not exceed 5*10^5 (500000),

Sample Input(Plaintext Link)
 3
abcd bcda
bad daa
a1b2c3 abc123
Sample Output(Plaintext Link)
 YES
NO
YES

====================
4.
Prime or Not
Max. Marks 100
Given the number N check whether it is prime number or not.

Input:
Input contains a single integer N.

Output:
Print Prime if N is prime number else print Not Prime.

Note:
A prime number (or a prime) is a natural number greater than 1 that has no positive divisors other than 1 and itself.

Constraints:
1<=N<=100

Sample Input(Plaintext Link)
 17
Sample Output(Plaintext Link)
 Prime


 =================
 1.
Crazy Series
Max. Marks 100
Abhimanyu has one magical series:

1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, ..........
Abhimanyu got one magical function F(N) for some magical integer N, such that F(N) represents the Nth term of the magical series.

For two more magical integers L and R, Abhimanyu wants to find the integer S:

S = F(L) + F(L + 1) + ... + F(R - 1) + F(R)
Abhimanyu wants to find S % M, for M = 1000000007 (109 + 7).

Input

First line of input is an integer T, total number of test cases, followed by T lines. Each line consists of two space separated integers L and R.

Output

Output S % M in single line for each test case.

Constraints

1 <= T <= 1000000 (106)
1 <= L, R <= 50000000000 (5 x 1010)
L <= R
Note: Large input data. Use fast I/O.

Sample Input(Plaintext Link)
 5
1 3
5 10
9 18
7 17
10 10
Sample Output(Plaintext Link)
 5
22
51
53
4
Explanation
For L = 1, R = 3: F(1) = 1 F(2) = 2 F(3) = 2

So S = F(1) + F(2) + F(3) = 1 + 2 + 2 = 5



=============
2.
What is the maximum distance that you can cover?
Max. Marks 100
You have to go on a trip in your car which can hold a limited amount of fuel. You know how many liters of fuel your car uses per hour for certain speeds and you have to find out how far a certain amount of fuel will take you when travelling at the optimal speed.

You will be given a set of speeds, a corresponding set of fuel consumption and an amount that tells you the amount of fuel in your tank.

The input will be

The first line contains an integer N, that signifies the number of speeds for the car
The second line contains N number of speeds
The third line contains N number of consumption, such that if the car moves at ith speed (in km/hr) it consumes ith fuel (in ml)
The 4th line contains the fuel available in your car
You have to tell what is the maximum distance that the car can travel (in kilometers) with the given amount of fuel, and travelling at a constant speed equal to one of the elements of speeds.

Note:

You have to return a double value, with upto 3 digits after the decimal

Sample Input(Plaintext Link)
 6
250 240 230 220 210 211
5000 4500 4000 3500 3000 3000
50000
Sample Output(Plaintext Link)
 3516.666

Comments

Popular posts from this blog

Gem::LoadError (Specified 'mysql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).?

Gem::LoadError (Specified 'mysql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).) In rails?


1)change the gemfile in mysql version
 gem 'mysql2'

2)Change to mysql2 version
 gem 'mysql2','0.3.20'

Get user accessing ip address in rails?

Get user accessing ip address rails?

request.ip ->returns the ip, whether is is a local proxy ip (localhost address) or not.
*request.remote_ip -> is smarter and gets the ip address of the client outside of local proxies.
3)If you are using apache in front of a mongrel, then remote_ip will return the source address of the request, which in this case will be local host because the Apache web server is making the request, so instead put this in your controller:

@remote_ip = request.env["HTTP_X_FORWARDED_FOR"]

PayUMoney Integration in Ruby on Rails

PayUMoney Integration in Ruby on Rails


Generating Cheksum in Payu
   Hash or Checksum
= sha512(key|txnid|amount|productinfo|firstname|email|u
df1|udf2|udf3|udf4|udf5||||||salt)



Controller Code Will be
def payumoney
  @key = "gtKFFx"
  @salt =  "eCwWELxi"
  val = "#{key|txnid|amount|productinfo|firstname|email|u
df1|udf2|udf3|udf4|udf5||||||#{@salt}"
 @checksum = Digest::SHA512.hexdigest("#{val}")
end

<form action="https://test.payu.in/_payment" method='post' id='sub'  >
    <input type="hidden" name="key" value="<%=@key%>">
    <input type="hidden" name="hash" value="<%=@checksum%>">
    <input type="hidden" name="txnid" value="TXN1234">
    <input type="hidden" name="amount" value="200">
    <input type="hidden" name="firstname" value=&quo…