<commit_before>#!/usr/bin/env python3

# Lets verify some bitcoins!

import hashlib


DOORID = b'ugkcyxxp'

key = []
i = 0

while True:
    hash = hashlib.md5( DOORID + str(i).encode('ascii') ).hexdigest()
    if hash[:5] == '00000':
        key.append(hash[5])
        print ("Found stage {}".format( len(key) ) )
        if len(key) == 8:
            break
    i += 1
            
print ("The password is {}".format(''.join(key) ) )<commit_msg>Day 5 part 2 animated<commit_after>#!/usr/bin/env python3

# Lets verify some bitcoins!

import hashlib
import random

DOORID = b'ugkcyxxp'
PASSWORDLENGTH = 8

key = list('u' * PASSWORDLENGTH)
i = 0

HASHCODES = '123456789abcdef'

def animate(key):
    line = []
    for c in key:
        if c == 'u':
            line.append( random.choice( HASHCODES ) ) 
        else:
            line.append( c )
    print('\r Password: {}'.format(''.join(line) ), end='' )

while True:
    hash = hashlib.md5( DOORID + str(i).encode('ascii') ).hexdigest()
    if hash[:5] == '00000':
        pos = hash[5]
        value = hash[6]
        if pos.isnumeric():
            pos = int(pos)
            if pos < PASSWORDLENGTH and key[pos] == 'u':
                key[pos] = value
                if 'u' not in key:
                    print('\r '+' ' * 40 ) # clear the screen
                    break
    i += 1
    if i % 40000 == 0: # chosen by science to be the most exciting speed on  my cpu
        animate(key)
            
print ("The password is {}".format(''.join(key) ) )
{'fraction_non_alphanumeric': 0.15079365079365079, 'fraction_numerical': 0.0291005291005291, 'mean_word_length': 1.996039603960396, 'pattern_counts': {'":': 0, '<': 4, '<?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': '2687206', 'n_tokens_mistral': 556, 'n_tokens_neox': 516, 'n_words': 146}