我只想说,我操!



我只想说,我操!, originally uploaded by herock.

原来站点违规被封是这个样子的。

Zoho Writer开始支持用户自定义CSS

早上看到Zoho Blogs中 Insert Stylesheets in Zoho Writer。真不错。

这是我一直很期待的功能,曾经在Zoho的论坛上提出过,主要是把它当作Blog或者其他网页编辑器的时候,能够基本上“所见即所得”:

Could each of my document appears with my own CSS file?
The CSS file could be updated to Zoho or just a web file link.
So I can use these CSS files as the real template for documents.
If styles could be automatic import from Workpress/ Blogger template of user’s site, the Zoho Writer would be a perfect front end of bloggers.

很快得到回应:

Great suggestion. We will work on it, and try and get it out as quickly as possible.

Thanks,
Sridhar

起码说明了他们的研发团队是热情有活力的,于是从此我开始从Writely转向Zoho。虽然Writely的后台比较硬。

大体上认为Zoho比Writely好在以下的功能上吧:

  • 不开新的窗口。
  • 分级(Heading1..)和Style比较好用。
  • 有版本控制。
  • 再就是自定义CSS了。
  • 所以,现在用Zoho Writer来做Blog的前端,是很合适不过了。也许逐渐就会变成在线的Dreamweaver。

四色立方体问题

Davies大侠那里看到这个问题。这个问题是Thumbjive招聘工程师时要求随简历要一同提交。去年春天我还没毕业时,也解了这个问题,并且去Thumbjive面试了。当时也是用Python解的,面试我的法国工程师还很高兴我懂Python这个东西。实际上当时刚刚接触Python,现在看起来当时写的代码,实在是太不Python style了。

参考Davies的解法,总结一下这个问题的解决过程。

原题在Thumbjive网站的招聘页面中。

You have four colored cubes. Each side of each cube is a single color, and there are four colors: blue (B), red (R), green (G) and yellow (Y) Describing the six faces as front, back, left, right, top, bottom, the cube colors are:

Cube
Front
Back
Left
Right
Top
Bottom
1
R
B
G
Y
B
Y
2
R
G
G
Y
B
B
3
Y
B
R
G
Y
R
4
Y
G
B
R
R
R

The objective is to find ways to stack the four cubes as a vertical column so that each side of the column is showing all four colors.

有四个立方体,每个有六个面,涂上了四种颜色。要求摞成一个长条,并使其四个侧面都有四种不同的颜色。

我想这里主要要解决两个事情:

  1. 立方体的表示。包括对其运动(旋转)的描述。并且要有一个描述立方体所有可能位置的集合,很容易看出每个立方体有24种可能的位置。
  2. 对四个立方体所有可能位置进行排列,找出满足要求的排列。

对于1,Davies定义了两个立方体的动作,侧面转一圈和翻个。 然后汇成一个角的三个面作为初始状态,分别翻个,转一圈。正好得到了24种可能位置。比我当时考虑的强,我定义了x,y轴两个方向的旋转,并且用这两个动作连续旋转立方体,虽然能遍历所有的状态,但是显然有冗余。

我定义的旋转遍历:


# a serial of cube rotation
# make sure that the cube placed in all possible position
all_seq = [2,1,1,1,1, # following with 4 transform 1 means unchanged
2,1,1,1,1,
2,1,1,1,1,
2,1,1,1,1, # no position change
1,2,
1,1,1,1,
1,1,
1,1,1,1]

对于2,Davies枚举了所有可能排列,应该是一种宽度优先算法吧。如果只要求得到一个解,而不给出所有解的前提下,深度优先搜索能更快。不过我原来的脚本写得太滥了,运行速度明显慢很多。于是在他的脚本基础上,我写了个深度优先的算法solve2,可以代替Davies的solve来用。


def solve2(belows, aboves=[[]]):
”’ 060805, charlie, depth first solution ”’
belows = [b for b in belows] # copy object as a ‘pass-by-value’ argu of function
nodes = combine(aboves, turn(belows.pop(0)))
if not nodes: return False
if not belows: return nodes # all cubes placed
return reduce( lambda x,n: x or solve2(belows, [n]),
nodes , False )

实际效果上也没快多少,可能是搜索树的深度比较浅,没啥效果吧。

另外有写得不好的地方,就是搞不懂pass-by-value传参应该怎么弄比较好;和找不到一个代替逻辑运算符or的函数, 只好lambda了一个。

最后贴一下去年我写的脚本,不值得一看,权且留念。

(more…)

Random posts

  • Test Zoundry
  • 备份一套可运行的Windows XP
  • 牌匾
  • 我的1997和2007
  • 在线化学结构式图片生成服务