##  改为z型字符串
def change_to_z(s,n):
    ## 字符串不能生成完整的区,用空格补全
    b=len(s)%(2*n-2)
    if b!=0:
        s+=' '*(n*2-2-b)
    a=len(s)//(2*n-2)
    lz=[]
    ##  不同的层
    for i in range(n):
        lg=[]
        ##完整的区
        for j in range(a):
            if i==0 or i==n-1:
                l=s[(2*n-2)*j+i]+' '*(n-1)
            else:
                l=s[(2*n-2)*j+i]+' '*(n-i-1)+s[(2*n-2)*j+2*n-i-2]+' '*(i-1)
            lg.append(l)
        lz.append('#'+''.join(lg))
    return '#\n'.join(lz)+'#'    
    
s='12345678'*10
print(change_to_z(s,7))

leetcode python 006的更多相关文章

  1. Leetcode Python Solution(continue update)

    leetcode python solution 1. two sum (easy) Given an array of integers, return indices of the two num ...

  2. LeetCode python实现题解(持续更新)

    目录 LeetCode Python实现算法简介 0001 两数之和 0002 两数相加 0003 无重复字符的最长子串 0004 寻找两个有序数组的中位数 0005 最长回文子串 0006 Z字型变 ...

  3. [LeetCode][Python]Container With Most Water

    # -*- coding: utf8 -*-'''https://oj.leetcode.com/problems/container-with-most-water/ Given n non-neg ...

  4. LeetCode Python 位操作 1

    Python 位操作: 按位与 &, 按位或 | 体会不到 按位异或 ^ num ^ num = 0 左移 << num << 1 == num * 2**1 右移 & ...

  5. 【leetcode❤python】Sum Of Two Number

    #-*- coding: UTF-8 -*- #既然不能使用加法和减法,那么就用位操作.下面以计算5+4的例子说明如何用位操作实现加法:#1. 用二进制表示两个加数,a=5=0101,b=4=0100 ...

  6. [Leetcode][Python]56: Merge Intervals

    # -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 56: Merge Intervalshttps://oj.leetcode. ...

  7. [Leetcode][Python]55: Jump Game

    # -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 55: Jump Gamehttps://leetcode.com/probl ...

  8. [Leetcode][Python]54: Spiral Matrix

    # -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 54: Spiral Matrixhttps://leetcode.com/p ...

  9. [Leetcode][Python]53: Maximum Subarray

    # -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 53: Maximum Subarrayhttps://leetcode.co ...

随机推荐

  1. C#:进程

    using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using S ...

  2. Unity之配置转换工具

    本人写的配置转换工具,可将策划的配置excel文件一键转换为unity的asset文件或lua代码: 转换请注明出处:http://www.cnblogs.com/jietian331/p/86252 ...

  3. C#-----字节数组(byte[])和字符串相互转换

       Encoding类  表示字符编码 1.字符串转换成字节数组byte[] using System; using System.Collections.Generic; using System ...

  4. ubuntu apache 配置虚拟主机 与 二级域名

    一.ubuntu 配置虚拟主机 方法一:添加端口号 第一步进入 /etc/apache2/sites-available/ 目录,将 000-default.conf 复制一份到当前目录下并重命名,然 ...

  5. JavaScript 神奇的参数

    JS函数的参数,和其他语言区别非常大.它不在乎你传过来多少个参数,也不在乎传过来的参数是什么类型.即使你定义的函数只接受两个参数,你调用这个函数的时候可以传递一个.三个甚至不传参数.这是因为JavaS ...

  6. Missing library: xdoclet-1.2.1.jar.如何解决?

    去这里下载xdoclet-bin-1.2.1.zip http://sourceforge.net/projects/xdoclet/files/xdoclet/1.2.1/ 解压出来,比如解压到C: ...

  7. idea软件快速设置主题颜色

    打开idea,然后在File->setting->在搜索框里面输入theme->然后点击appearance->将theme的主题设置为IntellilJ,然后就可以了,如下图 ...

  8. zabbix 乱码问题

    一.乱码原因 查看cpu负载,中文乱码如下 这个问题是由于zabbix的web端没有中文字库,我们最需要把中文字库加上即可 二.解决zabbix乱码方法 2.1 上传字体文件到zabbix中 找到本地 ...

  9. php 根据日期获取星座

    根据日期获取星座 /* * * 获取星座 * 星座是按阳历来计算的 * $month 阳历月份 * $day 阳历日期 * */ public static function get_xingzuo( ...

  10. 5、Spring-Kafka3

    3. Introduction This first part of the reference documentation is a high-level overview of Spring fo ...