부채탕감

2026년 6월 22일 09:30분

신명기 15장에서 7년마다 빚을 탕감합니다. 누적된 부채를 주기적으로 초기화합니다. 나는 부채 목록을 관리하고 탕감 주기가 되면 전체를 리셋하는 부채 관리기를 만들었습니다.

package com.jesusbornd.deuteronomy;
import java.util.*;

public class Deuteronomy_15_Chapter_Lv2 {
    static final int RESET_YEAR = 7;
    static Map<String, Integer> debts = new HashMap<>(Map.of(
        "르우벤", 500, "시므온", 300, "레위", 200, "유다", 800
    ));

    static void cancelAll(int currentYear) {
        if (currentYear % RESET_YEAR == 0) {
            System.out.printf("[%d년] 안식년 — 모든 부채 탕감%n", currentYear);
            debts.replaceAll((k, v) -> 0);
        }
        debts.forEach((name, d) -> System.out.printf("  %s: %d%n", name, d));
    }

    public static void main(String[] args) {
        System.out.println("탕감 전: " + debts);
        cancelAll(7);
        System.out.println("탕감 후: " + debts);
    }
}

RESET_YEAR = 7
debts = {"르우벤": 500, "시므온": 300, "레위": 200, "유다": 800}

def cancel_all(current_year):
    if current_year % RESET_YEAR == 0:
        print(f"[{current_year}년] 안식년 — 모든 부채 탕감")
        for k in debts: debts[k] = 0

if __name__ == "__main__":
    print("탕감 전:", debts.copy())
    cancel_all(7)
    print("탕감 후:", debts)

Comments

Avatar
 2026년 6월 22일 09:32분

주기적 리셋이 시스템을 지속 가능하게 만든다는 통찰이 인상적이네요.



Search

← 목록으로