# Node.js tries to solve the reasoning questions of the Criminal Investigation Department of Jiangsu internet police A month ago, Jiangsu network police A set of "2018 criminal investigation subject reasoning test questions" was released on Weibo, which is hard to defeat many heroes, and the comment area is full of leather voice.

However, when this incident came to the ears of ape family, the painting style suddenly changed. Heroes from Java, Python, PHP and other schools have used the school language to solve the criminal investigation and reasoning array of Jiangsu online police with the little wisdom of enumeration.

We are not willing to lag behind, so we have today's "Node.js to solve the reasoning test of Criminal Investigation Department of Jiangsu online police".

If you don't want to talk much, first picture: Surrender code to show Innocence:

question.js

``````/**
* Created by lonelydawn at 2018-03-29.
*/
var options = ['A', 'B', 'C', 'D']
// Define the question answer array, set the first element of the array to null, and align the array subscript and question number with offset
var answers = [, 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A']
var result = []
/**
* 01. The answer to this question is
* A. A    B. B    C. C    D. D
*/

/**
* 02. The answer to question 5 is
* A. C    B. D    C. A    D. B
*/
var getQues02 = function (answers) {
return 'A'
} else if (answers === 'D') {
return 'B'
} else if (answers === 'A') {
return 'C'
} else if (answers === 'B') {
return 'D'
}
return -1
}

/**
* 03. Which of the following answers is different from the other three
* A. 3. B. 6. C. 2. D. 4
*/
var getQues03 = function (answers) {
return 'A'
return 'B'
return 'C'
return 'D'
}
return -1
}

/**
* 04. Which two of the following questions have the same answer
* A. 1,5 B. 2,7 C. 1,9 D. 6,10
*/
var getQues04 = function (answers) {
return 'A'
return 'B'
return 'C'
return 'D'
}
return -1
}

/**
* 05. Which of the following is the same as this question
* A. 8. B. 4. C. 9. D. 7
*/
var getQues05 = function (answers) {
return 'A'
} else if (answers === 'B') {
return 'B'
} else if (answers === 'C') {
return 'C'
} else if (answers === 'D') {
return 'D'
}
return -1
}

/**
* 06. Which two of the following questions have the same answer as question 8
* A. 2,4 B. 1,6 C. 3,10 D. 5,9
*/
var getQues06 = function (answers) {
return 'A'
return 'B'
return 'C'
return 'D'
}
return -1
}
/**
* 07. In the ten questions, the letter of the choice with the least number of times selected is
* A. C    B. B    C. A     D. D
*/
var getQues07 = function (answers) {
var counter = [0, 0, 0, 0]
options.forEach(function (option, index) {
counter[index]++
}
})
})
return options[counter.indexOf(Math.min(counter, counter, counter, counter))]
}
/**
* 08. Which of the following is not adjacent to the first in letters
* A. Question 7 B. 5 C. 2 D. 10
* Solution: A, B, C and D are four letters. First, list which letters are not adjacent to each other, and then judge
* PS: There may be multiple solutions to this question, but only the first one is taken because the question is clearly marked with "single choice"
*/
var getQues08 = function (answers) {
var notNeighbor = {
A: ['C', 'D'],
B: ['D'],
C: ['A'],
D: ['A', 'B']
return 'A'
} else if (notNeighbor.indexOf(answers) > -1) {
return 'B'
} else if (notNeighbor.indexOf(answers) > -1) {
return 'C'
} else if (notNeighbor.indexOf(answers) > -1) {
return 'D'
}
return -1
}
/**
* 09. It is known that "the answers of the first and sixth questions are the same" and "the answers of the X and 5 questions are the same" are true and false
* A. 6. B. 10. C. 2. D. 9
* Solution:
* The answer to question X may be the same as or different from question 5,
* So we judge it in two ways
* PS:
* If the answers of the first and sixth questions are the same, then x and 5 answers are not the same, and X's answers may have multiple values (A/B/C/D)
* If it is different, then x is the same as 5, and the answer of X can only take a unique value
* But even if the answer value of X is unique, X may have multiple values (1-10)
* I intersect the candidate array of these values with the four options of the topic, so as to limit the unique X value
*/
var getQues09 = function (answers) {
var arr = []
var x = -1
for (var i = 0; i < answers.length; i++) {
var answer = ['A', 'B', 'C', 'D'][[6, 10, 2, 9].indexOf(i)]
}
}
}
} else {
for (var i = 0; i < answers.length; i++) {
var answer = ['A', 'B', 'C', 'D'][[6, 10, 2, 9].indexOf(i)]
}
}
}
}
}
/**
* 10. In the 10 questions, the difference between the most and the least of the four letters of ABCD is
* A. 3    B. 2    C. 4     D. 1
*/
var getQues10 = function (answers) {
var counter = [0, 0, 0, 0]
options.forEach(function (option, index) {
counter[index]++
}
})
})
var max = Math.max(counter, counter, counter, counter)
var min = Math.min(counter, counter, counter, counter)
return {
1: 'D',
2: 'B',
3: 'A',
4: 'C'
}[max - min]
}

// Recursion + loop to establish enumeration queue
var recurse = function (answers, index) {
if (index < 10) {
for (var i = 0; i < options.length; i++) {
continue
}
continue
}
continue
}
continue
}
continue
}
continue
}
continue
}
continue
}
continue
}
}
}
}

var begin = new Date().getTime()