Skip to content

Instantly share code, notes, and snippets.

@mitake
Created December 8, 2012 06:22
Show Gist options
  • Save mitake/4238913 to your computer and use it in GitHub Desktop.
Save mitake/4238913 to your computer and use it in GitHub Desktop.
Party accounting
% usage:
% $ swipl -o party-accounting -c party-accounting.pl
% $ ./party-accounting
% ?- main.
:- use_module(library('clp/bounds')).
party_accounting(Nr_manager, Manager_yen, Nr_principle, Principle_yen, Nr_director, Director_yen, Nr_hira, Hira_yen, Total_yen) :-
Manager_yen in 0..Total_yen,
Principle_yen in 0..Total_yen,
Director_yen in 0..Total_yen,
Hira_yen in 0..Total_yen,
Director_yen mod 500 #= 0,
Principle_yen mod 500 #= 0,
Manager_yen mod 500 #= 0,
Hira_yen mod 500 #= 0,
Hira_yen #< Director_yen,
Director_yen #< Principle_yen,
Principle_yen #< Manager_yen,
Total_yen #=< Nr_manager * Manager_yen + Nr_principle * Principle_yen + Nr_director * Director_yen + Nr_hira * Hira_yen,
label([Nr_manager, Manager_yen, Nr_principle, Principle_yen, Nr_director, Director_yen, Nr_hira, Hira_yen, Total_yen]).
main :-
party_accounting(1, My, 9, Py, 4, Dy, 20, Hy, 159200 - 12000),
write('Manager yen: '),
format('~D', My),
nl,
write('Principle yen: '),
format('~D', Py),
nl,
write('Director yen: '),
format('~D', Dy),
nl,
write('Hira yen: '),
format('~D', Hy).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment