abacus 原

ludlows

``````#########################################################################
#                 10-row School abacus
#                         by
#                      Michael H
#########################################################################
#       Description partially extracted from from wikipedia
#
#  Around the world, abaci have been used in pre-schools and elementary
#
# In Western countries, a bead frame similar to the Russian abacus but
# with straight wires and a vertical frame has been common (see image).
# Helps schools as an aid in teaching the numeral system and arithmetic
#
#         |00000*****   |     row factor 1000000000
#         |00000*****   |     row factor 100000000
#         |00000*****   |     row factor 10000000
#         |00000*****   |     row factor 1000000
#         |00000*****   |     row factor 100000
#         |00000*****   |     row factor 10000
#         |00000*****   |     row factor 1000
#         |00000****   *|     row factor 100     * 1
#         |00000***   **|     row factor 10      * 2
#         |00000**   ***|     row factor 1       * 3
#                                        -----------
#                             Sum                123
#
# Each row represents a different row factor, starting with x1 at the
# bottom, ascending up to x1000000000 at the top row.
######################################################################

# Define a procedure print_abacus(integer) that takes a positive integer
# and prints a visual representation (image) of an abacus setup for a
# given positive integer value.
#
# Ranking
# 1 STAR: solved the problem!
# 2 STARS: 6 < lines <= 9
# 3 STARS: 3 < lines <= 6
# 4 STARS: 0 < lines <= 3

def print_abacus(value):
outstr = "00000*****"
for i in "0"*(10-len(str(value)))+str(value):
print "|"+outstr[:10-int(i)]+"   "+outstr[10-int(i):]+"|"

###  TEST CASES
print "Abacus showing 0:"
print_abacus(0)
#>>>|00000*****   |
#>>>|00000*****   |
#>>>|00000*****   |
#>>>|00000*****   |
#>>>|00000*****   |
#>>>|00000*****   |
#>>>|00000*****   |
#>>>|00000*****   |
#>>>|00000*****   |
#>>>|00000*****   |
print "Abacus showing 12345678:"
print_abacus(12345678)
#>>>|00000*****   |
#>>>|00000*****   |
#>>>|00000****   *|
#>>>|00000***   **|
#>>>|00000**   ***|
#>>>|00000*   ****|
#>>>|00000   *****|
#>>>|0000   0*****|
#>>>|000   00*****|
#>>>|00   000*****|
print "Abacus showing 1337:"
print_abacus(1337)
#>>>|00000*****   |
#>>>|00000*****   |
#>>>|00000*****   |
#>>>|00000*****   |
#>>>|00000*****   |
#>>>|00000*****   |
#>>>|00000****   *|
#>>>|00000**   ***|
#>>>|00000**   ***|
#>>>|000   00*****|
mm=raw_input("yahdhkjajdahd")``````

ludlows

101个LINQ例子

101 LINQ Samples 说明：本文摘抄自Microsoft的MSDN网站，因为原文不方便快速阅读和学习，故此调整如下。本文所有权利归Microsoft公司所有。如果您觉得本文侵犯了您的著作权，请来信告知，我...

2012/10/23
254
0
Linux系统下三款常用的网络安全工具简介

zt371
2009/05/07
707
0

abacus 是一个扩展性良好的小型计算器，得名于中国古代著名的计算工具----算盘，目前版本 2。支持四则混合运算、支持符号常量、支持变量参与运算、支持众多的数学函数、并可以把自己常用的公...

zhcosin
2013/01/28
1.2K
0
Android将会有无密码登录功能，你信吗？

linuxprobe
2016/06/12
0
0
Linux操作系统下的网络安全工具详细介绍

2009/05/07
287
0

AI复原上海民国名媛影像！1929年的小姐姐，时装精致不输现在

22
0
【脑电硬件】教育相关的商业可穿戴脑电设备概览

17分钟前
25
0

25分钟前
51
0

Kubernetes

23
0
2020年7月Github上最热门的开源项目

7月份GitHub上最热门的开源项目排行已经出炉啦，一起来看看上榜详情吧 1 tsunami-security-scanner https://github.com/google/tsunami-security-scannerStar 5830 tsunami-security-scanne...

14
0