Files
Aislo/B08_Quantity/B08_Quantity_Formula_Node.ts
T
eomsangdonandClaude Opus 5 197728d6c9 feat(b08): 구조물도 식 풀이기 — TS 한 벌을 화면·서버 Node 가 같이 씀
- 명세 13장 식 언어(사칙·^·비교·SQRT·MIN·MAX·SUM·IF·LOOKUP 근사/EXACT)를 직접 짠 파서로 풂
- 수는 BigInt 분수로 들고 적힌 차례대로 풂 — 부동소수 버림·반올림 1 틀어짐 막음
- 줄마다 반올림 floor·round(사사오입)·ceil·none·round_half_even, refs 는 앞 줄만
- 서버는 build:formula 번들을 Node 로 부름(B06 Server_Calc 본), 파이썬은 껍데기뿐
- 시험 15건 — 실무 찰쌓기 탭 12줄 엑셀 캐시값 재현 포함

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016VBGFXB9AbJBwXP19z75Qq
2026-09-13 16:46:54 +09:00

26 lines
1.2 KiB
TypeScript

/* =============================================================================
* B08_Quantity_Formula_Node.ts
* 구조물도 식 풀이를 **서버가** 돌리는 진입점 — [저장]·[확정] 때 정본으로 다시 풂.
*
* 풀이는 화면이 쓰는 `B08_Quantity_Formula.ts` 그대로(판정 Ⓐ, 2026-09-13) —
* B06 `B06_Section_Server_Calc_Node.ts` 와 같은 본. 여기에는 계산이 없음.
*
* 실행: node <번들> <입력.json> <출력.json>
* 입력 { sheets: FormulaSheet[] }
* 출력 { sheets: FormulaRowResult[][] } — 입력 장 차례 그대로
* 끝 코드: 0 성공 / 2 인자 오류
* ========================================================================== */
import { readFileSync, writeFileSync } from "node:fs";
import { evaluateSheet, type FormulaSheet } from "./B08_Quantity_Formula";
const [inputPath, outputPath] = process.argv.slice(2);
if (!inputPath || !outputPath) {
console.error("사용법: node <번들> <입력.json> <출력.json>");
process.exit(2);
}
const input = JSON.parse(readFileSync(inputPath, "utf8")) as { sheets?: FormulaSheet[] };
const sheets = (input.sheets ?? []).map((sheet) => evaluateSheet(sheet));
writeFileSync(outputPath, JSON.stringify({ sheets }));