Graderpractice for programmers

273387 Swift - Mini Test 1

Awaiting submission
Write a program that converts an amount in Thai baht to British pounds. The exchange rate is 1 baht = 0.023 pounds. You program should read in an Int, convert it from baht to pounds and then output the result. The output should be formatted as: X baht = Y pounds
Awaiting submission
An isosceles triangle has exactly 2 sides with the same length. Read in 3 integer inputs that represent the 3 sides of a triangle. Output yes if the triangle is isosceles or no if it is not.
Awaiting submission
You are writing a program that helps a user to search for names of cities. If the user inputs ba then the program will output the cities starting with "ba". If the user inputs * then the program will output ALL cities.

Use the following code to define your list of cities.
let cities = ["Prague","Shanghai","Vienna","Osaka","Rome","Taipei","Milan","Amsterdam","Barcelona","Hong Kong","Seoul","Tokyo","Istanbul","Kuala Lumpur","Singapore","New York","Dubai","Paris","London","Bangkok"]
Awaiting submission
Write a function that takes an Array of Ints and returns the sum.

Use the following code as a template:
// TODO: write your function here

let inputString = readLine() ?? ""
let numbers: [Int] = inputString.components(separatedBy: ",").flatMap { Int($0)}
let result: Int = sum(list: numbers)
print(result)
Awaiting submission
Write a function called isSubset that takes two arrays of strings and returns true if the first array is a subset of the second array.

Examples:
subset(list: ["a","c"], of: ["a","b","c","d"])   // true
subset(list: ["a","b","c","d"], of: ["a","c"])   // false
subset(list: ["a","b","c"], of: ["c","d"])       // false
subset(list: ["a","b"], of: ["a","b"])           // true
Use the following code as a template:
// TODO: write your function here

let list1: [String] = (readLine() ?? "").components(separatedBy: ",")
let list2: [String] = (readLine() ?? "").components(separatedBy: ",")
let result: Bool = subset(list: list1, of: list2)
print(result)