다윗선택
2026년 9월 15일 09:30분
사무엘상 16장에서 사무엘은 이새의 아들들 중에서 막내 다윗을 기름부음합니다. 외모가 아닌 마음을 보십니다. 나는 외적 조건 대신 내적 점수를 기준으로 선택하는 알고리즘을 만들었습니다.
package com.jesusbornd.samuel1;
import java.util.List;
public class Samuel1_16_Chapter_Lv2 {
record Candidate(String name, int height, int heartScore) {}
static Candidate select(List<Candidate> candidates) {
return candidates.stream()
.max((a, b) -> Integer.compare(a.heartScore(), b.heartScore()))
.orElseThrow();
}
public static void main(String[] args) {
var chosen = select(List.of(
new Candidate("엘리압", 190, 60),
new Candidate("아비나답", 185, 55),
new Candidate("다윗", 160, 95)));
System.out.println("선택: " + chosen.name() + " (마음 점수: " + chosen.heartScore() + ")");
}
}
candidates = [("엘리압", 190, 60), ("아비나답", 185, 55), ("다윗", 160, 95)]
chosen = max(candidates, key=lambda c: c[2])
print(f"선택: {chosen[0]} (마음 점수: {chosen[2]})")
Search
Categories
← 목록으로
Comments
사람은 외모를 보지만 하나님은 중심을 보십니다.