Posted By

apoz on 06/23/11


Tagged

contest tuenti tlang


Versions (?)

Tuenti contest test #2 TLang


 / Published in: Perl
 

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

  1. while(<>)
  2. {
  3. s/\^/\(/g; #subs ^ x (
  4. s/\$/\)/g; #subs $ x )
  5. my $changed=0;
  6.  
  7. while($changed==0)
  8. {
  9. if(s/\([=] (-?\d+) (-?\d+)\)/$1 + $2/eg) # (= 1 1)
  10. {
  11. }elsif (s/\([#] (-?\d+) (-?\d+)\)/$1 * $2/eg)
  12. {
  13. }elsif (s/\([@] (-?\d+) (-?\d+)\)/$1 - $2/eg)
  14. {
  15. }elsif (s/\([@] (-?\d+)\)/-$1/eg)
  16. {
  17. }else { $changed=1;}
  18. }
  19. print $_ . " \n";
  20. }

Report this snippet  

You need to login to post a comment.