We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
请按照以下的模版填充相应的内容,一个 PR 会自动生成并保持与本 Issue 的内容同步。
你不需要提供详细的答案或教学,但请保证题目可解。
# 题目难度 difficulty: hard # medium / hard / extreme # 题目标题 title: 康威生命游戏 # 题目标签 # tags: union, array # separate by comma
康威生命游戏是一种有意思的游戏。 它的游戏进行在一个方格布上,每个方格或生或死,根据当前的方格布可推断出下一刻方格布的方格排列,推断规则如下:
这个游戏的胜利条件是你开心。只要你看你的方格布看得很开心,你就胜利了。
现在可以在 TS 中表示一盘如此的 $8 \times 8$ 康威生命游戏:
type Status = 'o' | 'x'; type Line = `${Status}${Status}${Status}${Status}${Status}${Status}${Status}${Status}`; type LifeGame = [Line, Line, Line, Line, Line, Line, Line, Line]; type LifeGame0 = [ 'xxxxxxxx', 'xxxxoxxx', 'xxooxxxx', 'xxoxxoox', 'xxxxxxxx', 'xxxxoxxx', 'xxxooxxx', 'xxxxxxxx', ];
其中, o 表示活着, x 表示死掉了;一个字符串表示一行,数组中有八个字符串表示有八行。 LifeGame0 表示一盘进行当中的生命游戏。 在本挑战中你不需要考虑边缘外的方格。
o
x
LifeGame0
现在,希望你能设计一个康威生命游戏的计算器,给定游戏进行的时间和初始的方格布,推算出到时间时的方格布是什么样子。
以下是给予挑战者开始做题的代码模版,在大部分情况下你只需要修改类型名称使其符合你的题目与判题测试,实现的部分保持 any 即可。
any
type Status = 'o' | 'x'; type Line = `${Status}${Status}${Status}${Status}${Status}${Status}${Status}${Status}`; type LifeGame = [Line, Line, Line, Line, Line, Line, Line, Line]; type GotLifeGame<T extends number, B extends LifeGame> = any
请为你的题目提供一些判题测试,你可以使用 @type-challenges/utils 中提供的一些工具进行判断。
@type-challenges/utils
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<GotLifeGame<0, [ 'xxxxxxxx', 'xxxxoxxx', 'xxooxxxx', 'xxoxxoox', 'xxxxxxxx', 'xxxxoxxx', 'xxxooxxx', 'xxxxxxxx', ]>, [ 'xxxxxxxx', 'xxxxoxxx', 'xxooxxxx', 'xxoxxoox', 'xxxxxxxx', 'xxxxoxxx', 'xxxooxxx', 'xxxxxxxx', ]>>, Expect<Equal<GotLifeGame<20, [ 'xxxxxxxx', 'xxoxxxxx', 'xoxoxxxx', 'xoxoxxxx', 'xxoxxxxx', 'xxxxxoox', 'xxxxxoox', 'xxxxxxxx', ]>, [ 'xxxxxxxx', 'xxoxxxxx', 'xoxoxxxx', 'xoxoxxxx', 'xxoxxxxx', 'xxxxxoox', 'xxxxxoox', 'xxxxxxxx', ]>>, Expect<Equal<GotLifeGame<5, [ 'xxxxxxxx', 'xxoxxxxx', 'xxxoxxxx', 'xoooxxxx', 'xxxxxxxx', 'xxxxxxxx', 'xxxxxxxx', 'xxxxxxxx', ]>, [ 'xxxxxxxx', 'xxxxxxxx', 'xxxxxxxx', 'xxoxoxxx', 'xxxooxxx', 'xxxoxxxx', 'xxxxxxxx', 'xxxxxxxx', ]>>, Expect<Equal<GotLifeGame<3, [ 'xxxxxxxx', 'xoxxxoxx', 'xxxxoxxx', 'xxooxxxx', 'xxxxxxxx', 'xxxxxxxx', 'xxxxxxxx', 'xxxxxxxx', ]>, [ 'xxxxxxxx', 'xxoooxxx', 'xxxxxxxx', 'xxoxoxxx', 'xxxoxxxx', 'xxxxxxxx', 'xxxxxxxx', 'xxxxxxxx', ]>>, Expect<Equal<GotLifeGame<2, [ 'xxxxxxxx', 'xxxxxxxx', 'xxoxxxxx', 'xxxoxxxx', 'xxxooxxx', 'xxxxxxxx', 'xxxxxxxx', 'xxxxxxxx', ]>, [ 'xxxxxxxx', 'xxxxxxxx', 'xxxoxxxx', 'xxoxoxxx', 'xxoxoxxx', 'xxxxxxxx', 'xxxxxxxx', 'xxxxxxxx', ]>>, Expect<Equal<GotLifeGame<10, [ 'xxxxxxxx', 'xxxxxxxx', 'xxoxxxxx', 'xxxoxxxx', 'xxxooxxx', 'xxxxxxxx', 'xxxxxxxx', 'xxxxxxxx', ]>, [ 'xxxxxxxx', 'xxxxxxxx', 'xxxxxxxx', 'xxxxxxxx', 'xxxxxxxx', 'xxxxxxxx', 'xxxxxxxx', 'xxxxxxxx', ]>>, ]
The text was updated successfully, but these errors were encountered:
feat(question): add #31893 - 康威生命游戏
1e19e17
#31894 - PR 已更新
Sorry, something went wrong.
d296cbb
f9ff786
Successfully merging a pull request may close this issue.
基本信息
题目
康威生命游戏是一种有意思的游戏。
它的游戏进行在一个方格布上,每个方格或生或死,根据当前的方格布可推断出下一刻方格布的方格排列,推断规则如下:
这个游戏的胜利条件是你开心。只要你看你的方格布看得很开心,你就胜利了。
现在可以在 TS 中表示一盘如此的$8 \times 8$ 康威生命游戏:
其中,
o
表示活着,x
表示死掉了;一个字符串表示一行,数组中有八个字符串表示有八行。LifeGame0
表示一盘进行当中的生命游戏。在本挑战中你不需要考虑边缘外的方格。
现在,希望你能设计一个康威生命游戏的计算器,给定游戏进行的时间和初始的方格布,推算出到时间时的方格布是什么样子。
题目模版
以下是给予挑战者开始做题的代码模版,在大部分情况下你只需要修改类型名称使其符合你的题目与判题测试,实现的部分保持
any
即可。判题测试
请为你的题目提供一些判题测试,你可以使用
@type-challenges/utils
中提供的一些工具进行判断。The text was updated successfully, but these errors were encountered: