<commit_before>#ifndef ULAM_HPP
#define ULAM_HPP

#include <algorithm>

namespace ulam{


	/**
	 * Converts a prime list index to a spiral index (n is odd) (4)
	 *
	 *
	 */

	size_t stol(size_t i, size_t n){
		size_t line = i / n;
		size_t col = i % n;

		size_t ring_index, side_col = 1, side_line = 1;

		if(col < n - line){
			ring_index = std::min(line, col);
		}
		else if(col > line){
			ring_index = n - col - 1;
			side_line = -1;
		}
		else{
			ring_index = n - line - 1;
			side_col = -1;
		}	

		size_t sub_size = n - ring_index * 2;

		return sub_size * sub_size - (sub_size - 1) * 2 + side_line * (line - ring_index) - side_col * (col - ring_index) - 1;
	}



}


#endif // ULAM_HPP<commit_msg>fix for even numbers<commit_after>#ifndef ULAM_HPP
#define ULAM_HPP

#include <algorithm>

namespace ulam{


	/**
	 * Converts a prime list index to a spiral index (n is odd or even) (4)
	 *
	 *
	 */

	size_t stol(size_t i, size_t n){
		size_t line = i / n;
		size_t col = i % n;

		if(n % 2 == 0){
			line = n - line - 1;
			col = n - col - 1;
		}

		size_t ring_index, side_col = 1, side_line = 1;

		if(col < n - line){
			ring_index = std::min(line, col);
		}
		else if(col > line){
			ring_index = n - col - 1;
			side_line = -1;
		}
		else{
			ring_index = n - line - 1;
			side_col = -1;
		}	

		size_t sub_size = n - ring_index * 2;

		return sub_size * sub_size - (sub_size - 1) * 2 + side_line * (line - ring_index) - side_col * (col - ring_index) - 1;
	}



}


#endif // ULAM_HPP
{'fraction_non_alphanumeric': 0.13951935914552738, 'fraction_numerical': 0.017356475300400534, 'mean_word_length': 2.3090507726269314, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3777000', 'n_tokens_mistral': 734, 'n_tokens_neox': 622, 'n_words': 179}