Introduction to Logic Tests Series


coding-skills Introduction to Logic Tests Series interview questions logic tests programming languages

coding-skills

Many companies have IQ tests or logics tests as one of the interviewing methods. These questions are not intended to test interviewee candidates for the specific programming knowledge, rather, they are to testing the if the candidates are ‘intelligent enough’. For programming jobs, the candidates are often required to solve problems (puzzles) in analytic manners.

It is a bias to pick any programming languages simply for this purpose. Solving puzzles do not require specific knowledge of any programming languages. And how are we going to test the candidates?

Luckily, here is a programming language that consists of four instructions. The variables hold non-negative integers. You don’t need to explicitly define variables but you have to zero or assign the values before using them, similar as Python.

ZERO

Use ZERO instruction to clear a variable i.e. X=0

ZERO(X)

Assign a variable

You can’t assign arbitrary values (constants) to a variable, however, you can use ASGN(X, Y) to assign value of Y variable to X, which is equal to X=Y

INCR

X++ is implemented via INCR(X)

LOOP

Use LOOP(X) {} to start a Loop of X times. Inside the loop, you can change the X value however the loop still goes X times.

for (; x > 0; -- x) {

}

I am going to start a series of using this tiny programming language, and you will see even with four instructions, this language can be very powerful.

First example is to define a ADD procedure that takes two parameters X and Y and it will perform X += Y

ADD(X, Y) {
    LOOP(Y) {   // Loop Y times
       INCR(X)    // Increment X
   }
}

Do you get this?

You may also like: 逻辑测试系列 – 一种只有4种语句的编程语言 – (1)

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
417 words
Last Post: Go to an Interview even if you are not changing your job.
Next Post: The experience of using Teamviewer on iPhone SE, connecting to desktop, and SSH to VPS, in order to make a Robot Python script up running.

The Permanent URL is: Introduction to Logic Tests Series

Leave a Reply