2 min to read

# Job interviewer - If you have only 1 question

**tldr;** If you had only one question to judge the quality of the technical candidate for your startup, what would that question be?

This is the choice of a question of Asen who I chatted to some minutes ago.

We have two numbers - 36 and 48. Write a function which receives as an input one of these numbers, and returns the other.

Important: You are not allowed to use any of these - if clauses, loops and data structures.

### Here are 3 example solutions

*Input*

Input: 36, Output: 48.

Input: 48, Output: 36.

Here is the logic and pseudo code for the threee solutions :arrow_down:

#### Use sum

- sum up the two numbers
- receive the input number
- return the sum of the two numbers minus the input number

```
two_num_sum = 36 + 48
def return_the_other_number(this_number, two_num_sum):
return two_num_sum - this_number
```

#### Use a string

- Store the two numbers in a sequence in a string.
- Remove the input number from that string
- Return the remaining string

```
def return_the_other_number(this_number):
this_str_number = str(this_number)
num_string = "3648"
return int(num_string.replace(this_str_number, ""))
```

#### Use text files

- create two text files - named
`<number>.txt`

. The content of the file would be the other number - return the calue written in the text file with the name of the input number

```
# 36.txt
48
```

```
def return_the_other_number(this_number):
filename = str(this_number) + ".txt"
with open(filename, "r") as fin:
output = fin.read()
return int(output)
```

**Photo Credit**

Unsplash/Jac Alexandru

## Comments