Skip to content

Instantly share code, notes, and snippets.

@Poxios
Created January 26, 2024 00:58
Show Gist options
  • Save Poxios/9a967fcb443af31aa7e56f04cdd6213d to your computer and use it in GitHub Desktop.
Save Poxios/9a967fcb443af31aa7e56f04cdd6213d to your computer and use it in GitHub Desktop.
jungsan
const participants = ["은소", "종민", "의정", "연우", "서윤", "준하", "영현"]
type participants = typeof participants[number]
const events: { label: string, cost: number, target: participants[] }[] = [
{ label: "하나로1", cost: 58_280, target: ["은소", "종민", "의정", "연우", "서윤", "준하", "영현"] },
{ label: "하나로2", cost: 93_250, target: ["은소", "종민", "의정", "연우", "서윤", "준하", "영현"] },
{ label: "주유비", cost: 61_800, target: ["종민", "연우", "서윤", "준하", "영현"] },
{ label: "싼타클로스 햄버거", cost: 96_500, target: ["은소", "종민", "의정", "연우", "서윤", "준하", "영현"] },
{ label: "바베큐", cost: 30_000, target: ["은소", "종민", "의정", "연우", "서윤", "준하", "영현"] },
{ label: "씨유 (얼음, 음료수)", cost: 7_800, target: ["은소", "종민", "의정", "연우", "서윤", "준하", "영현"] },
{ label: "톨게이트", cost: 7_200, target: ["종민", "연우", "서윤", "준하", "영현"] },
{ label: "스파1", cost: 30_000, target: ["종민", "연우", "서윤", "준하", "영현"] },
{ label: "스파2", cost: 35_000, target: ["종민", "연우", "서윤", "준하", "영현"] },
{ label: "스파3", cost: 17_500, target: ["종민", "연우", "서윤", "준하", "영현"] },
{ label: "스파정산1", cost: 32_300, target: ["종민", "연우", "서윤", "준하", "영현"] },
{ label: "스파정산2", cost: 16_000, target: ["종민", "연우", "서윤", "준하", "영현"] },
{ label: "스파정산3", cost: 11_000, target: ["종민", "연우", "서윤", "준하", "영현"] },
{ label: "스파정산4", cost: 15_000, target: ["종민", "연우", "서윤", "준하", "영현"] },
{ label: "초밥", cost: 38_000, target: ["연우", "서윤", "영현"] },
{ label: "아이스크림", cost: 27_500, target: ["종민", "연우", "서윤", "준하", "영현"] },
]
participants.forEach(p => {
console.log(`${p} : ${events.reduce((sum, e) => e.target.includes(p) ? (sum + (e.cost) / e.target.length) : sum, 0).toFixed(0)}`);
})
@Poxios
Copy link
Author

Poxios commented Jan 26, 2024

npx ts-node jungsan.ts

은소 : 40833
종민 : 91493
의정 : 40833
연우 : 104160
서윤 : 104160
준하 : 91493
영현 : 104160

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment