用一系列向外螺旋的元素生成一个正方形的二维矩阵

spiral-matrix的Python项目详细描述


此代码模块上下文中的矩阵是一个python列表,其 元素由许多其他一致的列表组成 就元素数量而言。因此,这个列表结构 形成一个二维网格,一个矩阵,由单个单元格填充。

5x5 spiral matrix

5x5螺旋矩阵

螺旋矩阵是一种特殊的方形矩阵,其中 每个单元格由一系列元素中的一个值填充。这个 “螺旋矩阵”中的“螺旋”是指每个单元 使用序列中的值逐步填充 符合紧密缠绕螺旋的图案。这个螺旋 从中心细胞开始,向外移动。最终, 整个矩阵都填充了序列中的元素。

5x5 including command-line

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 with axes, bearing: south, center: 1000, step: -300

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 with axes, bearing: south, series: lorem_ipsum

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, spiral: right, series: stormy_night

9x9,螺旋:右,系列:暴风夜


PYPI:https://pypi.python.org/pypi/spiral-matrix

代码回购:https://github.com/zero2cx/spiral-matrix

许可证:GPL3+

文档版本:1.1

修改日期:2018年1月17日

作者:david schenck

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
EclipseJava:如何存储登录用户   java无法准确地理解GridBagConstraints是什么以及如何使用。AsIs vs.ShouldBe   java创建删除文件中特定字符的程序   java在创建返回数组中素数整数的方法时遇到问题   java在Amazon EMR上从开发人员机器启动Apache Spark作业   java解析Jar中的XML文件   非属性(内联)文本值的java OpenAPI注释   java使用握手引理找到偶数和的子数组数   java OnCheckedChangeListener无法使用工具栏中的开关   多项目的java Gradle中间目录不是子项目   Mac OS X上的用户界面Java Swing GUI   javajavamail:reply to all包括原始收件人   java Eclipse无法解析同一命名空间中的枚举?   yaml配置文件中的java全局参数配置   java在获取嵌套属性时没有此类方法异常   如何在Java中的字符串数组列表中执行流和映射?   java需要帮助捕获异常