프로그래머스/Level 0

[Lv. 0] 간단한 논리 연산

스몰스테핑 2023. 5. 10. 14:38

문제 출처 : https://school.programmers.co.kr/learn/courses/30/lessons/181917

 

난이도 : Level.0


언어 : Kotlin

 

문제 설명 :

boolean 변수 x1, x2, x3, x4가 매개변수로 주어질 때, 다음의 식의 true/false를 return 하는 solution 함수를 작성해 주세요.

  • (x1 ∨ x2) ∧ (x3 ∨ x4)

 

제한 사항 

  • 없음

입출력 예 :

x1 x2 x3 x4 result
false true true true true
true false false false false

풀이 

class Solution {
    fun solution(x1: Boolean, x2: Boolean, x3: Boolean, x4: Boolean): Boolean = (x1.or(x2)).and((x3.or(x4)))
}