головоломка

ALLA2009

картинка взята с лепры, оригинал тут:
http://faculty.uml.edu/jpropp/srat.html

a101

Странный пазл. Даже при "правильном" расставлении всех буковок, в некоторых клетках (не только в 19й) существуют и другие правильные ответы (но они противоречат остальной картине). По моему это не совсем корректно :(

qwerty225

По моему это не совсем корректно
корректно - ведь задача "найти всевохможные наборы ответов , так чтоб в целом не было противоречия"

Arthur8

"баттхёрт проваливших ЕГЭ?" (с)

Enery

другие правильные ответы (но они противоречат остальной картине)
Так бы сразу и сказал, что не знаешь.

Evgenui

в последней ячейке неправильный перевод :crazy:

ALLA2009

вот эта задачка больше понравилась:
Below are ten statements concerning X, a whole number between 1 and 10
(inclusive). Not all of the statements are true, but not all of them
are false either. What number is X?
1. X equals the sum of the statement numbers of the false statements in
this list.
2. X is less than the number of false statements in this list, and
statement 10 is true.
3. There are exactly three true statements in this list, or statement 1
is false, but not both.
4. The previous three statements are all false, or statement 9 is true,
or both.
5. Either X is odd, or statement 7 is true, but not both.
6. Exactly two of the odd-numbered statements are false.
7. X is the number of a true statement.
8. The even-numbered statements are either all true or all false.
9. X equals three times the statement number of the first true statement
in this list, or statement 4 is false, or both.
10. X is even, or statement 6 is true, or both.

terkin

какое решение ?

terkin

ок гугл помог, программка выглядит так:
Когда решал сам понимал вопрос 7 как "number of a true statements" - число верных утверждений.
def matches(true_false, conditional):
if true_false:
return conditional
else:
return not conditional

def xor(a, b):
return (a or b) and (not a or not b)

def all_vals:
for v in all_vals_helper(n=10):
yield [None] + v

def all_vals_helper(n):
if n == 1:
yield [True]
yield [False]
else:
for sub in all_vals_helper(n=n-1):
yield [True] + sub
yield [False] + sub

def print_answer(X, vals):
print 'Number: %i' % X
for i in range(1, 11):
print '%2i) %s' % (i, vals[i])

for X in range(1, 11):
for vals in all_vals:

total_true = 0
total_false = 0
for i in range(1, 11):
if vals[i]:
total_true += 1
else:
total_false += 1

# 1) X equals the sum of the statement numbers of the false statements in
# this list.
total = 0
for n in range(1, 11):
if vals[n]:
total += n
if not matches(vals[1], X == n):
continue

# 2) X is less than the number of false statements in this list, and
# statement 10 is true.
total = 0
if not matches(vals[2], X < total_false and vals[10]):
continue

# 3) There are exactly three true statements in this list, or statement 1
# is false, but not both.
if not matches(vals[3], xor(total_true == 3, not vals[1]:
continue

# 4) The previous three statements are all false, or statement 9 is true,
# or both.
if not matches(vals[4], (not vals[1] and not vals[2] and not vals[3]) or vals[9]):
continue

# 5) Either X is odd, or statement 7 is true, but not both.
if not matches(vals[5], xor(X % 2, vals[7]:
continue

# 6) Exactly two of the odd-numbered statements are false.
total_odd_false = 0
for n in range(1, 11, 2):
if not vals[n]:
total_odd_false += 1
if not matches(vals[6], total_odd_false == 2):
continue

# 7) X is the number of a true statement.
if not matches(vals[7], X == total_true):
continue

# 8) The even-numbered statements are either all true or all false.
all_true = True
all_false = True
for n in range(2, 11, 2):
all_true = all_true and vals[n]
all_false = all_false and not vals[n]
if not matches(vals[8], all_true or all_false):
continue

# 9) X equals three times the statement number of the first true statement in
# this list, or statement 4 is false, or both.
for n in range(1, 11):
if vals[n]:
break
else:
assert 0, "None are true"
if not matches(vals[9], X == n * 3 or not vals[4]):
continue

# 10) X is even, or statement 6 is true, or both.
if not matches(vals[10], not X % 2 or vals[6]):
continue

print_answer(X, vals)
Оставить комментарий
Имя или ник:
Комментарий: