Languages

Chef Kawasaki is trying out some new formulas. What is he making?

The Input and Output options for each section are meant to implement the corresponding code segment and are merely for the convenience of the solver. Any differences between the code shown and the behavior of the Input and Output options are not relevant to the puzzle.

Essentials (4-5 4)
public int Upper(int i, int c, int p, int m) {
  int result = 0;
  int[,] array = new int[2,2];
  array[0, 0] = i;
  array[0, 1] = c;
  array[1, 0] = p;
  array[1, 1] = m;
  result += array[0, 0] * array[1, 1] + array[1, 0] * array[0, 1];
  result *= array.Rank;
  if (result % 2 == 1) {
    result += 1;
  } else {
    result -= 1;
  }
  return result;
}

Upper Inputs: i = c = p = m =

Upper Output:

public int Lower(int i, int c, int p, int m) {
  int result = 0;
  var numbers = new List();
  numbers.Add(i);
  numbers.Add(c);
  numbers.Add(p);
  numbers.Add(m - 1);
  foreach (int num in numbers)  {
    result = result * num + num;
  }
  return result - 1;
}

Lower Inputs: i = c = p = m =

Lower Output:


Practical Programming (8-5 6 8)
int Upper(int i, int c, int p, int m) {
  int result = 0;
  std::map<int, int> map;
  map[i] = (c + p + m);
  map[c] = (i + p + m);
  map[p] = (i + c + m);
  map[m] = (i + c + p);
  for (const auto& [key, value] : map) {
    result += key * value;
  }
  result += 4;
  return result;
}

Upper Inputs: i = c = p = m =

Upper Output:

int Lower(int i, int c, int p, int m) {
  int result = 0;
  std::vector<int> commands = {i, c, p, m};
  for (int command : commands) {
    if (command == 0) {
      result = result * result;
    } else if (command == 1 || command == 3) {
      result = result + 6;
    } else if (command == 2) {
      result = result / 2;
    } else if (command == 4) {
      result = result + 6;
    } else {
      result = result - 5;
    }
  }
  return result;
}

Lower Inputs: i = c = p = m =

Lower Output:


Inside Out (8 5)
(defn Upper [i c p m]
  (* (inc (+ (identity i) c p)) (inc (+ c (identity m)))))

Upper Inputs: i = c = p = m =

Upper Output:

(defn Lower [i c p m]
  (def num1 (reduce + ((juxt max min) i c p m)))
  (def num2 (+ i c p m m))
  (* num1 num2))

Lower Inputs: i = c = p = m =

Lower Output:


Introducing (5'1 6 6)
func Upper(i int, c int, p int, m int) int {
  tensDigit := strconv.Itoa(i + c)
  onesDigit := strconv.Itoa(p + m)
  result, _ := strconv.Atoi(tensDigit + onesDigit)
  return result
}

Upper Inputs: i = c = p = m =

Upper Output:

func Lower(i int, c int, p int, m int) int {
  tensDigit := strconv.Itoa(i + m)
  onesDigit := strconv.Itoa(i + c + p)
  result, _ := strconv.Atoi(tensDigit + onesDigit)
  return result
}

Lower Inputs: i = c = p = m =

Lower Output:


Data Objects (5)
public int Upper(int i, int c, int p, int m) {
  HashMap<Integer, Integer> map = new HashMap<>();
  map.put(i, c);
  map.put(c, p);
  map.put(p, m);
  map.put(m, i);
  int result = 0;
  for (int key : map.keySet()) {
    result += (key / map.get(key)) + (key % map.get(key));
  }
  return result + 2;
}

Upper Inputs: i = c = p = m =

Upper Output:

public int Lower(int i, int c, int p, int m) {
  int result = 0;
  ArrayList<Integer> list = new ArrayList<>();
  list.add(i);
  list.add(c);
  list.add(p);
  list.add(m);
  list.add(list.get(0) + list.get(1));
  list.add(list.get(2) + list.get(3));
  list.add(list.get(4) + list.get(5));
  for (int number : list) {
    result += number;
  }
  return result + 14;
}

Lower Inputs: i = c = p = m =

Lower Output:


Supercharged Graphics (5 5)
function Upper(i, c, p, m) {
  var result = 0;
  result += 1 + 2 * p;
  result *= m;
    result += 1 + i + c;
  return result;
}

Upper Inputs: i = c = p = m =

Upper Output:

function Lower(i, c, p, m) {
  var result = 0;
  result += i**i - c**c;
  result += p * m;
    result -= p / m;
  return result;
}

Lower Inputs: i = c = p = m =

Lower Output:


Pocket Reference (6 3)
- (int) Upper: (int) i : (int) c : (int) p : (int) m {
  int product = i * c * p;
  NSNumber *result = [NSNumber numberWithInt:product];
  return [result intValue] + m / 2;
}

Upper Inputs: i = c = p = m =

Upper Output:

- (int) Lower: (int) i : (int) c : (int) p : (int) m {
  NSNumber *num1 =  [NSNumber numberWithInt:(p + m / 2)];
  NSNumber *num2 =  [NSNumber numberWithInt:(i + c)];
  int result = 2 * [num1 intValue] * [num2 intValue] - 2;
  return result;
}

Lower Inputs: i = c = p = m =

Lower Output:


In a Nutshell (7 5)
sub Upper {
  $i = $_[0];
  $c = $_[1];
  $p = $_[2];
  $m = $_[3];
  return $i * $c + 3 * $p + 2 * $m;
}

Upper Inputs: i = c = p = m =

Upper Output:

sub Lower {
  $i = $_[0];
  $c = $_[1];
  $p = $_[2];
  $m = $_[3];
  return $i ** $m + $c ** $p + $i + 3 * $c + $m;
}

Lower Inputs: i = c = p = m =

Lower Output:


Standard Library (7 5)
def Upper (i, c, p, m):
  result = 0
  nums = divmod(17 + c * p, 2)
  result += nums[0]
  result *= (i * nums[1])
  result += m
  return result

Upper Inputs: i = c = p = m =

Upper Output:

def Lower (i, c, p, m):
  result = 0
  num1 = complex(i, 5 * c)
  num2 = complex(10 * p, 15 * m)
  result += int((num1 * num2).imag)
  if result % 2 == 1:
    result += 1
  return result

Lower Inputs: i = c = p = m =

Lower Output:


Parallel (6)
Upper <- function(i, c, p, m) {
  list1 <- seq(c, p, 1)
  list2 <- rep(i + 1, 2*m)
  result <- sum(list1) + sum(list2)
  return (result - 1)
}

Upper Inputs: i = c = p = m =

Upper Output:

Lower <- function(i, c, p, m) {
  result <- 100 * i + 10 * m + p
  result <- (result %/% m) + qbinom(1, c, 0.25) - 1
  return (result)
}

Lower Inputs: i = c = p = m =

Lower Output:


My Troubleshooting (7 6)
CREATE FUNCTION Upper(
  @i INT,
  @c INT,
  @p INT,
  @m INT
)
RETURNS INT
AS
BEGIN
  DECLARE @result INT;
  SET @result = 2*@i + 3*@c + 4*@p;
  SET @result = @result * @m;
  RETURN @result;
END;

Upper Inputs: i = c = p = m =

Upper Output:

CREATE FUNCTION Lower(
  @i INT,
  @c INT,
  @p INT,
  @m INT
)
RETURNS INT
AS
BEGIN
  DECLARE @result INT;
  SET @result = ABS(POW(@c, @i) - POW(@i, @c)) * (@p + @m) * 4 + 2 * @c;
  IF (@result >= 50)
    SET @result = @result - 8;
  RETURN @result;
END;

Lower Inputs: i = c = p = m =

Lower Output:


Learning Script (5 4)
Function Upper(i, c, p, m)
  Upper = i * p + c ^ m - Sgn(i)
End Function

Upper Inputs: i = c = p = m =

Upper Output:

Function Lower(i, c, p, m)
  Lower = (10 * (i + c) + 2 * Sqr(p)) * ((m + 1) \ 2)
End Function

Lower Inputs: i = c = p = m =

Lower Output: