# Principle_of_Computing Assignment 1: 2048_Merge

"""
Merge function for 2048 game.
"""

def merge(line):
"""
Function that merges a single row or column in 2048.
"""
aline=[]
for i in range(len(line)):
if line[i]!=0:
aline.append(line[i])
n=len(line)-len(aline)
i=1
while i<=len(aline)-1:
if aline[i-1]==aline[i]:
aline[i-1]=aline[i-1]*2
aline[i]=0
i=i+2
else:
i=i+1
for i in range(len(aline)):
if aline[i]==0:
j=i
while j<len(aline)-1:
aline[j]=aline[j+1]
j=j+1
aline[len(aline)-1]=0
n=len(line)-len(aline)
if n>0:
for i in range(n):
aline.append(0)
return aline

#### R Programming Assignment 1

2016-06-11 12:55:06

#### Programming Assignment 1: Percolation代码

2014-05-13 16:02:06

#### My solution to cs224n assignment1(3-4)

2017-08-29 11:38:26

#### Qt解决：warning : Z-order assignment

2017-09-24 09:10:54

#### My solution to cs224n assignment1(1-2)

2017-08-29 09:54:17

#### （国外大学作业解答）Java assignment1

2014-02-20 20:28:20

#### coursera算法课 Programming Assignment 1:Percolation

2017-02-27 18:36:06

#### cs224n assignment 2 代码

2017-08-17 20:42:02

#### 对常用术语进一步理解，比如赋值（assignment）

2010-12-05 15:03:00