<commit_before>package main

import (
	"strconv"
)

type Fraction struct {
	numerator   int
	denominator int
}

func NewFrac(num, denom int) Fraction {
	return Fraction{
		numerator:   num,
		denominator: denom,
	}
}

func NewIFrac(integer int) Fraction {
	return Fraction{
		numerator:   integer,
		denominator: 1,
	}
}

// This method operates on a struct instance and modifies it attempting to
// put it in to a simpler/reduced form
func (self *Fraction) simplify() {
	// TODO: Use Euclidean Algoritim for finding GCD to divide num and denom
	if self.denominator == 0 {
		return
	}

	if self.numerator%self.denominator == 0 {
		self.numerator /= self.denominator
		self.denominator = 1
	}
	greatest_divisor := gcd(self.numerator, self.denominator)
	if greatest_divisor > 1 {
		self.numerator /= greatest_divisor
		self.denominator /= greatest_divisor
	}
}

func gcd(a, b int) int {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

// Adding two fractions together
func (self Fraction) add(other Fraction) Fraction {
	// TODO: could potentiallly use a math.Min(denominators) and % operator
	// to only need to multiply one fraction before adding (maybe faster?)<commit_msg>Update note about GCD alg for fractions<commit_after>package main

import (
	"strconv"
)

type Fraction struct {
	numerator   int
	denominator int
}

func NewFrac(num, denom int) Fraction {
	return Fraction{
		numerator:   num,
		denominator: denom,
	}
}

func NewIFrac(integer int) Fraction {
	return Fraction{
		numerator:   integer,
		denominator: 1,
	}
}

// This method operates on a struct instance and modifies it attempting to
// put it in to a simpler/reduced form
func (self *Fraction) simplify() {
	// TODO: Use Euclidean algoritim for finding GCD to divide num and denom
	// NOTE: Probably use <NAME>'s version
	if self.denominator == 0 {
		return
	}

	if self.numerator%self.denominator == 0 {
		self.numerator /= self.denominator
		self.denominator = 1
	}
	greatest_divisor := gcd(self.numerator, self.denominator)
	if greatest_divisor > 1 {
		self.numerator /= greatest_divisor
		self.denominator /= greatest_divisor
	}
}

func gcd(a, b int) int {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

// Adding two fractions together
func (self Fraction) add(other Fraction) Fraction {
	// TODO: could potentiallly use a math.Min(denominators) and % operator
	// to only need to multiply one fraction before adding (maybe faster?)
{'fraction_non_alphanumeric': 0.09441707717569786, 'fraction_numerical': 0.0049261083743842365, 'mean_word_length': 3.529739776951673, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, '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': '1395443', 'n_tokens_mistral': 909, 'n_tokens_neox': 845, 'n_words': 278}