장애감지

2026년 5월 12일 09:30분

민수기 22장에서 나귀가 천사의 장애물을 먼저 봅니다. 앞을 보지 못하는 주인보다 나귀가 먼저 경로 이탈을 감지합니다. 나는 경로 상의 장애물을 감지하고 회피 전략을 반환하는 탐지기를 만들었습니다.

package com.jesusbornd.numbers;
import java.util.Set;

public class Numbers_22_Chapter_Lv3 {
    record Position(int x, int y) {}

    static Set<Position> obstacles = Set.of(
        new Position(3, 0), new Position(5, 0), new Position(7, 1)
    );

    static void move(String traveler, Position from, Position to) {
        boolean blocked = obstacles.contains(to);
        System.out.printf("%s: (%d,%d)→(%d,%d) %s%n",
            traveler, from.x(), from.y(), to.x(), to.y(),
            blocked ? "⚠️ 장애물 감지 — 경로 회피" : "✅ 통과");
    }

    public static void main(String[] args) {
        move("발람", new Position(0,0), new Position(3,0));
        move("나귀", new Position(3,0), new Position(5,0));
        move("발람", new Position(5,0), new Position(6,0));
    }
}

OBSTACLES = {(3, 0), (5, 0), (7, 1)}

def move(traveler, fx, fy, tx, ty):
    blocked = (tx, ty) in OBSTACLES
    status = "⚠️ 장애물 감지 — 경로 회피" if blocked else "✅ 통과"
    print(f"{traveler}: ({fx},{fy})→({tx},{ty}) {status}")

if __name__ == "__main__":
    move("발람", 0, 0, 3, 0)
    move("나귀", 3, 0, 5, 0)
    move("발람", 5, 0, 6, 0)

Comments

Avatar
 2026년 5월 12일 15:08분

눈에 보이지 않는 장애물을 먼저 감지하는 시스템이 필요했군요.



Search

← 목록으로