##  改为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. nginx----------linux下nginx环境搭建遇到的一些问题汇总(多域名配置,配置文件修改问题)

    一.启动 cd usr/local/nginx/sbin ./nginx 二.重启 更改配置重启nginx kill -HUP 主进程号或进程号文件路径 或者使用 cd /usr/local/ngin ...

  2. Mysql关于时间排序的问题

    SELECT * FROM table_name WHERE deleted = 0 order by create_time DESC 当用户使用DESC(降序时),最终得到的结果集,时间早的在前面 ...

  3. 看懂MSSQL执行计划,分析SQL语句执行情况

    打开SQL执行计划窗口 执行计划的图表是从右向左看的 SQL Server有几种方式查找数据记录 [Table Scan] 表扫描(最慢),对表记录逐行进行检查 [Clustered Index Sc ...

  4. Object类型的转为String类型

    Map<String, Object> scaleMap = new HashMap(): scaleMap.put("name","张三"); S ...

  5. 01:open-falcon入门篇

    open-falcon其他篇 目录: 1.1 openfalcon介绍 1.2 open-falcon架构 1.1 openfalcon介绍返回顶部   openfalcon官网: https://b ...

  6. 复旦大学2016--2017学年第二学期(16级)高等代数II期末考试第六大题解答

    六.(本题10分)  设 $A$ 为 $n$ 阶半正定实对称阵, $S$ 为 $n$ 阶实反对称阵, 满足 $AS+SA=0$. 证明: $|A+S|>0$ 的充要条件是 $r(A)+r(S)= ...

  7. vue脚手架的目录结构

    . |-- build // 项目构建(webpack)相关代码 | |-- build.js // 生产环境构建代码 | |-- check-version.js // 检查node.npm等版本 ...

  8. sublime汉化

    1.打开sublime使用快捷键 shift+ctrl+p调出package control; 2.键入Package Control:install package 会弹出一个输入框,然后再搜索lo ...

  9. 【虚拟机】解决网络适配器没有 VirtualBox Host-Only Ethernet Adapter 问题

    下面以windows系统来演示重新安装 VirtualBox Host-Only Ethernet Adapter的方法 1.“win+r”输入“devmgmt.msc”,出现如下界面: 2.点击菜单 ...

  10. Vs10.设置.高亮(20190327)

    ZC:(20190327)只要使用的是 "Highlight all occurrences of selected word" 和 "Visual Assist X&q ...