That’s a representation of the book. I’m not trying to sell or promote it for sale nor do I wish to buy it, it’s right in front of me.

Posers is a book of just that, but none that would take a 130 IQ to solve, just good old common sense and logic. I’m betting there are plenty of posers that can be proven with code, though it is merely hypothesis at this writing.

Take the first poser, which I’m quoting a transcription from the book under Fair Use Guidelines…

A man who wears either blue or brown socks keeps them all in the same drawer in a state of complete disorder. In total there are 20 blue and 20 brown socks in the drawer.

Assuming there is insufficient light for the man to see the color of the socks, how many must he take out of the drawer to be sure that he has a matching pair?

A little concerned about the literal 3 thrown in there. Must be some way to get around that. Sayin’.

Jotted this down to help me think…

>>> from random import choice
>>> r = ['blue', 'brown']
>>> m = choice(r)
>>> n = choice(r)
>>> o = choice(r)
>>> o == m or o == n
True
>>>

We need to add the probabilities to get to 1:

P(o == m) == 0.5
P(o == n) == 0.5

Given there are only two choices, that sums it up. A fifty-fifty chance that it will match one of the pair. So the probability of the next choice matching one of these is 1.

A game is played by 3 players in which the one who loses must double the amount of money that each of the other 2 players has at that time.
Each of the 3 players loses 1 game and at the conclusion of the 3 games each man has $16.
How much money did each man start with?

If 50 players enter a singles tennis tournament, how many matches are required to determine the winner? Of course, a player is eliminated as soon as they lose a match.

class Tire:
def __init__(self, id, miles=0):
self.id = id
self.miles = miles
def __repr__(self):
return f'Tire {self.id}: {self.miles}'
class Car:
def __init__(self, make, model, doors, wheels=4, tires=5, mileage=0):
self.make = make
self.model = model
self.doors = doors
self.wheels = wheels
self.tires = [Tire(i, mileage) for i in ('A', 'B', 'C', 'D', 'E', 'F', 'G', 'E')[:tires]]
self.tires_on_ground = self.tires[:wheels]
self.spare_tire = self.tires[wheels:] #or spare tires if more than one
self.mileage = mileage
def __str__(self):
return f'''
Make: {self.make}
Model: {self.model}
Number of doors: {self.doors}
Number of wheels: {self.wheels}
Number of tires in rotation: {len(self.tires)}
Miles on each tire: {self.tires}
Current mileage: {self.mileage}
'''
def drive(self, miles_driven):
self.mileage += miles_driven
for tire in self.tires_on_ground:
tire.miles += miles_driven
def rotate_tires(self):
num_spares = len(self.spare_tire)
self.tires_on_ground = self.tires[num_spares:]
self.spare_tire = self.tires[:num_spares]
self.tires = self.tires_on_ground + self.spare_tire
def simulate_tire_wear(car, miles_to_drive):
miles_per_rotation = miles_to_drive // len(car.tires)
while miles_to_drive > 0:
# print(car) # uncomment to see progression
car.drive(min(miles_per_rotation, miles_to_drive))
car.rotate_tires()
miles_to_drive -= miles_per_rotation
print(car)
my_truck = Car('Ford', 'F-250', 4)
simulate_tire_wear(my_truck, 20000)
my_bmw = Car('BMW', 'Isetta', 1, 3) # using default 5 tires simulating 2 spare tires
simulate_tire_wear(my_bmw, 20000)

Output

Make: Ford
Model: F-250
Number of doors: 4
Number of wheels: 4
Number of tires in rotation: 5
Miles on each tire: [Tire A: 16000, Tire B: 16000, Tire C: 16000, Tire D: 16000, Tire E: 16000]
Current mileage: 20000

Make: BMW
Model: Isetta
Number of doors: 1
Number of wheels: 3
Number of tires in rotation: 5
Miles on each tire: [Tire A: 12000, Tire B: 12000, Tire C: 12000, Tire D: 12000, Tire E: 12000]
Current mileage: 20000

Three couples must get across a river using a boat which cannot hold more than 2 people. None of the men will allow his wife to be on the same side of the river or in the boat with any other man (or men) unless he also is present.

Assuming that both the husbands and the wives can row, how do the 3 couples get across under the stated conditions?

Worked it out on paper easily enough. Not sure where to even start to code it up. A list of arbitrary moves isn’t really getting the computer to solve the poser. One could code up a game similar to Hanoi Towers, and/or write an algorithm to determine the fewest number of moves to reach the goal.

There are six matches in a horizontal row, 3 with heads up followed by 3 with heads down. The position of the matches can be changed by turning over any 2 adjacent matches.

In 3 moves, show how to change the position of the matches so that the head of the first match is up, the second down, the third up, fourth down, etc.

On paper it is simple enough. Can the logic be written to go from start to finish?

>>> a = int("0b111000", 2)
>>> b = int("0b100000", 2)
>>> c = int("0b101100", 2)
>>> d = int("0b101010", 2)
>>> a, b, c, d
(56, 32, 44, 42)
>>> 56 ^ 24
32
>>> 32 ^ 12
44
>>> 44 ^ 6
42
>>>

>>> a = int("0b111000", 2)
>>> b = a ^ 8 # the first two bits
>>> a ^= (b >> 1) # the second two
>>> a ^= (b >> 2) # the third
>>> a ^= (b >> 3) # the fourth
>>> a
42
>>>

Okay, still fudging around with this one…

>>> def shift_bits(a):
b = a ^ 8
while b > 6:
b >>= 1
a ^= b
return a
>>> shift_bits(56)
42
>>>