Created
October 19, 2011 07:55
-
-
Save umejam/1297710 to your computer and use it in GitHub Desktop.
Alloyで論理パズルを解いてみる その2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//問題: | |
//ミスコンの最終選考に残ったのは好美, 恵美, 明美, 麻美, 宏美の5人。 | |
//誰が優勝するか、なかよし4人が次のように予想した。 | |
// | |
// まゆみ 「好美と恵美は無理」 | |
// 大貴 「明美か恵美が優勝する」 | |
// 崇臣 「好美か麻美が優勝する」 | |
// やす美 「好美と宏美は無理」 | |
// | |
// 4人のうち、予想があたったのは二人だった。 | |
// 優勝したのは誰? | |
// | |
// 出典: 新作論理パズル77 小野田 博一 | |
enum コンテスト結果 {優勝, 落選} | |
enum 予想結果 {アタリ, ハズレ} | |
abstract sig 候補者 { | |
の結果: one コンテスト結果 | |
} | |
one sig 好美, 恵美, 明美, 麻美, 宏美 extends 候補者 {} | |
fact 優勝者は一人 { | |
one p: 候補者 | p.の結果 = 優勝 | |
} | |
abstract sig やじ馬 { | |
の予想: one 予想結果 | |
} | |
one sig まゆみ, 大貴, 崇臣, やす美 extends やじ馬 {} | |
fact 予想があたった人は二人 { | |
#{p: やじ馬 | p.の予想 = アタリ} = 2 | |
} | |
fact まゆみの予想 { | |
まゆみ.の予想 = アタリ <=> all p: {好美 + 恵美} | p.の結果 = 落選 | |
} | |
fact 大貴の予想 { | |
大貴.の予想 = アタリ <=> one p: {明美 + 恵美} | p.の結果 = 優勝 | |
} | |
fact 崇臣の予想 { | |
崇臣.の予想 = アタリ <=> one p: {好美 + 麻美} | p.の結果 = 優勝 | |
} | |
fact やす美の予想 { | |
やす美.の予想 = アタリ <=> all p: {好美 + 宏美} | p.の結果 = 落選 | |
} | |
pred show {} | |
run show |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment