Loading [MathJax]/jax/output/CommonHTML/fonts/TeX/AMS-Regular.js
前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >我知道你不知道,我到底知不知道?

我知道你不知道,我到底知不知道?

作者头像
用户9995743
发布于 2022-12-22 08:06:17
发布于 2022-12-22 08:06:17
5160
举报
文章被收录于专栏:彭旭锐彭旭锐

请点赞关注,你的支持对我意义重大。 🔥 Hi,我是小彭。本文已收录到 GitHub · AndroidFamily[1] 中。

前言

大家好,我是小彭。

在计算机面试中,逻辑类题目是规模以上互联网公司的必考题。由于题目花样百出,准备难度较大,题海战术可能不是推荐的做法。在这个系列里,我将精选十道非常经典的逻辑题,希望能帮助你找到解题思路 / 技巧。如果能帮上忙,请务必点赞加关注,这真的对我非常重要。


系列文章:

  • 我知道你不知道,我到底知不知道[2]
  • 至少要几个砝码,可以称出 1g ~ 40g 重量[3]
  • 舞会上有多少顶黑帽?[4]
  • 25 匹马 5 条赛道,最快需要几轮求出前 3 名?[5]

1. 题目描述

A 与 B 好奇问 C 的年龄,爱卖关子的 C 给出了以下 11 个数字,C 的年龄就是其中的一个:3536384245465155576162,并且分别把年龄的十位数告诉给 A,把个位数告诉给 B。此时,A 和 B 发生以下对话:

A:我不知道 C 的年龄,我知道你不知道。

B:原本我不知道的,现在我知道了。

A:现在我也知道了。

那么,请问 C 的年龄是?


2. 解题关键

  • 1、我知道你不知道的含义: 这句话的含义是:根据我的现有信息,可以知道你未取得命题的充分条件。更通俗的说法是,我不知道你现在是什么情况,反正一定不是那个可以推断出结果的状态;
  • 2、“唯一性” 隐含的充分条件: 有 36、46、57 这三个数,假设已知目标数的个位数是 7 ,那么很明显这个数就是 57 了(因为只有唯一个数字个位是 7)。

3. 题解

  • 首先我们观察 11 个数字: (35、36、38、42、45、46、51、55、57、61、62)

十位数有 3、4、5、6 这几种可能,都会匹配不唯一个数字。

个位数有 1、2、5、6、7、8 这几种可能,其中 1、2、5、6 会匹配不唯一个数字,而 7、8 会分别匹配 57、38 两个数字。

  • A:我不知道 C 的年龄,我知道你不知道。

首先,A 说 “不知道 C 的年龄”,说明十位数是不唯一的。由于 十位数 3、4、5、6 都对应多个数,目前无法排除任何数字;

随后 A 又说 “我知道你不知道”,in other words,“根据我的现有信息,可以知道你未取得命题的充分条件”,in other words,“我知道你手上的个位数一定不是 7 或 8 ”。

为什么 A 敢断言:“你手上的个位数一定不是 7 和 8” 呢?一定是 A 手中的十位数不是 3,也不是 5 的时候。只有这样才能确定最终答案不是 3_ 或 5_ ,也就不可能是 38、57 两个数字。

  • 此时,观察剩下以下数字: (42、45、46、61、62)

个位数有 1、2、5、6 这几种可能,其中 个位数 2 会匹配多个数字,而 个位数 1、5、6 会分别匹配 61、45、46 三个数字。

  • B:原本我不知道的,现在我知道了。

此时,B 说 “我知道了”,说明达到唯一性充分条件,那么年龄个位数一定不是 2

  • 此时,观察剩下以下数字: (61、45、46)

十位数有 4_ 和6_ 这两种可能,其中 十位数 4 会匹配 2 个数字,而 十位数 6 会唯一匹配 61 这个数字。

  • A:现在我也知道了。

此时,A 说 “我也知道了”,说明达到唯一性充分条件,那么年龄是 61。

我是小彭,带你构建 Android 知识体系。

参考资料

[1]

GitHub · AndroidFamily: https://github.com/pengxurui/AndroidFamily

[2]

我知道你不知道,我到底知不知道: https://juejin.cn/post/6902829580013436942

[3]

至少要几个砝码,可以称出 1g ~ 40g 重量: https://juejin.cn/post/6903460612886495245

[4]

舞会上有多少顶黑帽?: https://juejin.cn/post/6903524335193948167/

[5]

25 匹马 5 条赛道,最快需要几轮求出前 3 名?: https://juejin.cn/post/6903861591188783112/

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2022-09-03,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 彭旭锐 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
NFV迈向云原生时代:Network Service Mesh项目介绍
当第一次看到Network Service Mesh这一名词时,你很可能和我一样好奇它到底是什么?是否和Service Mesh有什么关系?Network Service Mesh是云原生领域中一个新的热点,是CNCF(云原生基金会)中的一个沙箱项目。本文将介绍Network Service Mesh的起源和架构,并探讨其与Service Mesh、SDN、NFV等相关技术的区别与联系。
赵化冰
2022/08/01
1.3K0
NFV迈向云原生时代:Network Service Mesh项目介绍
Which One is the Right Choice for the Ingress Gateway of Your Service Mesh?
By default, in a Kubernetes cluster with the Istio service mesh enabled, services can only be accessed inside the cluster. However, some of the services may need to be exposed to external networks as well. Kubernetes and Istio provide a variety of means to
赵化冰
2022/08/01
5000
Which One is the Right Choice for the Ingress Gateway of Your Service Mesh?
The obstacles to put Istio into production and how we solve them
I have been following the Istio project from its early stage. Over time, it turned out Istio has a good architecture, an active community, promising features and also strong support from big companies. So, after its 1.0 release, our team has begun the efforts to integrate Istio into our system. This article tells our findings and thoughts during this adventure.
赵化冰
2022/08/01
4240
The obstacles to put Istio into production and how we solve them
Debugging Kubernetes Networking
How to Find a Needle in a Virtualized Network
heidsoft
2022/06/09
3780
Debugging Kubernetes Networking
Network Service Mesh发布0.2版本,来Run示例玩玩
https://github.com/networkservicemesh/networkservicemesh/blob/master/docs/guide-helm.md
CNCF
2019/12/04
7660
Try out Istio Ambient mode
Ambient is a new data-plane model that Istio has just announced support for. In this post, we will try to install Istio’s ambient model and use the bookinfo demo to experience the L4 and L7 capabilities offered by ambient.
赵化冰
2022/09/28
2680
Try out Istio Ambient mode
cni | 容器网络接口规范|Container Networking Interface Specification
Application containers on Linux are a rapidly evolving area, and within this area networking is not well addressed as it is highly environment-specific. We believe that many container runtimes and orchestrators will seek to solve the same problem of making the network layer pluggable.
heidsoft
2022/04/18
9780
Container Platform and Best Practices Reference
This is a process diagram summarizing a Kubernetes cluster environment from three years ago, depicting various components and their relationships within it. The diagram from left to right illustrates a mind map ranging from the perspective of basic resources to application management. Let's explain the main components in the diagram:
行者深蓝
2023/12/11
2720
认识Service Mesh(1): Deploy Istio on Kubernetes with GKE
关注容器圈的朋友一定会注意到最近一年的高频词:Service Mesh。这么绕口的词,到底是什么意思?引用一篇文章里对其的解释:
nevermosby
2020/05/11
7500
What Can Service Mesh Learn from SDN?
Service Mesh is yet another emerging fancy tech word in the field of microservices recently. If you have a telecommunication or networking background, you may have already noticed that Service Mesh and SDN (Software Defined Network) look similar. Both of them use a software layer to manage and control the network infrastructure, and they also share the same architecture, which consists of a control plane and a data plane.
赵化冰
2022/08/01
2320
What Can Service Mesh Learn from SDN?
全面对比指南:Service Mesh能否成为下一代SDN
作者:James Kelly 译者:月满西楼 原题:Are Service Meshes the Next-Gen SDN? 全文7500字,阅读约需要18分钟 2017年6月28日更新: 了解更
yuanyi928
2018/03/30
1.4K0
全面对比指南:Service Mesh能否成为下一代SDN
云原生 | Kubernetes 之常用 CNI 网络插件简述与对比
Kubernetes 需要使用网络插件来提供集群内部和集群外部的网络通信,并提供可扩展和高性能的网络架构,其核心概念如下:
全栈工程师修炼指南
2024/08/20
5370
云原生 | Kubernetes 之常用 CNI 网络插件简述与对比
kubernetes入门-概念篇
Kubernetes is an open-source platform for automating deployment, scaling, and operations of application containers across clusters of hosts, providing container-centric infrastructure.
王磊-字节跳动
2019/05/28
2.5K0
运维锅总浅析kubernetes网络插件
本文首先介绍kubernetes的网络模型,然后分别对Flannel 、Calico 、Cilium网络插件的各种模式进行介绍,最后通过表格方式对比三者的异同及应用场景。希望对您选择Kubernetes网络插件有所帮助
锅总
2024/07/29
3320
运维锅总浅析kubernetes网络插件
Understanding Kubernetes Kube-Proxy
Kubernetes is a complicated system with multiple components interacting with each other in complex ways. As you may already know, Kubernetes is made of master and node components.
heidsoft
2019/09/10
2.1K0
Understanding Kubernetes Kube-Proxy
Know Kubernetes — Pictorially
Recently, I started my Kubernetes journey and wanted to understand its internals better. I did a talk on these lines and here is the blog version of it
麒思妙想
2020/07/10
5150
SRE Interview Questions and Answers Simulation - Linux and K8S
grep: A tool for searching text using patterns (regular expressions).
行者深蓝
2024/09/08
1350
交易系统架构演进之路(七):Service Mesh
Service Mesh,也叫服务网格,号称是下一代微服务架构技术,能有效地解决当前微服务架构中关于服务治理的痛点问题,从 2016 年推出至今,一直都是架构领域的热点。
Keegan小钢
2021/03/10
9430
交易系统架构演进之路(七):Service Mesh
service mesh 简介
先来个文献:https://philcalcado.com/2017/08/03/pattern_service_mesh.html
看、未来
2022/05/28
6630
service mesh 简介
SDN实战团分享(五):基于VCS技术 + NSX 控制平台实现SDDC网络架构
1.数据中心和新的网络架构需要软硬件一体化 看到前面的兄弟关于NSX架构的分享,感到收获良多,Vmware力争实现的平台是一种和硬件解耦,把大部分问题在虚拟化架构中解决的构想,对于传统硬件厂商来说,这种方式给我们带来了很多挑战,也带来了软件网络能否完全脱离硬件体系的很多争论。 值得肯定的是,目前软件网络的功能和性能都有较大的提升,包括Vrouter,vLB等NFV产品的出现,已经对传统网络厂商构成了一定威胁,Brocade也正是NFV(包括vRouter,vLB的供应商),我们的vRouter Vyatta
SDNLAB
2018/04/03
1.3K0
SDN实战团分享(五):基于VCS技术 + NSX 控制平台实现SDDC网络架构
推荐阅读
相关推荐
NFV迈向云原生时代:Network Service Mesh项目介绍
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档