<commit_before>"""
	Addition:
	Input: a base b, a length n, and two positive n digit integers X and Y. 
	Intermediate variable: c, the carry. 
	Output: an integer Z represented by its digits such that Z = X + Y, or an error if X + Y cannot
		be represented as an n digit, base b integer. 
"""

import math
import random

def addition(b, n, X, Y):
	c = 0
	Z = []
	for i in range(0, n):
		s = X[i] + Y[i] + c
		Z.append(s%b)
		c = math.floor(s/b)
	if c != 0:
		Z.append(c)
	return Z

if __name__ == "__main__":
# A test case
	b = 10
	n = 30
	X = [random.randrange(0, 10) for i in range(0, n)]
	Y = [random.randrange(0, 10) for i in range(0, n)]
	print "X: ", X
	print "Y: ", Y
	Z = addition(b, n, X, Y)
	print "Z: ", Z
<commit_msg>1.4: Modify the output format.<commit_after>"""
	Addition:
	Input: a base b, a length n, and two positive n digit integers X and Y. 
	Intermediate variable: c, the carry. 
	Output: an integer Z represented by its digits such that Z = X + Y, or an error if X + Y cannot
		be represented as an n digit, base b integer. 
"""

import math
import random

def integer_value(b, n, d_list):
	v = 0
	for i in range(n-1, -1, -1):
		v = v*b + d_list[i]
	return v

def addition(b, n, X, Y):
	c = 0
	Z = []
	for i in range(0, n):
		s = X[i] + Y[i] + c
		Z.append(s%b)
		c = math.floor(s/b)
	if c != 0:
		Z.append(c)
		i += 1
	i += 1
	return Z, i

if __name__ == "__main__":
# A test case
	b = 10
	n = 30
	X = [random.randrange(0, 10) for i in range(0, n)]
	Y = [random.randrange(0, 10) for i in range(0, n)]
	print "X: ", integer_value(b, n, X)
	print "Y: ", integer_value(b, n, Y)
	Z, Z_length = addition(b, n, X, Y)
	print "Z: ", integer_value(b, Z_length, Z)

{'fraction_non_alphanumeric': 0.1501787842669845, 'fraction_numerical': 0.02264600715137068, 'mean_word_length': 2.9505882352941177, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7172187', 'n_tokens_mistral': 748, 'n_tokens_neox': 704, 'n_words': 279}