Posts

Showing posts from March, 2016

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

3
abcd bcda
a1b2c3 abc123
YES
NO
YES

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

Input:
Input co…

Basic Ruby Programs for Interview?

Basic Ruby Programs for Interview?

# require 'prime'
# # p Prime.first(10)
# Prime.each(100) do |prime|
#   p prime  #=> 2, 3, 5, 7, 11, ...., 97
# end

#Prime number programe
def prime_numbers max
for i in (2..10) do
for j in (2..i) do
break if i%j == 0
end
p "#{i} is a prime number." if i == j
end
end

#Factorial Programe
n = gets
n = n.to_i
def fact(n)
if n == 0
1
else
n * fact(n-1)
end
end
p fact(n)

#Reverse Number Programe
x = 12345
y = 0
while x > 0 do
y = y*10
y = y + (x%10)
x = x/10

puts y
end

puts "What character do you want to make the pyramid out of?"
character = gets.chomp

puts "How many rows of #{character}'s do you want?"
row_count = gets.chomp.to_i

character_count = 1
width = 100

row_count.times do
puts (character * character_count).center(width)
character_count += 2
end

star_string = "*"
10.times do
puts star_string
star_string = star_string + "*&qu…