/**
 * This function optimizes a portfolio by selecting the most valuable assets from a pool of available assets based on the desired assets.
 *
 * @param availableAssets A list of available assets.
 * @param desiredAssets A list of desired assets.
 * @return A list of selected assets to include in the portfolio.
 */
fun optimizePortfolio(availableAssets: List<String>, desiredAssets: List<String>): List<String> {

    val selectedAssets = mutableListOf<String>()

    for (asset in availableAssets) {
        if (asset in desiredAssets) {
            selectedAssets.add(asset)
        } else {
            for (desiredAsset in desiredAssets) {
                if (asset.startsWith(desiredAsset[0]) && asset.endsWith(desiredAsset[desiredAsset.length - 1])) {
                    selectedAssets.add(asset)
                    break
                }
            }
        }
    }
    return selectedAssets
}
/**
 * This function optimizes a portfolio by selecting the most valuable assets from a pool of available assets based on the desired assets.
 *
 * @param availableAssets A list of available assets.
 * @param desiredAssets A list of desired assets.
 * @return A list of selected assets to include in the portfolio.
 */
fun optimizePortfolio(availableAssets: List<String>, desiredAssets: List<String>): List<String> {
/**
 * This function optimizes a portfolio by selecting the most valuable assets from a pool of available assets based on the desired assets.
 *
 * @param availableAssets A list of available assets.
 * @param desiredAssets A list of desired assets.
 * @return A list of selected assets to include in the portfolio.
 */
fun optimizePortfolio(availableAssets: List<String>, desiredAssets: List<String>): List<String> {

    val selectedAssets = mutableListOf<String>()

    for (asset in availableAssets) {
        if (asset in desiredAssets) {
            selectedAssets.add(asset)
        } else {
            for (desiredAsset in desiredAssets) {
                if (asset.startsWith(desiredAsset[0]) && asset.endsWith(desiredAsset[desiredAsset.length - 1])) {
                    selectedAssets.add(asset)
                    break
                }
            }
        }
    }
    return selectedAssets
}