 The possible positive integers below 100, divisible by 7, called candidates:
candidates = [n  n < [1..99]; n mod 7 = 0]
 The possible unitdigits y that Alice knows:
aliceKnows=
[y  y < [0..9];
and [
 Bob cannot know the number uniquely; i.e., there are at least two candidates with the same tendigit:
#[ n  n 1

 for every tendigit x of the candidates with unit y:
x < [0..9]; member candidates (10*x+y)
]
]
 The possible tendigits x that Bob knows:
bobKnows =
[x  x < [0..9];
 the candidates with tendigit x have the unitdigit known by Alice:
#[n  n < candidates; n div 10 = x; member aliceKnows (n mod 10)] = 1
]
 The set of candidates after the dialogue:
remainingCandidates =
[n  n < candidates; member aliceKnows (n mod 10); member bobKnows (n div 10) ]
# Alice knows the units value of tanyas_number
# Alice thinks that Bob does not know tanyas_number from just the tens value.
# Bob knows the tens value of tanyas_number
# Bob has some ambiguity about Alice’s knowledge of the number, stays quiet.
tanyas_reduced_set = lambda x: filter(lambda y: x != y, tanyas_set)
# => Alice does not know tanyas_number
alices_set = {i for i in tanyas_set
if i % 10 in {
j % 10 for j
in tanyas_reduced_set(i)}}
print(alices_set)
# => Bob does not know tanyas_number
bobs_set = {i for i in tanyas_set
if int(i/10) in {
int(j/10) for j
in tanyas_reduced_set(i)}}
print(bobs_set)
# If tanyas_number == 70, she would know tanyas_number and declare
# “I know Tanya’s number”.
# Bob would be very annoyed that Tanya has uniquely identified the
# number to Alice, but not to Bob. He could then figure it out too.
# Since Alice does not know tanyas_number,
# and if they both stay silent, this is as
# far as their logic can take them.
shared_set = bobs_set & alices_set
print(shared_set)
# But Alice has declared that Bob does not know.
# Bob can now filter ambiguity in his set.
shared_reduced_set = lambda x: filter(lambda y: x != y, shared_set)
bobs_ambiguous_set = {i for i in shared_set
if int(i/10) in {
int(j/10) for j
in shared_reduced_set(i)}}
# Bob no longer has any ambiguity
print(shared_set – bobs_ambiguous_set)
# It’s funny that Bob wouldn’t know tanyas_number
# if Alice had declared
# “I do not know Tanya’s number.”
# It gets really messy if Alice had declared
# “You know Tanya’s number”.
This is a little bit tedious but I wrote everything out so that anyone can understand it. OK. maybe not anyone, but as many people as possible.
TN = Tanya’s number
(1) The integers satisfying the publicly available information are 07, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91 and 98.
(2X0) Suppose Alice was given ‘X0’. She will think “This must be 70. However, since Bob will see it only as ‘7X’, there’s no way for Bob to tell whether it’s 70 or 77. Therefore, I can say with confidence that at this stage Bob doesn’t know TN.
(2X1) Suppose Alice was given ‘X1’. She will think “TN must be 21 or 91. If it’s 21, then Bob must have been given ‘2X’, from which he cannot tell whether it’s 21 or 28. If it’s 91, then Bob must have been given ‘9X’, from which he cannot tell whether it’s 91 or 98. Therefore I can confidently say Bob at this stage doesn’t know TN.”
(2X2) Suppose Alice was given ‘X2’. She will think “This must be 42. Bob must have been given ‘4X’ and he won’t be able to say if it’s 42 or 49. There is no way Bob knows TN.”
(2X3) Suppose Alice was given ‘X3’. She will think “This must be 63. Bob must have been given ‘6X’ and he must have easily deduced that it must be 63.” So Alice wouldn’t have said anything like her part in the conversation. We can rule out this possibility.
(2X4) Suppose Alice was given ‘X4’. She will think “This must be either 14 or 84. Either case, Bob knows TN. If given ‘1X’, he will know it’s 14 and if given ‘8X’, he will realize it’s 84.” So we see that there’s no way for Alice to say anything like her part in the conversation. We can rule out this possibility.
(2X5) Suppose Alice was given ‘X5’. She will think “This mus be 35. Then Bob must have been given ‘3X’ and easily concluded it’s 35.” So we see that there’s no way for Alice to say anything like her part in the conversation. We can rule out this possibility.
(2X6) Suppose Alice was given ‘X6’. She will think “This must be 56. Bob must have been given ‘5X’ and easily concluded that it’s 56.” So we see that there’s no way for Alice to say anything like her part in the conversation. We can rule out this possibility.
(2X7) Suppose Alice was given ‘X7’. She will think “This is either 07 or 77. If it is 07, then Bob will see it as ‘0X’ and Bob must know it’s 07. However, if it is 77, the Bob will see it as ‘7X’ and won’t know whether it’s 70 or 77. I can’t confidently assume Bob’s ignorance of TN.” So we see that there’s no way for Alice to say anything like her part in the conversation. We can rule out this possibility.
(2X8) Suppose Alice was given ‘X8’. She will think “This is either 28 or 98. If it’s 28, then Bob won’t know if it’s 21 or 28 because he will see it as ‘2X’. If it’s 98, then Bob won’t know if it’s 91 or 98 because he will see it as ‘9X’. Either way, Bob doesn’t know.”
(2X9) Suppose Alice was given ‘X9’. She will think “This must be 49. But Bob sees it as just ‘4X’ and there’s no way for him to say it’s 42 or 49. Bob doesn’t know.”
(2Lemma) From (2X0) through (2X9), we see that 21, 28, 42, 49, 70, 91, 98 are the only remaining possibilities logically allowed by Alice’s remark.
(3) Bob said he knows TN, which basically means that he was able to determine TN from (2Lemma) and the tensdigit information. Therefore, it is obvious that he hasn’t been given ‘2X’ or ‘4X’ or ‘9X’. This leaves us with just ‘7X’, i.e. 70 in this case.
Let’s reconstruct the situation now.
Alice is given ‘X0’ and Bob is given ‘7X’. The candidates are 07, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91 and 98.
Given ‘X0’, Alice thinks “This must be 70, because it’s the only one in the candidate pool that ends with a 0. But Bob will see it only as ‘7X’, there’s no way for Bob to tell whether it’s 70 or 77. Therefore, I can say with confidence that at this stage Bob doesn’t know what TN is.”
Then Alice tells Bob “You do not know Tanya’s number.”
Bob hears this and figures out (2Lemma). He already had the ‘7X’ information initially given by Tanya.
So Bob tells Alice “I know Tanya’s number.”