Skip to main content

Iquanti Apptitude Test for ror

Iquanti Apptitude Test for ror ?

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.


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)

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)
abcd bcda
bad daa
a1b2c3 abc123
Sample Output(Plaintext Link)

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

Input contains a single integer N.

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

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


Sample Input(Plaintext Link)
Sample Output(Plaintext Link)

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).


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 S % M in single line for each test case.


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)
1 3
5 10
9 18
7 17
10 10
Sample Output(Plaintext Link)
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

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.


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

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


Popular posts from this blog

Get the Current url in ruby on rails

request.refererrequest.fullpathrequest.fullpath.split("?")[0]request.referer or request.env['HTTP_REFERER'] your controller to get the referer url. 

<link rel="canonical" href="<%= request.url %>" />
How can I get the current absolute URL in my Ruby on Rails view?
The request.request_uri only returns the relative URL.

 For Rails 3.2 or Rails 4 you should use request.original_url to get the current URL. More detail.

For Rails 3: You want "#{request.protocol}#{request.host_with_port}#{request.fullpath}", since request.url is now deprecated.

For Rails 2: You want request.url instead of request.request_uri. This combines the protocol (usually http://) with the host, and request_uri to give you the full address

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'

Active Scaffold : Add radio buttons to your form ruby on rails ?

Active Scaffold : Add radio buttons to your form ruby on rails ?

The way to add radio buttons to your active scaffold create/update from is as shown below


class UsersController < ApplicationController
active_scaffold :user do |config|
config.label = “Users”
config.columns = [:name, :gender]
config.columns[:gender].form_ui = :radio
config.columns[:gender].options[:options] = [['Male', '1'], ['Female','2']]