- 514 名前:デフォルトの名無しさん mailto:sage [2012/04/21(土) 01:27:35.30 ]
- >>512
Squeak Smalltalk で。 | ui stock player | ui := UIManager default. stock := (1 to: 9) gather: [:each | Array new: 4 withAll: each]. stock := stock shuffled asOrderedCollection. player := (stock removeFirst: 7) asOrderedCollection. [ | choice | [ | input | input := ui request: player asSortedArray asString, 'から合計が15になるようにチョイス'. choice := input subStrings collect: #asInteger. choice ifEmpty: [(ui confirm: 'ギブアップ?') ifTrue: [^self] ifFalse: [choice := {nil}]]. (choice allSatisfy: #isInteger) and: [choice sum = 15] and: (player includesAllOf: choice) and: [choice asSet allSatisfy: [:card | (player occurrencesOf: card) >= (choice occurrencesOf: card)]] ] whileFalse. player removeAll: choice. player addAll: (stock removeFirst: (choice size min: stock size)). player notEmpty] whileTrue. ui inform: 'おめでとう!'
|

|