英文:
Which Python library would allow me to display certain geometrical shapes based on a set of predefined simple rules
问题
这是一组简单的规则:
应用这组规则后的输出:
请推荐一个简单的Python库或简单的方法,允许我使用Python来计算和可视化这样的计算。
请提供一个适合初学者的、易理解的答案。
1: https://i.stack.imgur.com/UU9YS.png
2: https://i.stack.imgur.com/acQ5S.jpg
英文:
Here is a set of simple rules:
And here is the output once this set of rules has been applied:
Please recommend a simple python library or a simple way that would allow me to use python to calculate and visualize such computations.
Please provide a beginner programmer friendly (easily comprehensible) answer.
答案1
得分: 1
我会使用两个for循环。
外部循环遍历行,内部循环从左到右遍历。
由于我喜欢索引,我会使用所需维度的numpy数组。
用于绘图的话,你可以使用imshow。它直接使用numpy的2D数组。
英文:
I would use two for loops.
The outer loop goes through the lines, the inner loop goes from left to right.
Since I like the indexing I would use numpy arrays of desired dimension.
For plotting you could use imshow. It takes directly the numpy 2D Array.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论