Tuenti contest test #2 TLang


/ Published in: Perl
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.