Question: Swift: import Foundation /* * Complete the 'isPossible' function below. * * The function is expected to return a STRING. * The function accepts following

Swift:

Swift: import Foundation /* * Complete the 'isPossible' function below. * *

import Foundation

/*

* Complete the 'isPossible' function below.

*

* The function is expected to return a STRING.

* The function accepts following parameters:

* 1. INTEGER a

* 2. INTEGER b

* 3. INTEGER c

* 4. INTEGER d

*/

func isPossible(a: Int, b: Int, c: Int, d: Int) -> String {

// Write your code here

}

let stdout = ProcessInfo.processInfo.environment["OUTPUT_PATH"]!

FileManager.default.createFile(atPath: stdout, contents: nil, attributes: nil)

let fileHandle = FileHandle(forWritingAtPath: stdout)!

guard let a = Int((readLine()?.trimmingCharacters(in: .whitespacesAndNewlines))!)

else { fatalError("Bad input") }

guard let b = Int((readLine()?.trimmingCharacters(in: .whitespacesAndNewlines))!)

else { fatalError("Bad input") }

guard let c = Int((readLine()?.trimmingCharacters(in: .whitespacesAndNewlines))!)

else { fatalError("Bad input") }

guard let d = Int((readLine()?.trimmingCharacters(in: .whitespacesAndNewlines))!)

else { fatalError("Bad input") }

let result = isPossible(a: a, b: b, c: c, d: d)

fileHandle.write(result.data(using: .utf8)!)

fileHandle.write(" ".data(using: .utf8)!)

Consider a pair of integers, (a, b). The following operations can be performed on (a, b) in any order, zero or more times: (a, b) = (a + b, b) (a, b) (a, a + b) Return a string that denotes whether or not (a, b) can be converted to to (c, d) by by performing zero or more of the operations specified above

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!