<commit_before>class Solution {
    public:
        int ladderLength(string start, string end, unordered_set<string> &dict) {
            if(start == end) return 2;
            queue<string> q; q.push(start);
            int depth = 1, layerCount = 1, nextLayerCount = 0;
            unordered_set<string> visited;
            while(!q.empty()){
                string cur = q.front(); q.pop();
                layerCount --;
                unordered_set<string>::iterator iter;
                for(iter = dict.begin(); iter != dict.end(); iter++){
                    if(checkTransformation(cur, *iter)){
                        if(cur == end) return depth;
                        if(checkTransformation(cur, end)) return depth + 1;
                        if(visited.find(*iter) == visited.end()){
                            q.push(*iter); 
                            nextLayerCount ++;
                            visited.insert(*iter);
                        }
                    }
                }
                if(layerCount == 0) {
                    depth ++;
                    layerCount = nextLayerCount;
                    nextLayerCount = 0;
                }
            }
            return 0;
        }

        bool checkTransformation(const string &word1, const string &word2){
            int count = 0;
            for(int i = 0; i != word1.size(); ++i){
                if(word1[i] != word2[i]){
                    count ++;
                }
            }
            if(count == 1) return true;
            else return false;
        }
};<commit_msg>changing each position from a to z in a DFS rather than counting the difference<commit_after>class Solution {
    public:
        int ladderLength(string start, string end, unordered_set<string> &dict) {
            if(start == end) return 2;
            queue<string> q; q.push(start);
            int depth = 1, layerCount = 1, nextLayerCount = 0;
            unordered_set<string> visited;
            while(!q.empty()){
                string cur = q.front(); q.pop();
                layerCount --;
                unordered_set<string>::iterator iter;

                for(int i = 0; i != cur.size(); ++i){
                    for(char j = 'a'; j < 'z'; ++j){
                        if(cur[i] == j) continue;
                        string tmp = cur; tmp[i] = j;
                        if(tmp == end) return depth + 1;
                        if(dict.find(tmp) != dict.end()){
                            q.push(tmp);
                            dict.erase(tmp);
                            ++nextLayerCount;
                        }
                    }
                }

                if(layerCount == 0) {
                    depth ++;
                    layerCount = nextLayerCount;
                    nextLayerCount = 0;
                }
            }
            return 0;
        }

};
{'fraction_non_alphanumeric': 0.11299239806496199, 'fraction_numerical': 0.008638562543192813, 'mean_word_length': 1.0473833097595473, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 11, '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': '4285076', 'n_tokens_mistral': 767, 'n_tokens_neox': 708, 'n_words': 177}