Skip Navigation
InitialsDiceBearhttps://github.com/dicebear/dicebearhttps://creativecommons.org/publicdomain/zero/1.0/„Initials” (https://github.com/dicebear/dicebear) by „DiceBear”, licensed under „CC0 1.0” (https://creativecommons.org/publicdomain/zero/1.0/)DN
dns @aussie.zone
Posts 0
Comments 6
[2023 Day #1] Massive Difficulty Increase
  • The bug is some strings can have overlapping characters. onEight threEight fivEight. There are more cases. So if you do a search and replace your string becomes 1ight 3ight and the second number does not get found.

    Possible fixes: Search and replace and add the extra letter: oneEigh then search and replace. Search and replace words to numbers but put some extra letters in just in case.

  • 🦌 - 2023 DAY 2 SOLUTIONS -🦌
  • My solution in python

    input="""Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green
    Game 2: 1 blue, 2 green; 3 green, 4 blue, 1 red; 1 green, 1 blue
    Game 3: 8 green, 6 blue, 20 red; 5 blue, 4 red, 13 green; 5 green, 1 red
    Game 4: 1 green, 3 red, 6 blue; 3 green, 6 red; 3 green, 15 blue, 14 red
    Game 5: 6 red, 1 blue, 3 green; 2 blue, 1 red, 2 green"""
    
    def parse(line):
        data={}
        data['game']=int(line[5:line.index(':')])
        data['hands']=[]
        for str in line[line.index(':')+1:].split(';'):
            h={'red':0,'green':0,'blue':0}
            for str2 in str.split(','):
                tmp=str2.strip(' ').split(' ')
                h[tmp[1]]=int(tmp[0])
            data['hands'].append(h)
    
        data['max_red']=max([x['red'] for x in data['hands']])
        data['max_green']=max([x['green'] for x in data['hands']])
        data['max_blue']=max([x['blue'] for x in data['hands']])
        data['power']=data['max_red']*data['max_green']*data['max_blue']
        data['possible'] = True
        if data['max_red'] > 12:
            data['possible'] = False
        if data['max_green'] > 13:
            data['possible'] = False
        if data['max_blue'] > 14:
            data['possible'] = False
    
    
        return data
    def loadFile(path):
        with open(path,'r') as f:
            return f.read()
    
    if __name__ == '__main__':
        input=loadFile('day2_input')
        res=[]
        total=0
        power_sum=0
        for row in input.split('\n'):
            data=parse(row)
            if data['possible']:
                total=total+data['game']
            power_sum=power_sum+data['power']
        print('total: %s, power: %s ' % (total,power_sum,))
    
  • Measuring performance in a hardware-agnostic way
  • I believe everyone gets different input and needs to produce a different result. There can be multiple solutions. Do you process as you are going, or do you parse and build a data structure to process later so you loop through the results multiple times.

  • [2023 Day 1] It is not supposed to ramp up this fast
  • My solution was worse than most: replace one -> one1one You are only going to do the replace all for each number and if the "e" is also in eight it is still there for the next set of replace.

    A better quick and dirty solution from Mastodon was to just add the common character first: twone -> twoone