Skip to content

Best HW programmer.

User Avatar
#6
Auto-translated
Good day.

The idea was certainly not bad (since it's no longer summer :)).
So, I present to you a solution in Perl (since I'm currently learning it).
# Task #1 (as easy as it gets)
# Determine the level 7 unit of a given faction.
use strict;
use warnings;
my %un = (
	'1', 'Archangel',
	'2', 'Golden Dragon',
	'3', 'Titan',
	'4', 'Ghost Dragon',
	'5', 'Black Dragon',
	'6', 'Archdevil',
	'7', 'Hydra',
	'8', 'Ancient Horror',
	'9', 'Phoenix'
	);
my %cas = (
	'1', 'Castle', 
	'2', 'Rampart', 
	'3', 'Tower', 
	'4', 'Necropolis', 
	'5', 'Dungeon', 
	'6', 'Inferno', 
	'7', 'Fortress', 
	'8', 'Stronghold', 
	'9', 'Conflux', 
	);
print "Enter the faction: ";
my $n = 1;
while ($n <= keys(%un))
{
	print $cas{$n}, ". ";
	$n++;
}
print "\n";
my $un = ;
chomp $un;
$n = 1;
while ($n <= keys(%cas))
{
	if ($un eq $cas{$n})
	{
		print "For the faction: ", $cas{$n}, ", the level 7 unit is: ", $un{$n};
	}
	$n++;
}
I'll post more when I have some free time from work.

P.S. Just out of sporting interest, I'd like to see how this task is solved in Assembler.

Sincerely, K0Lb@zzeR.
:smile13: [ТУРНИР] "Гонка за Лидером" :smile13:
:smile28: [M] "Я и моя тень" - "I am and my shadow" :smile28:
:smile16: "Быстрая смерть" - "Fast Death" :smile16: