Ittiam Systems Interview Question for Software Trainees


Team: dsfgfds
Country: India
Interview Type: Written Test




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

It's easier than that:

# use original posters map function.
# use original posters $no definition.

my $newstr;
($newstr=$no) =~ s/(\d)/$map{$1}/g;
print "$newstr\n";

Of course there are variations such as inserting spaces, etc, but the above doesn't require loops but could be a simple function that is called from a loop that, say, parses @ARGV or a file.

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

Awesome !

- D September 10, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

#convert no to word
use Data::Dumper;


# Solution one without using regex
$no =1568999;

%map =( 1 => "one",
2 => "two",
3 => "three",
4 => "four",
5 => "five",
6 => "six",
7 => "seven",
8 => "eight",
9 => "nine",
0 => "zero",
);

@digits = split(//,$no);

foreach(@digits){
$result .= $map{$_}." ";
}
print("The result without using regex is : $result");

# Solution two using regex
while($no =~ /([0-9])/g)
{
$result1 .= $map{$1}." ";
}
print("The result using regex is :".$result1);

- saha November 16, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

use strict;
use warnings;

my $words = {
	"1" => "ONE",
	"2" => "TWO",
	"3" => "THREE",
	"4" => "FOUR",
	"5" => "FIVE",
	"6" => "SIX",
	"7" => "SEVEN",
	"8" => "EIGHT",
	"9" => "NINE",
	"0" => "ZERO",
};

my $num = "4567894";
my @num = split("",$num);
@num = map {$words->{$_}} @num;
print "@num";

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

@map{0..9}=qw(zero one two three four five six seven eight nine);
$no=~s/(\d)/"$map{$1} "/ge;

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

fgdnhf

- Anonymous October 05, 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