Ittiam Systems Interview Question for Software Trainees


Team: dsfgfds
Country: India
Interview Type: Written Test




Comment hidden because of low score. Click to expand.
0
of 0 vote

this is python. but re should be the same. wow the re is long... any better solution?

regex = re.compile("^172\.125\.((25\.0)|((([1-9])|(1[0-9])|(2[0-4]))\.(([0-
])|([1-9][0-9])|(1[0-9][0-9])|(2[0-4][0-9])|(25[0-5]))))$")

- gnahzy August 29, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

For the question-Input ip address. Check if it is in the range 172.125.1 and 172.125.25

#!/usr/bin/perl
print "Content-type:text/html\n\n";
my $ipaddr= "172.125.24.255";
chomp($ipaddr);
my $pattern='^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$';
if($ipaddr=~m/$pattern/)
{
if (($1<172 || $2<125 || $3<1 || $4<0) || ($1>172 || $2>125 || $3>25 || $4>0))
{
print "$ipaddr is not in the range between IP Address 172.125.1.0 and 172.125.25.0";
}
else
{
print "$ipaddr is an valid IP Address";
}
}
else
{
print "$ipaddr is an Invalid IP Address";
}
I am getting the output as valid when input ip address is 172.125.25.0. But output is invalid when the input is 172.125.24.255. How to solve this? Please help

- Anonymous August 30, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Change to:

if (($1<172 || $2<125 || $3<1 || $4<0) || ($1>172 || $2>125 || $3>25 || $4>255))

Note: I change $4>0 -> $4>255.

- Henry January 17, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

$ip=$ARGV[1];

if ($ip =~ m/^(25[0-5]|2[0-4][0-9]|1[0-9][0-9]?|[0-9]?[1-9])\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/)
{
print "IP Address Match\n" ;
}

- Rohit February 08, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

if( $ip_addr =~ /^172\.125\.(\d+)\.(\d+)/ ) {
	
	if( $1 < 24 ) {
		print "\nIt's in range!";
	} else {
		if( $1 ==25 && $2 == 0) {
			print "\nIt is in range";
		} else {
			print "\nNot in range!";
		}
	}
	
} else {
	print "\nIp addr not in range.";
}

- D October 02, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

print $ip=~m/172\.125\.([1-2][0-5]|[0-9])\.0/ ? "in" : "out";

- perl monk May 06, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

fentastic, mind blowing , unbelievable!

- ajay May 06, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

#!/usr/bin/perl -w

use strict;

#Task 1: Input IP Address. Check if it lies between 172.125.1.0 and 172.125.25.0?

my $ip_add = $ARGV[0];
if($ip_add =~ m/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/ && ($1>171 && $1<173) 
&& ($2>124 && $2<126) && ($3>0 && $3<25) && ($4>=0 && $4<256) || $ip_add =~ m/172.125.25.0/)
{
	print "Valid IP Address\n";
}
else
{
	print "Non-Valid IP Address\n";

}

- lochan.brijesh March 02, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#!/usr/bin/perl -w

use strict;

#Task 1: Input IP Address. Check if it lies between 172.125.1.0 and 172.125.25.0?

my $ip_add = $ARGV[0];
if($ip_add =~ m/^172\.125\.(\d{1,3})\.(\d{1,3})$/ && ($1>0 && $1<25) && ($2>=0 && $2<256) || $ip_add =~ m/172.125.25.0/)
{
	print "Valid IP Address\n";
}
else
{
	print "Non-Valid IP Address\n";

}

- lochan.brijesh March 02, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#!/usr/bin/perl
use strict;
use warnings;

print "Enter ip address:";
my $ip = <STDIN>;
chomp $ip;

# print ip in range 172.125.1.0 - 172.125.25.0
print $ip=~ m/172\.125\.([1-9]|1[0-9]|2[1-5])\.0/ ? "IP in Range": "IP out of Range";

- Solitary_reaper June 08, 2015 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More