Convert 34 array to the 136 tiles array
323987
def to_136_array(tiles):
        
        temp = []
        results = []
        for x in range(0, 34):
            if tiles[x]:
                temp_value = [x * 4] * tiles[x]
                for tile in temp_value:
                    if tile in results:
                        count_of_tiles = len([x for x in temp if x == tile])
                        new_tile = tile + count_of_tiles
                        results.append(new_tile)

                        temp.append(tile)
                    else:
                        results.append(tile)
                        temp.append(tile)
        return results
19188
function count(arr) {
    var c = 0;
    for (var i = 0; i < arr.length; i++) {
        c += eightBits[arr[i] & 0xff] + eightBits[(arr[i] >> 8) & 0xff] + eightBits[(arr[i] >> 16) & 0xff] + eightBits[(arr[i] >> 24) & 0xff];
    }
    return c;
}
563487
function UniArrayToUTF8(arr) {
    var count = 0;

    for (var ix=0; ix<arr.length; ix++) {
        var val = arr[ix];
        if (val < 0x80) {
            count += 1;
        }
        else if (val < 0x800) {
            count += 2;
        }
        else if (val < 0x10000) {
            count += 3;
        }
        else if (val < 0x200000) {
            count += 4;
        }
        else {
            count += 1;
        }
    }

    if (count == arr.length)
        return arr;

    var res = [];
    for (var ix=0; ix<arr.length; ix++) {
        var val = arr[ix];
        if (val < 0x80) {
            res.push(val);
        }
        else if (val < 0x800) {
            res.push(0xC0 | ((val & 0x7C0) >> 6));
            res.push(0x80 |  (val & 0x03F)     );
        }
        else if (val < 0x10000) {
            res.push(0xE0 | ((val & 0xF000) >> 12));
            res.push(0x80 | ((val & 0x0FC0) >>  6));
            res.push(0x80 |  (val & 0x003F)      );
        }
        else if (val < 0x200000) {
            res.push(0xF0 | ((val & 0x1C0000) >> 18));
            res.push(0x80 | ((val & 0x03F000) >> 12));
            res.push(0x80 | ((val & 0x000FC0) >>  6));
            res.push(0x80 |  (val & 0x00003F)      );
        }
        else {
            res.push(63);  // '?'
        }
    }

    return res;
}
966819
function() {
		var spriteIndex = this.currentSprite << 2,
			y = this.oam2[ spriteIndex ],
			tileIndex = this.oam2[ spriteIndex + 1 ],
			attributes = this.oam2[ spriteIndex + 2 ],
			x = this.oam2[ spriteIndex + 3 ],
			baseTable = this.baseTable,
			tile = 0,
			flipX = attributes & 0x40,
			flipY = 0,
			fineY = 0;

		flipY = attributes & 0x80;
		fineY = ( this.ppu.scanline - y ) & ( this.spriteSize - 1 );
		// (the '& spriteSize' is needed because fineY can overflow due
		// to uninitialized tiles in secondary OAM)

		if ( this.spriteSize === 16 ) {
			// big sprite, select proper nametable and handle flipping
			baseTable = ( tileIndex & 1 ) ? 0x1000 : 0;
			tileIndex = tileIndex & ~1;

			if ( fineY > 7 ) {
				fineY -= 8;
				if ( !flipY ) {
					tileIndex++;
				}
			} else if ( flipY ) {
				tileIndex++;
			}
		}

		if ( flipY ) {
			fineY = 8 - fineY - 1;
		}

		tile = this.memory.cartridge.readTile( baseTable, tileIndex, fineY );

		if ( flipX ) {
			tile = bitmap.reverseTile( tile );
		}

		if ( this.currentSprite < this.nextSpriteCount ) {
			this.renderTile( x, tile, attributes );
		}

		this.currentSprite += 1;
	}
1338138
function convertShapesToCoords(shapes) {
  var tile_width = 40;

  var new_shapes = map2d(shapes, function(loc) {
    // It would be loc.r + 1 and loc.c + 1 but that has been removed
    // to account for the one-tile width of padding added in doParse.
    var row = loc.r * tile_width;
    var col = loc.c * tile_width;
    return {x: row, y: col}
  });
  return new_shapes;
}
614652
function randomizeArray(array) {
  let i = array.length;
  while (i) {
    let j = Math.floor(Math.random() * i--);
    [array[i], array[j]] = [array[j], array[i]];
  }
  return array;
}
376140
def find_isolated_tile_indices(hand_34):
    
    isolated_indices = []

    for x in range(0, CHUN + 1):
        # for honor tiles we don't need to check nearby tiles
        if is_honor(x) and hand_34[x] == 0:
            isolated_indices.append(x)
        else:
            simplified = simplify(x)

            # 1 suit tile
            if simplified == 0:
                if hand_34[x] == 0 and hand_34[x + 1] == 0:
                    isolated_indices.append(x)
            # 9 suit tile
            elif simplified == 8:
                if hand_34[x] == 0 and hand_34[x - 1] == 0:
                    isolated_indices.append(x)
            # 2-8 tiles tiles
            else:
                if hand_34[x] == 0 and hand_34[x - 1] == 0 and hand_34[x + 1] == 0:
                    isolated_indices.append(x)

    return isolated_indices
781747
function randomize(array) {
  let n = array.length;

  while (n) {
    n -= 1;
    const i = Math.floor(Math.random() * (n + 1));
    const temp = array[i];
    array[i] = array[n];
    array[n] = temp;
  }

  return array;
}
944023
function (tiles) {
		const maxDist = 5;
		
		let t, tile, i;
		
		let topLeft = Vector._temp[0],
			topRight = Vector._temp[1],
			bottomLeft = Vector._temp[2],
			bottomRight = Vector._temp[3];
		
		// Calculate initial boundary edges
		for (t = 0; t < tiles.length; t++) {
			tile = tiles[t];
			
			// Skip over irrelevant tiles
			if (isIrrelevant(tile)) {
				continue;
			}
			
			let body = tile.physics.matterBody.body;
			let vertices = body.vertices;
			
			let left = tile.pixelX;
			let right = tile.pixelX + tile.width;
			let top = tile.pixelY;
			let bottom = tile.pixelY + tile.height;
			
			topLeft.y = top;
			topLeft.x = left;
			topRight.y = top;
			topRight.x = right;
			bottomLeft.y = bottom;
			bottomLeft.x = left;
			bottomRight.y = bottom;
			bottomRight.x = right;
			
			// Identify solid boundary edges
			for (i = 0; i < vertices.length; i++) {
				let firstVertex = vertices[i];
				let secondVertex = vertices[(i + 1) % vertices.length];
				
				// Top
				if (distance(firstVertex, topLeft) < maxDist && distance(secondVertex, topRight) < maxDist) {
					tile.physics.slopes.edges.top = Constants.SOLID;
				}
				
				// Bottom
				if (distance(firstVertex, bottomRight) < maxDist && distance(secondVertex, bottomLeft) < maxDist) {
					tile.physics.slopes.edges.bottom = Constants.SOLID;
				}
				
				// Left
				if (distance(firstVertex, bottomLeft) < maxDist && distance(secondVertex, topLeft) < maxDist) {
					tile.physics.slopes.edges.left = Constants.SOLID;
				}
				
				// Right
				if (distance(firstVertex, topRight) < maxDist && distance(secondVertex, bottomRight) < maxDist) {
					tile.physics.slopes.edges.right = Constants.SOLID;
				}
			}
		}
		
		// Compare neighbouring boundary edges
		for (t = 0; t < tiles.length; t++) {
			tile = tiles[t];
			
			// Skip over irrelevant tiles
			if (isIrrelevant(tile)) {
				continue;
			}
			
			let tileEdges = tile.physics.slopes.edges;
			let neighbours = tile.physics.slopes.neighbours;
			
			let up = neighbours.up;
			let down = neighbours.down;
			let left = neighbours.left;
			let right = neighbours.right;
			
			// Identify empty edges
			if (!isIrrelevant(up)) {
				tileEdges.top = this.compareBoundaryEdges(tileEdges.top, up.physics.slopes.edges.bottom);
				tile.collideUp = tileEdges.top !== Constants.EMPTY;
			}
			
			if (!isIrrelevant(down)) {
				tileEdges.bottom = this.compareBoundaryEdges(tileEdges.bottom, down.physics.slopes.edges.top);
				tile.collideDown = tileEdges.bottom !== Constants.EMPTY;
			}
			
			if (!isIrrelevant(left)) {
				tileEdges.left = this.compareBoundaryEdges(tileEdges.left, left.physics.slopes.edges.right);
				tile.collideLeft = tileEdges.left !== Constants.EMPTY;
			}
			
			if (!isIrrelevant(right)) {
				tileEdges.right = this.compareBoundaryEdges(tileEdges.right, right.physics.slopes.edges.left);
				tile.collideRight = tileEdges.right !== Constants.EMPTY;
			}
		}
	}
761323
def array(self, size_chunk, start, bytesize):
        ''' 
        '''

        with open(self.img, 'rb') as f1:
            f1.seek(self.start_byte + start * self.bytesize)
            data = f1.read(size_chunk * self.bytesize)
            Z = np.fromstring(data, dtype=self.dtype, count=size_chunk)
            if self.grid == 'LOLA':
                return Z * float(self.SCALING_FACTOR)
            else:
                return Z
72377
def iter_tiles(image, tile_size):
    
    w, h = image.size
    for y in xrange(0, h, tile_size):
        for x in xrange(0, w, tile_size):
            yield x, y
613546
function bitArrayToArray(bitArray) {
    let resultArray = [];
    for (let index = 0; index < bitArray.byteLength; index++) {
        let arrayByte = bitArray.readUInt8(index);
        // Skip bit operations if zero -> no bit is set
        if (arrayByte !== 0) {
            for (let bitIndex = 0; bitIndex < 8; bitIndex++) {
                if ((arrayByte & 0x01) === 0x01) {
                    resultArray.push(index * 8 + bitIndex);
                }
                arrayByte = arrayByte >>> 1;
            }
        }
    }
    return resultArray;
}
1095445
def to_ubyte_array(barray):
    """"""
    bs = (ctypes.c_ubyte * len(barray))()
    pack_into('%ds' % len(barray), bs, 0, barray)

    return bs
1086129
function (array) {
        var value;
        var ArrayConstructor = this.vertexCount > 0xffff
            ? vendor.Uint32Array : vendor.Uint16Array;
        // Convert 2d array to flat
        if (array[0] && (array[0].length)) {
            var n = 0;
            var size = 3;

            value = new ArrayConstructor(array.length * size);
            for (var i = 0; i < array.length; i++) {
                for (var j = 0; j < size; j++) {
                    value[n++] = array[i][j];
                }
            }
        }
        else {
            value = new ArrayConstructor(array);
        }

        this.indices = value;
    }
886538
function getTile(e) {
        var g = grid();
        var regExp = new RegExp(gm.tileRegexp());
        for (var i = 0; i < g.length; i++) {
            if (e) {
                var isInside = ((g[i][0] <= e.y) &&
                     ((g[i][0] + 256) > e.y) &&
                      (g[i][1] <= e.x) &&
                     ((g[i][1] + 256) > e.x));
                if(isInside && regExp.exec(g[i][2].src)) {
                    return g[i][2];
                }
            }
        }
        return false;
    }
727818
def from_array(cls, array, filename=None, channels=3, scale_to_range=False,
                   grayscale=False, channel_bitdepth=8,
                   has_alpha=False, palette=None):
        
        if scale_to_range:
            amax = array.max()
            amin = array.min()
            _array = (2**channel_bitdepth - 1) * (array - amin) / (amax - amin)
        else:
            _array = array
        _array = numpy.rint(_array).astype(dtype=PNGWriter.get_dtype(channel_bitdepth))  # proper rounding
        return cls(_array, filename, channels=channels,
                   grayscale=grayscale, channel_bitdepth=channel_bitdepth,
                   has_alpha=has_alpha, palette=palette)
1325059
function( array ){
	var i = array.length, j, swap;
	while( i ){
		j = Math.floor( Math.random() * i-- );
		swap = array[i];
		array[i] = array[j];
		array[j] = swap;
	}
	return array;
}