Tuenti Challenge 2001 #2

We use a variety of languages and technologies here at Tuenti. Sometimes we even develop our own languages and tools. Here is an example from a programming language that we use when we want to blow our minds. Your task is to interpret it!

by Luis Martin

JavaScript

let input = `^= 1 2$
^# 2 2$
^@ 3 1$`;

const regex = /\^(.) (\d+) (\d+)\$/

const operTuenti = ["=", "#", "@"]
const operReal = ["+", "*", "-"]

let lines = input.split("\n")

lines.forEach((line) => {

	let arr = line.match( regex )
  let op = arr[1]
  let n1 = arr[2]
  let n2 = arr[3]
  
  let  result = eval(n1 + operReal[operTuenti.indexOf(op)] + n2)
  
  console.log(result)

});