COMP9021 PRINCIPLES OF PROGRAMMING - quiz 6


  • 作业标题:COMP9021 - PRINCIPLES OF PROGRAMMING - quiz 6
  • 课程名称:University of New South Wales COMP9021 PRINCIPLES OF PROGRAMMING
  • 完成周期:3天

描述

# Randomly generates a grid with 0s and 1s, whose dimension is controlled
# by user input, as well as the density of 1s in the grid, and finds out,
# for given step_number >= 1 and step_size >= 2, the number of stairs of
# step_number many steps, with all steps of size step_size.
#
# A stair of 1 step of size 2 is of the form
# 1 1
# 1 1
#
# A stair of 2 steps of size 2 is of the form
# 1 1
# 1 1
# 1 1
#
# A stair of 1 step of size 3 is of the form
# 1 1 1
# 1
# 1 1 1
#
# A stair of 2 steps of size 3 is of the form
# 1 1 1
# 1
# 1 1 1
# 1
# 1 1 1
#
# The output lists the number of stairs from smallest step sizes to largest
# step sizes, and for a given step size, from stairs with the smallest number
# of steps to stairs with the largest number of stairs.

sample output

$ python3 quiz_6.py
Enter three positive integers: 0 1 2
Here is the grid that has been generated:
1 1
0 1

$ python3 quiz_6.py
Enter three positive integers: 0 1 3
Here is the grid that has been generated:
1 1 0
1 1 1
1 1 1

For steps of size 2, we have:
2 stairs with 1 step

。。。


文章作者: IT神助攻
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 IT神助攻 !
  目录