Bibi's DevLog ๐Ÿค“๐ŸŽ

[๋ฐฑ์ค€ 2789] ์œ ํ•™ ๊ธˆ์ง€ (Swift) ๋ณธ๋ฌธ

ํ”„๋กœ๊ทธ๋ž˜๋ฐ/์•Œ๊ณ ๋ฆฌ์ฆ˜ ํ’€์ด Swift

[๋ฐฑ์ค€ 2789] ์œ ํ•™ ๊ธˆ์ง€ (Swift)

๋น„๋น„ bibi 2022. 9. 21. 12:33

2789๋ฒˆ: ์œ ํ•™ ๊ธˆ์ง€

  • ์ž…๋ ฅ๋˜๋Š” ๋ฌธ์ž์˜ ๊ฐ ๊ธ€์ž ๊ฒ€์—ด ๋ฌธ์ž์—ด์ธ โ€œCAMBRIDGEโ€์— ํ•ด๋‹นํ•˜๋Š”์ง€ ํ™•์ธํ•˜๊ณ , ํ•ด๋‹น๋˜์ง€ ์•Š๋Š” ๋ฌธ์ž๋งŒ ๊ณจ๋ผ ์ถœ๋ ฅํ•œ๋‹ค.
  • ์Šค์œ„ํ”„ํŠธ์—์„œ๋Š” ๋ฌธ์ž์—ด์— ๋Œ€ํ•ด์„œ๋„ .contains() ์™€ .filter ๋ฅผ ๋ฐ”๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์–ด์„œ ํŽธํ•˜๋‹ค!
let censor = "CAMBRIDGE"
let input = readLine()!
let answer = input.filter {
    return !censor.contains($0)
}
print(answer)