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

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

Awesome !

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

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";

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;

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

fgdnhf

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.

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