上次写的博客,介绍了下刚拿到galileo开发板的时候如何进行折腾。 上次折腾完后,因为我发现galileo本身和一个装着linux的arduino/pc一样,那么用它来实现一些物联网应用会比较简单,又赶上本学期的工程设计课作业,所以初步实现了一个能用微信监测室内温度和拍摄室内照片的小型物联网系统。 参考: 《鼓捣Galileo开发板的一些吐槽》( http://blog.jcix.top/2015-11-04/introduce_galileo/ ) 记录下实现过程。由于本人表述能力较差,采用简述加大量外部连接的方式进行记录。 系统功能 用微信获取室内当前温度或者一张较为实时的照片。 通过亮度传感器自动自动控制LED的亮、灭。 基本结构 系统实现最初的想法,就是让微信公众平台和开发板通过互联网直接进行信息传递,但是因为微信公众平台对我们所搭建服务器采用get和post方法进行通信,所以在没有公网ip的校园网环境,一般只能租云服务器或者VPS进行中转。 这样,系统的基本结构就变成了: 开发板外围<–>Galileo开发板<–>云服务器<–>微信公众平台<–>手机微信<–>用户 可见整个通信链将用户和外围器件连接起来,实现了简单的物联网。

这两道题明显是一对。。。放一起 题目一 Integer to Roman Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. 大意: 就是把一个1~3999的阿拉伯数字,变成罗马数字表示。 题目二 Roman to Integer Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 大意: 就是把一个1~3999的罗马数字,表示成阿拉伯数字。 […]

题目 Write a function to find the longest common prefix string amongst an array of strings. 大意: 写一个函数,找到一组字符串的公共最长前缀。 思路 我的:定义一个不断更新的变量,存储当前的最长前缀,循环时加以一定的优化,比如如果下一个字符串比当前的前缀还长,那么可以截断前缀后在进行比较。 参考的:这道题在discuss上看到了一些运用了python语法的解法,用到了zip,reduce,set等python特有的语法,顺便贴出。 代码 原创(Python): class Solution(object): def longestCommonPrefix(self, strs): “”” :type strs: List[str] :rtype: str “”” if len(strs) == 0: return “” if len(strs) == 1: return strs[0] <!–more–> com_str = list(strs[0]) for i in range(1, […]

题目 Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone buttons) is given below. Input:Digit string “23” Output: [“ad”, “ae”, “af”, “bd”, “be”, “bf”, “cd”, “ce”, “cf”]. Note: Although the above answer is in lexicographical order, your answer could […]

题目 Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. For example, Given [0,1,0,2,1,0,1,3,2,1,2,1], return 6. 大意: 有n个非负整数,代表地势图的高度,如图,计算下雨后这个地形能存多少雨水。 思路 这道题和第10题非常像,分别从最左边和最右边开始,定义两个游标,移动到过程中,记录左边的最大值和右边的最大值,然后用两个最大值中的小值减去地形高度,就是所积的雨水值(类似第10题思路)。 关于两个游标怎么移动的问题,同第10题思路,还是移动当前最大值较小的边,比如:当前右边最大值right_max为10,左边最大值left_max为5,如果移动right_index,那么左边的最大值只能保持不变,不管right_max变不变,两个最大值的较小一个也还会是left_max,没有可能增加积水量,所以可能会存在错误。(详细可结合代码看) 代码 Python class Solution(object): def trap(self, height): “”” :type height: List[int] :rtype: int <!–more–> “”” if […]

这几天折腾伽利略开发板,写下一些吐槽,以便以后再看到这篇博客,仍然能记起这些值得吐槽的地方。。。也希望看到这篇博客的人能够因此少些吐槽( ╯□╰ )。。网上其实是有不少资源的,但是相对其他更热门的板子,显然找资料并不是和喝白开水一样简单,由于我表达能力较差,所以准备采用简述+大量站外链接的形式,给出一个希望不会让人误入歧途的引导。。。 介绍 Intel Galileo(点击查看中文官网),是一个兼容Arduino的x86平台的开源硬件产品。个人感觉应当注意的是,特点就是兼容Arduino和x86,这样我们既能够利用丰富的Arduino软硬件及社区资源,又能够在上边运行linux甚至windows系统,做出更复杂的系统。 相关介绍: 《x86 版的 Arduino 来了,Intel Galileo 开发板的体验、分析和应用【超长文多图】》(http://www.ifanr.com/388835 ) 《系出名門:Intel Galileo的十大特性》(http://www.leiphone.com/news/201406/intel-galileo.html ) (更多请自行百度/google) “Arduino模式” 略(自行百度) Arduino? no,Linux! Galileo可以在SD卡中装入完整版Linux镜像,一旦在装有完整版Linux镜像的SD卡插入时启动,会进入所安装的完整版Linux系统,否则,则会进入烧写入flash的裁剪版微型Linux系统。而只有安装了完整版Linux,Galileo才不仅仅只是一个Arduino。下图为Galileo开机启动过程: 参考: 《x86 版的 Arduino 来了,Intel Galileo 开发板的体验、分析和应用【超长文多图】》(http://www.ifanr.com/388835 )

题目 The string “PAYPALISHIRING” is written in a zigzag pattern on a given >number of rows like this: (you may want to display this pattern in a >fixed font for better legibility) P A H N A P L S I I G Y I R And then read line by line: “PAHNAPLSIIGYIR” Write the […]

题目 Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 大意:就是把数字倒过来。。。 思路和吐槽 只有吐槽:用Python做简直是太简单了,简直就是在作弊,,,如果我十天之内没用c++再做一遍,我肯定是白做了这道题 代码 Python class Solution(object): def reverse(self, x): “”” :type x: int :rtype: int “”” if x < 0: symbol = -1 else: symbol = 1 x = abs(x) str_x = str(x) ans_list = list(str_x) […]