用一系列向外螺旋的元素生成一个正方形的二维矩阵
spiral-matrix的Python项目详细描述
此代码模块上下文中的矩阵是一个python列表,其 元素由许多其他一致的列表组成 就元素数量而言。因此,这个列表结构 形成一个二维网格,一个矩阵,由单个单元格填充。
5x5螺旋矩阵
螺旋矩阵是一种特殊的方形矩阵,其中 每个单元格由一系列元素中的一个值填充。这个 “螺旋矩阵”中的“螺旋”是指每个单元 使用序列中的值逐步填充 符合紧密缠绕螺旋的图案。这个螺旋 从中心细胞开始,向外移动。最终, 整个矩阵都填充了序列中的元素。
5x5包括命令行
本文的其余部分详细介绍了 从命令行执行螺旋矩阵。为了解释 作为Python3.x模块导入时的API用法,请click here。
必需参数
DIMENSION This parameter is an integer value, and is limited to odd numbers only. This count of rows and columns constitute the constructed size of the the square- shaped 2-d matrix. (REQUIRED)
通用选项
沿着顶部和左侧的列和行轴标签可以是 打印输出的前缀。从中心向外 一个指南针方向或方位上的单元格,即东、北、西或 南部,启动螺旋的进程。螺旋可以是 配置为顺时针或逆时针前进 态度。
7x7带轴,轴承:南,中心:1000,步进:-300
--axes This parameter-less option enables or disables the prefixing of column- and row-axes labels along the top- and left-side of the printed output. (default: False) --bearing EAST | NORTH | WEST | SOUTH This compass bearing (E, N, W, or S) specifies the direction that is used to proceed initially outward from the center of the matrix. (default: E) --right This parameter-less option generates a spiral which progresses in a clockwise manner. Not for use with 'left'. (default: not used) --left This parameter-less option generates a spiral which progresses in a counter-clockwise manner, which is the default behavior. Not for use with 'right'. Included for completeness.
整数填充矩阵单元格的默认样式选项
生成的矩阵的默认样式由 以“1”开头,然后每一个以“1”递增的整数 系列元素。这些整数值中的任何一个都可以修改 以更改生成矩阵的单元格内容。任何积极的 或负整数,或零,可以占用中心单元格 这就开始了螺旋。增量整数必须为正或 负,非零整数。
使用以下选项将修改 默认行为。
--center INTEGER This integer value is used to populate the center cell that begins the spiral. (default: 1) --step INTEGER This integer value is used to increment the next cell's value as the spiral progresses from cell to cell. (default: 1)
代币填充矩阵单元替代样式的选项
作为用一系列 递增整数,以空格分隔的文本字符串 可以提供元素或单词标记。这串标记 可能包含任何单词、数字、标点符号的组合, 或者空白。令牌字符串可以从文件或stdin中读取, 或通过命令行参数提供。
5x5带轴,轴承:南,系列:Lorem_ipsum
使用下列任一选项将替换默认值 用一系列的增量填充细胞的行为 整数。
--file FILENAME The specified file should contain some amount of whitespace-delimited text elements. The cells of the matrix are then populated using these elements. Usage of the 'words' option is excluded when using this option. (default: not used) --words [STRING] This string of whitespace-delimited text elements is used to populate the cells of the matrix. When this option is present with no string parameter given, then string is read from stdin. When utilizing stdin for string input, this option needs to be the last option provided on the command-line. Usage of the 'file' option is excluded when using this option. (default: not used)
9x9,螺旋:右,系列:暴风夜
PYPI:https://pypi.python.org/pypi/spiral-matrix
代码回购:https://github.com/zero2cx/spiral-matrix
许可证:GPL3+
文档版本:1.1
修改日期:2018年1月17日
作者:david schenck