<commit_before>﻿using System.Collections.Generic;
using System.Linq;

namespace RollGen
{
    public abstract class PartialRoll
    {
        public int d2() => d(2);
        public int d3() => d(3);
        public int d4() => d(4);
        public int d6() => d(6);
        public int d8() => d(8);
        public int d10() => d(10);
        public int d12() => d(12);
        public int d20() => d(20);
        public int Percentile() => d(100);
        public int d(int die) => IndividualRolls(die).Sum();
        public abstract IEnumerable<int> IndividualRolls(int die);
        public IEnumerable<int> KeepIndividualRolls(IEnumerable<int> rolls, int keep)
        {
            if (rolls.Count() == keep)
                return rolls;
            return rolls.OrderByDescending(r => r).Take(keep);
        }
    }
}<commit_msg>Bug fix: Use int[] instead of IEnumerable<int> to avoid depleting the container.<commit_after>﻿using System.Collections.Generic;
using System.Linq;

namespace RollGen
{
    public abstract class PartialRoll
    {
        public int d2() => d(2);
        public int d3() => d(3);
        public int d4() => d(4);
        public int d6() => d(6);
        public int d8() => d(8);
        public int d10() => d(10);
        public int d12() => d(12);
        public int d20() => d(20);
        public int Percentile() => d(100);
        public int d(int die) => IndividualRolls(die).Sum();
        public abstract IEnumerable<int> IndividualRolls(int die);
        public IEnumerable<int> KeepIndividualRolls(int[] rolls, int keep)
        {
            if (rolls.Length == keep)
                return rolls;
            return rolls.OrderByDescending(r => r).Take(keep);
        }
    }
}
{'fraction_non_alphanumeric': 0.13845258871436883, 'fraction_numerical': 0.029086678301337987, 'mean_word_length': 2.239171374764595, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 31, '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': '5733822', 'n_tokens_mistral': 541, 'n_tokens_neox': 516, 'n_words': 151}