CSDN daily practice: ghost drawing talisman point big array

CSDN daily practice: ghost drawing talisman point big array

topic description

Topic name: Ghost Drawing Talisman Gate: Dot Array
Time Limit: 1000ms
Memory Limit: 256M

Title description
Xiaoyi is a student of the ghost painting talisman school, but because of his poor academic skills, he can only draw a little bit of big array. One day, the master asked Xiaoyi to draw more key point formations, and the master would give Xiaoyi the 1st point point formation. If Xiaoyi needs to complete the 2nd point point formation, then she needs to regard the 1st point point formation as a whole as a whole. A point in the big array. Xiaoyi wants you to help draw one first.

Input description:
Input the side length a of the dot array, and the number of layers n of the dot array. (1<=a^n<=1000) Enter a character '*' or ' ' in each line of the following a line.

Output description:
output a large array of dots.

Example
Example 1
Input

3 2
***
*
***

output

*********
*  *  *
*********
***
*
***
*********
*  *  *
*********

topic logic

this subject. . . . It's not difficult until it's done. Before it's done, I can't figure out what kind of logic this question is.

In the end, it was Lao Gu who had a 50% pass rate by accident and realized his logic

1. The large array of one key point is fixed, and the number of layers and length are consistent (the input description is very important, if you miss it, you will make a mistake), that is, if the input value is a, then a ** 2 points are needed, or empty, or as a star.
2. No matter how many layers there are, the asterisks of each dot array can only be replaced with 1 layer of dot array (if it is recursive expansion, Lao Gu tried it, and it took 3 minutes for the 5th layer array to come out)
3 , When outputting the array at the end, be sure to remove the space on the right of each line!
4. When outputting the array at the end, be sure to remove the space on the right of each line!
5. When outputting the array at the end, be sure to remove the space on the right of each line!
6. The input part in python must be taken over, modify the input().strip()!

So when it comes to this, everyone should understand that this topic is the same as the method used by Lao Gu in the article "Python Basics Series: 6. Use * to make a digital lattice ". Put an asterisk, Turn it into a two-dimensional list with multiple rows and multiple columns, and then flip it back.

Hey, in short, there are actually a lot of pitfalls in this topic, and finally let old Gu Meng come out, especially the content given by default, there is a strip in his data processing to remove spaces, this is a sinkhole! In case there should be a space before the asterisk on one level, if you strip it, it is impossible to get the correct content anyway.

Lao Gu's Submission

import copy

def change(n):
    if n < 2:
        return copy.deepcopy(first)
    ans = change(n - 1)
    rows = len(ans)
    z = []
    for i in range(rows):
        for ii in range(a):
            z.append([])
            for j in range(len(ans[i])):
                if ans[i][j] == '*':
                    z[-1] += copy.deepcopy(first[ii])
                else:
                    z[-1] += copy.deepcopy(blank[ii])
    return z

a,n = map(int,input().split())
vector = []
for i in range(a):
    vector.append(input().rstrip())
first = [list(row.ljust(a)) for row in vector]
blank = [list(' '.ljust(a)) for row in vector]

print("\n".join([''.join(row).rstrip() for row in change(n)]))

insert image description here

CSDN topic features: reading comprehension

Every time he encounters this kind of problem, Lao Gu will always have various dyslexia and can't understand. Just like today, um, April 9, 23, the 44th session of the csdn weekly competition, the programming questions are actually not difficult, the difficulty lies in how to understand the thinking of the person who made the question, and adjust the thinking to the question through limited words and conditions people's channel.

insert image description here

Similar triangles are two or more triangles whose sides correspond to the same proportions. Please remove those that cannot form a triangle according to the lengths of the three sides entered, and only keep the frontmost one of the similar triangles.

It's a damn subject. . . The other questions were completed in 5 minutes according to Lao Gu's speed. As a result, this question took 40 minutes. I didn't want to understand the idea of ​​the person who wrote the question. Finally, I handed in the paper and found that someone in the bug area said: 3 4 5 this The triangle and the triangle 5 4 3 are not similar triangles. . . .
insert image description here

As a person who has been partial to subjects since childhood and drifted near the passing line in Chinese, it is really the most difficult thing in the exam. Not to mention this outrageous description. I am the most serious person, I will not add conditions that are not given, otherwise, as Party B, Party A can spray you to death at any time!

summary

All in all, all in all, the csdn test is not about algorithms, but about reading comprehension and conditional completion. . .

I want to pull the topic selection personnel to sacrifice to heaven again!

insert image description here

Guess you like

Origin blog.csdn.net/superwfei/article/details/130042190