Please answer this question in 10 mins i will surely rate your answer.   Given an integer string, create all integer permutations of its digits. Determine if there is a permutation whose integer value is evenly divisible by 8, L.e. (permutation value) mod 8 = 0. For example, the possible permutations of 123 are p= (123, 132, 213, 231, 312, 321). Of these values, p[4]-312 is divisible by 8 because 312 mod 8=0. Function Description Complete the function checkDivisibility in the editor below. The function must return an array of result strings, either YES or NO, where each result[i] denotes whether a permutation of arr[i] is divisible by 8. checkDivisibility has the following parameter(s): arr[arr[0]...arr[n-1]): an array of integer strings Constraints • 1≤ns45 Osarris 10110 All characters of arr[i] € (0-9) Input Format for Custom Testing Input from stdin will be processed as follows and passed to the function. The first line contains an integer n, the size of the array arr. Each of the next n lines contains an integer as a string, arr[i], where 0 ≤i≤n. Sample Case 0 Sample Input 0 STDIN Function Parameters 2 → arr[] Size = 2 61 75 arr[]=[ 61, 75] Sample Output 0 YES NO Explanation 0 Check the following n = 2 values: • arr[0]=61. The permutation p = 16 is divisible by 8 so store YES in index 0 of the return array arr[1]= 75. The only permutations are p = 75 and p=57, but neither of them is divisible by & Store NO in index 1 of the return array.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Please answer this question in 10 mins i will surely rate your answer.

 

Given an integer string, create all integer permutations of its digits. Determine if there is a permutation

whose integer value is evenly divisible by 8, L.e. (permutation value) mod 8 = 0.

For example, the possible permutations of 123 are p= (123, 132, 213, 231, 312, 321). Of these values, p[4]-312 is divisible by 8 because 312 mod 8=0.

Function Description

Complete the function checkDivisibility in the editor below. The function must return an array of result strings, either YES or NO, where each result[i] denotes whether a permutation of arr[i] is divisible by 8.

checkDivisibility has the following parameter(s): arr[arr[0]...arr[n-1]): an array of integer strings

Constraints

• 1≤ns45

Osarris 10110

All characters of arr[i] € (0-9)

Input Format for Custom Testing

Input from stdin will be processed as follows and passed to the function.

The first line contains an integer n, the size of the array arr. Each of the next n lines contains an integer as a string, arr[i], where 0 ≤i≤n.

Sample Case 0

Sample Input 0

STDIN

Function Parameters

2

→ arr[] Size = 2

61

75

arr[]=[ 61, 75]

Sample Output 0

YES

NO

Explanation 0

Check the following n = 2 values:

• arr[0]=61. The permutation p = 16 is divisible by 8 so store YES in index 0 of the return array arr[1]= 75. The only permutations are p = 75 and p=57, but neither of them is divisible by & Store NO in index 1 of the return array.

Expert Solution
steps

Step by step

Solved in 4 steps with 6 images

Blurred answer
Knowledge Booster
Topological Sort
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education