CECV demo has been deployed on Heroku. The Demo link is here
What is CECV?
CECV is a web application to convert cryptocurrency energy consumption data into graphs and present them in a intuitive and interactive way. In CECV, we present two data sets including the BECI (Bitcoin Energy Consumption Index) and EECI (Ethereum Energy Consumption Index).
According to the BECI from Digiconomist, the peak value of the annual electricity consumption reached 77.782TWh, which is comparable to the power consumption of Chile. Besides, the generated annual carbon footprint is nearly 36.95 Mt of carbon dioxide, comparable to the carbon footprint of New Zealand. Moreover, the electricity consumption of a single transaction is 761.93 kWh, which is close to the energy consumption of 700,000 VISA payments and is equivalent to the 20-day average electricity consumption of American households, and the e-waste generated by each transaction is 101.10 grams.
As for the EECI, the annual total electrical energy consumption of Ethereum is 11.89 TWh, which is comparable to the power consumption of Uruguay, and the footprint per single transaction is 29.44 kWh, equivalent to the power consumption of an average U.S. household over 0.99 days.
funcmin(A int, B int)int { if A < B { return A } else { return B } }
funcmaxArea(height []int)int { size := len(height) left, right := 0, size-1 max := 0 for { if left >= right { break } dis := min(height[left], height[right]) * (right - left) if max < dis { max = dis } if height[left] <= height[right] { left += 1 } elseif height[left] > height[right] { right -= 1 } } return max }
functhreeSumClosest(nums []int, target int)int { sort.Ints(nums) diff := math.MaxInt64 var l, r, val, dis, res int for i := 0; i < len(nums)-2; i++ { l = i + 1 r = len(nums) - 1 for { if l >= r { break } val = nums[i] + nums[l] + nums[r] dis = int(math.Abs(float64(val - target))) if dis == 0 { return target } elseif diff > dis { diff = dis res = val }
if val < target { l++ } else { r-- } } } return res }
funcfourSum(nums []int, target int) [][]int { ans := make([][]int, 0, 10) if nums == nil || len(nums) < 4 { return ans } sort.Ints(nums) fmt.Println(nums) for i := 0; i < len(nums); i++ { if i > 0 && nums[i] == nums[i-1] { continue } tmp := target - nums[i] for j := i + 1; j < len(nums)-2; j++ { if j > i+1 && nums[j] == nums[j-1] { continue } tmp1 := tmp - nums[j] left, right := j+1, len(nums)-1 for { if left >= right { break }
if nums[left]+nums[right] == tmp1 { ans = append(ans, []int{nums[i], nums[j], nums[left], nums[right]}) for { left += 1 if left < right && nums[left] == nums[left-1] { continue } else { break } }
for { right -= 1 if left < right && nums[right] == nums[right+1] { continue } else { break } } } elseif nums[left]+nums[right] < tmp1 { for { left += 1 if left < right && nums[left] == nums[left-1] { continue } else { break } } } elseif nums[left]+nums[right] > tmp1 { for { right -= 1 if left < right && nums[right] == nums[right+1] { continue } else { break } } }
}
} } return ans }
Leetcode 35. Search Insert Position
查找有序插入的位置,水题
1 2 3 4 5 6 7 8 9 10
funcsearchInsert(nums []int, target int)int { for i := 0; i < len(nums); i++ { if nums[i] == target || nums[i] > target { return i } elseif nums[i] < target && i < len(nums) - 1 && nums[i+1] > target { return i + 1 } } returnlen(nums) }
Leetcode 41. First Missing Positive
Note: Your algorithm should run in O(n) time and uses constant extra space.
funccanJump(nums []int)bool { index := 0 max_index := nums[0] for index <= max_index && index < len(nums) { if index+nums[index] > max_index { max_index = index + nums[index] } index += 1 } if index == len(nums) { returntrue } else { returnfalse } }
funcgenerateMatrix(n int) [][]int { matrix := make([][]int, n) for i := range matrix { matrix[i] = make([]int, n) } if n <= 0 { return matrix } index := 1 for i := 0; i < (n-1)/2+1; i++ { row := i col := i for col < n-i { //右移 matrix[row][col] = index index++ col++ } col-- for row = i + 1; row < n-i; row++ { //下移 matrix[row][col] = index index++ } row-- for col = n - i - 2; col > i; col-- { //左移 matrix[row][col] = index index++ } for row = n - i - 1; row > i; row-- { //上移 matrix[row][col] = index index++ } } return matrix }
funcsetZeroes(matrix [][]int) { var first_row, first_col bool = false, false
//首行首列判断 for i := range matrix { if matrix[i][0] == 0 { first_col = true } } for j := range matrix[0] { if matrix[0][j] == 0 { first_row = true } }
//判断值存储 for i := range matrix { for j := range matrix[0] { if matrix[i][j] == 0 && i != 0 && j != 0 { matrix[i][0] = 0 matrix[0][j] = 0 } } } //非首行首列赋值 for i := range matrix { if matrix[i][0] == 0 && i != 0 { for j := range matrix[0] { matrix[i][j] = 0 } } } for j := range matrix[0] { if matrix[0][j] == 0 && j != 0 { for i := range matrix { matrix[i][j] = 0 } } } //首行首列赋值 if first_row { for j := range matrix[0] { matrix[0][j] = 0 } } if first_col { for i := range matrix { matrix[i][0] = 0 } } }
本模型训练的环境为: Linux 3.10 + Python 3.5.2 + Tensorflow-gpu 1.4.0 + Darkflow + CUDA 8.0 + CUDNN 6.0 + Opencv 3.4.1
安装Opencv
1 2 3 4 5 6 7 8 9 10 11
$ sudo pip3 install opencv-python
#验证安装 [squarepants@root ~]$ python3 Python 3.5.2 (default, Jun 5 2018, 03:54:30) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux Type "help", "copyright", "credits" or "license"for more information. >>> import cv2 >>> cv2.__version__ '3.4.1' >>>
Hello from Docker! This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal.
To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/
For more examples and ideas, visit: https://docs.docker.com/engine/userguide/