Return to Snippet

Revision: 48069
at June 23, 2011 04:38 by apoz


Updated Code
while(<>)
{
	chomp;
	s/\^/\(/g;   #subs ^ x (
	s/\$/\)/g;   #subs $ x )
	my $changed=0;
	
	while($changed==0)
	{
		if(s/\([=] (-?\d+) (-?\d+)\)/$1 + $2/eg) # (=  1  1)
		{
		}elsif (s/\([#] (-?\d+) (-?\d+)\)/$1 * $2/eg)
		{
		}elsif (s/\([@] (-?\d+) (-?\d+)\)/$1 - $2/eg)
		{
		}elsif (s/\([@] (-?\d+)\)/-$1/eg)
		{
		}else {	$changed=1;}
	}
	print $_ . "    \n";
}

Revision: 48068
at June 23, 2011 03:11 by apoz


Initial Code
while(<>)
{
	chomp;
	s/\^/\(/g;   #subs ^ x (
	s/\$/\)/g;   #subs $ x )
	my $changed=0;
	
	while($changed==0)
	{
		if(s/\([=] (-?\d+) (-?\d+)\)/$1 + $2/eg) # (=  1  1)
		{
		}elsif (s/\([#] (-?\d+) (-?\d+)\)/$1 * $2/eg)
		{
		}elsif (s/\([@] (-?\d+) (-?\d+)\)/$1 - $2/eg)
		{
		}elsif (s/\([@] (-?\d+)\)/-$1/eg)
		{
		}else {	$changed=1;}
	}
	print $_ . "\n";
}

Initial URL

                                

Initial Description
Dunno why, but it does not validates. And the result seems right.

Initial Title
Tuenti contest test #2  TLang

Initial Tags

                                

Initial Language
Perl