• 0 Posts
  • 15 Comments
Joined 1 year ago
cake
Cake day: June 22nd, 2023

help-circle




  • Python

    Part 1: https://github.com/porotoman99/Advent-of-Code-2023/blob/main/Day 7/part1.py

    Code
    import os
    
    filePath = os.path.dirname(os.path.realpath(__file__))
    inputFilePath = filePath + "\\adventofcode.com_2023_day_7_input.txt"
    # inputFilePath = filePath + "\\part1.txt"
    
    def typeSort(hand):
    	cardCount = {
    		"2": 0,
    		"3": 0,
    		"4": 0,
    		"5": 0,
    		"6": 0,
    		"7": 0,
    		"8": 0,
    		"9": 0,
    		"T": 0,
    		"J": 0,
    		"Q": 0,
    		"K": 0,
    		"A": 0
    	}
    	for card in hand:
    		cardCount[card] += 1
    	cardTotals = list(cardCount.values())
    	cardTotals.sort(reverse=True)
    	if(cardTotals[0] == 5):
    		return 6
    	elif(cardTotals[0] == 4):
    		return 5
    	elif(cardTotals[0] == 3 and cardTotals[1] == 2):
    		return 4
    	elif(cardTotals[0] == 3):
    		return 3
    	elif(cardTotals[0] == 2 and cardTotals[1] == 2):
    		return 2
    	elif(cardTotals[0] == 2):
    		return 1
    	else:
    		return 0
    
    def bucketSort(camelCard):
    	totalScore = 0
    	cardOrder = ["2","3","4","5","6","7","8","9","T","J","Q","K","A"]
    	hand = camelCard[0]
    	totalScore += cardOrder.index(hand[4]) * 15 ** 1
    	totalScore += cardOrder.index(hand[3]) * 15 ** 2
    	totalScore += cardOrder.index(hand[2]) * 15 ** 3
    	totalScore += cardOrder.index(hand[1]) * 15 ** 4
    	totalScore += cardOrder.index(hand[0]) * 15 ** 5
    	return totalScore
    
    hands = []
    bids = []
    
    with open(inputFilePath) as inputFile:
    	for line in inputFile:
    		lineSplit = line.split()
    		hand = lineSplit[0]
    		bid = lineSplit[1]
    		hands.append(hand)
    		bids.append(bid)
    
    bids = [int(bid) for bid in bids]
    
    camelCards = list(zip(hands,bids))
    
    typeBuckets = [[],[],[],[],[],[],[]]
    
    for camelCard in camelCards:
    	hand = camelCard[0]
    	typeScore = typeSort(hand)
    	typeBuckets[typeScore].append(camelCard)
    
    finalCardSort = []
    
    for bucket in typeBuckets:
    	if(len(bucket) > 1):
    		bucket.sort(key=bucketSort)
    	for camelCard in bucket:
    		finalCardSort.append(camelCard)
    
    camelScores = []
    
    for camelIndex in range(len(finalCardSort)):
    	scoreMultiplier = camelIndex + 1
    	camelCard = finalCardSort[camelIndex]
    	camelScores.append(camelCard[1] * scoreMultiplier)
    
    print(sum(camelScores))
    

    Part 2: https://github.com/porotoman99/Advent-of-Code-2023/blob/main/Day 7/part2.py

    Code
    import os
    
    filePath = os.path.dirname(os.path.realpath(__file__))
    inputFilePath = filePath + "\\adventofcode.com_2023_day_7_input.txt"
    # inputFilePath = filePath + "\\part1.txt"
    
    def typeSort(hand):
    	cardCount = {
    		"J": 0,
    		"2": 0,
    		"3": 0,
    		"4": 0,
    		"5": 0,
    		"6": 0,
    		"7": 0,
    		"8": 0,
    		"9": 0,
    		"T": 0,
    		"Q": 0,
    		"K": 0,
    		"A": 0
    	}
    	for card in hand:
    		cardCount[card] += 1
    	jokerCount = cardCount["J"]
    	cardCount["J"] = 0
    	cardTotals = list(cardCount.values())
    	cardTotals.sort(reverse=True)
    	if(cardTotals[0] + jokerCount == 5):
    		return 6
    	elif(cardTotals[0] + jokerCount == 4):
    		return 5
    	elif(
    		cardTotals[0] + jokerCount == 3 and cardTotals[1] == 2
    		or cardTotals[0] == 3 and cardTotals[1] + jokerCount == 2
    	):
    		return 4
    	elif(cardTotals[0] + jokerCount == 3):
    		return 3
    	elif(
    		cardTotals[0] + jokerCount == 2 and cardTotals[1] == 2
    		or cardTotals[0] == 2 and cardTotals[1] + jokerCount == 2
    	):
    		return 2
    	elif(cardTotals[0] + jokerCount == 2):
    		return 1
    	else:
    		return 0
    
    def bucketSort(camelCard):
    	totalScore = 0
    	cardOrder = ["J","2","3","4","5","6","7","8","9","T","Q","K","A"]
    	hand = camelCard[0]
    	totalScore += cardOrder.index(hand[4]) * 15 ** 1
    	totalScore += cardOrder.index(hand[3]) * 15 ** 2
    	totalScore += cardOrder.index(hand[2]) * 15 ** 3
    	totalScore += cardOrder.index(hand[1]) * 15 ** 4
    	totalScore += cardOrder.index(hand[0]) * 15 ** 5
    	return totalScore
    
    hands = []
    bids = []
    
    with open(inputFilePath) as inputFile:
    	for line in inputFile:
    		lineSplit = line.split()
    		hand = lineSplit[0]
    		bid = lineSplit[1]
    		hands.append(hand)
    		bids.append(bid)
    
    bids = [int(bid) for bid in bids]
    
    camelCards = list(zip(hands,bids))
    
    typeBuckets = [[],[],[],[],[],[],[]]
    
    for camelCard in camelCards:
    	hand = camelCard[0]
    	typeScore = typeSort(hand)
    	typeBuckets[typeScore].append(camelCard)
    
    finalCardSort = []
    
    for bucket in typeBuckets:
    	if(len(bucket) > 1):
    		bucket.sort(key=bucketSort)
    	for camelCard in bucket:
    		finalCardSort.append(camelCard)
    
    camelScores = []
    
    for camelIndex in range(len(finalCardSort)):
    	scoreMultiplier = camelIndex + 1
    	camelCard = finalCardSort[camelIndex]
    	camelScores.append(camelCard[1] * scoreMultiplier)
    
    print(sum(camelScores))
    

    I tried to do this one as quickly as possible, so the code is more messy than I would prefer, but it works, and I don’t think the solution is too bad overall.

    Edit: I went back and changed it to be a bit better. Here are my new solutions:

    Part 1 v2: https://github.com/porotoman99/Advent-of-Code-2023/blob/main/Day 7/part1v2.py

    Code
    import os
    
    filePath = os.path.dirname(os.path.realpath(__file__))
    inputFilePath = filePath + "\\adventofcode.com_2023_day_7_input.txt"
    # inputFilePath = filePath + "\\part1.txt"
    
    CARD_ORDER = "23456789TJQKA"
    
    def typeSort(camelCard):
    	cardCount = {}
    	for card in CARD_ORDER:
    		cardCount[card] = 0
    	hand = camelCard[0]
    	for card in hand:
    		cardCount[card] += 1
    	cardTotals = list(cardCount.values())
    	cardTotals.sort(reverse=True)
    	if(cardTotals[0] == 5):
    		return 6
    	elif(cardTotals[0] == 4):
    		return 5
    	elif(cardTotals[0] == 3 and cardTotals[1] == 2):
    		return 4
    	elif(cardTotals[0] == 3):
    		return 3
    	elif(cardTotals[0] == 2 and cardTotals[1] == 2):
    		return 2
    	elif(cardTotals[0] == 2):
    		return 1
    	else:
    		return 0
    
    def handSort(camelCard):
    	totalScore = 0
    	hand = camelCard[0]
    	totalScore += CARD_ORDER.index(hand[4]) * 15 ** 1
    	totalScore += CARD_ORDER.index(hand[3]) * 15 ** 2
    	totalScore += CARD_ORDER.index(hand[2]) * 15 ** 3
    	totalScore += CARD_ORDER.index(hand[1]) * 15 ** 4
    	totalScore += CARD_ORDER.index(hand[0]) * 15 ** 5
    	return totalScore
    
    hands = []
    bids = []
    
    with open(inputFilePath) as inputFile:
    	for line in inputFile:
    		lineSplit = line.split()
    		hand = lineSplit[0]
    		bid = lineSplit[1]
    		hands.append(hand)
    		bids.append(int(bid))
    
    camelCards = list(zip(hands,bids))
    camelCards = sorted(camelCards, key=lambda x: (typeSort(x), handSort(x)))
    
    camelScores = []
    
    for camelIndex in range(len(camelCards)):
    	scoreMultiplier = camelIndex + 1
    	camelCard = camelCards[camelIndex]
    	camelScores.append(camelCard[1] * scoreMultiplier)
    
    print(sum(camelScores))
    

    Part 2 v2: https://github.com/porotoman99/Advent-of-Code-2023/blob/main/Day 7/part2v2.py

    Code
    import os
    
    filePath = os.path.dirname(os.path.realpath(__file__))
    inputFilePath = filePath + "\\adventofcode.com_2023_day_7_input.txt"
    # inputFilePath = filePath + "\\part1.txt"
    
    CARD_ORDER = "J23456789TQKA"
    
    def typeSort(camelCard):
    	cardCount = {}
    	for card in CARD_ORDER:
    		cardCount[card] = 0
    	hand = camelCard[0]
    	for card in hand:
    		cardCount[card] += 1
    	jokerCount = cardCount["J"]
    	cardCount["J"] = 0
    	cardTotals = list(cardCount.values())
    	cardTotals.sort(reverse=True)
    	if(cardTotals[0] + jokerCount == 5):
    		return 6
    	elif(cardTotals[0] + jokerCount == 4):
    		return 5
    	elif(
    		cardTotals[0] + jokerCount == 3 and cardTotals[1] == 2
    		or cardTotals[0] == 3 and cardTotals[1] + jokerCount == 2
    	):
    		return 4
    	elif(cardTotals[0] + jokerCount == 3):
    		return 3
    	elif(
    		cardTotals[0] + jokerCount == 2 and cardTotals[1] == 2
    		or cardTotals[0] == 2 and cardTotals[1] + jokerCount == 2
    	):
    		return 2
    	elif(cardTotals[0] + jokerCount == 2):
    		return 1
    	else:
    		return 0
    
    def handSort(camelCard):
    	totalScore = 0
    	hand = camelCard[0]
    	totalScore += CARD_ORDER.index(hand[4]) * 15 ** 1
    	totalScore += CARD_ORDER.index(hand[3]) * 15 ** 2
    	totalScore += CARD_ORDER.index(hand[2]) * 15 ** 3
    	totalScore += CARD_ORDER.index(hand[1]) * 15 ** 4
    	totalScore += CARD_ORDER.index(hand[0]) * 15 ** 5
    	return totalScore
    
    hands = []
    bids = []
    
    with open(inputFilePath) as inputFile:
    	for line in inputFile:
    		lineSplit = line.split()
    		hand = lineSplit[0]
    		bid = lineSplit[1]
    		hands.append(hand)
    		bids.append(int(bid))
    
    camelCards = list(zip(hands,bids))
    camelCards = sorted(camelCards, key=lambda x: (typeSort(x), handSort(x)))
    
    camelScores = []
    
    for camelIndex in range(len(camelCards)):
    	scoreMultiplier = camelIndex + 1
    	camelCard = camelCards[camelIndex]
    	camelScores.append(camelCard[1] * scoreMultiplier)
    
    print(sum(camelScores))
    


  • I don’t have a specific checklist, but I can tell you what I like to do to try and stay on task.

    What I usually like to do is make a world in editor mode and design small parts of that factory that I know I will need, like I know I will need enough smelters to fill a belt of iron, or I know I will need to produce each type of science. I copy those designs to blueprints, and place them back in the main world where I need them to be. At this point, it’s just a matter of placing buildings down where the ghosts say they should go, routing materials between factory sections, and scaling the factory up to deal with resource shortages.

    I find that designing the factories in editor mode makes the process go much smoother, since there is not much getting in the way. No placement/breaking range limit, no resource limit, instantly able to copy and paste buildings, and the ability to use infinity chests to test throughput all make the designing process much easier for me.




  • I’ve made a bunch of these using different berries since this was posted. The classic blueberry variety is good, and cherries are just as good, if not better. Cranberries are pretty good, but are very tart, so you can’t eat as much in one serving. Blackberries tasted good, but were very seedy, so it wasn’t as good texture-wise. Figs were terrible and I had to throw the whole batch away after 1 bite. Overall, a fun and easy recipe to try, and I’m planning on making more in the future.


  • There are some tricks you can do to make this one a bit easier. I played on a set seed, first planning a base for it in editor mode, and then copying the entire base as a blueprint. You have to play with biters, but you can set their spawning area to be far enough away that you won’t need to interact with them. I also made a new save file for each major milestone in the base, so if I didn’t reach the end quick enough, I could try to go back to a previous segment that I thought was slow and do it faster.



  • “Worthy” from Distance.

    It is still my rarest achievement, with only 0.60% of players having earned it. A lot of the achievements in my rarest achievement showcase were added to popular games years after the peak of the game’s popularity, but were actually quite easy to get. “Worthy” required beating a large level with various unique challenges, and even with checkpoints present in the game, it would often take me hours to reach the next checkpoint at certain parts. I had to follow along with this video at some parts to make sure I was getting through the level correctly, especially the segment from 5:40 to 7:57 which took me about 4 hours to get through successfully.



  • Stuff I liked:

    • Viewfinder: My favorite demo of all of the ones I played. A really neat puzzle mechanic that seems well implemented with lots of creative variations.
    • The Invincible: I was interested in this one before the demo, but it wasn’t quite what I was expecting. It seems to mostly be walking around, examining things, and listening to conversations between the player character and someone else. The graphics are quite pretty and it seems like the story will be good, so I will probably take a look at it at some point in the future.
    • Crime O’Clock: An interesting take on the hidden object genre where you have to examine a sequence of scenes from an event to solve a crime.
    • Cipher Zero: A simple puzzle game with a neat aesthetic. New mechanics are introduced in a way that makes them intuitive by the time another one is introduced. Some puzzles have multiple solutions, and each one is counted for full completion of a level.
    • Kanji Industry: An automation puzzle game where you build Japanese letters from their component parts. Needs some serious polish, but it is an interesting concept.
    • Cuisineer: A game where you inherit your parents’ restaurant. You need to explore dungeons and kill monsters to gather ingredients to make food, and complete quests for people in town to earn recipes.
    • Word Factori: A similar concept to Kanji Industry, but with more polish. You build English letters and words using only the letter “I” as a base to work with.
    • Little Kitty, Big City: Great animation, funny characters, and lots of little things to do with the end goal of returning home.
    • Station to Station: A puzzle game where you have to connect various buildings with train stations to create a complete network of supply and demand.

    Stuff I didn’t like (or at least not enough to buy):

    • Sea of Stars: The art was very pretty, but the gameplay just didn’t capture me for some reason. It seems like the demo takes place somewhere in the middle of the story without providing any context, making it feel like you have just continued someone else’s save file in the middle of a game.
    • Pygmalion: The puzzles were fine, but it got a bit annoying to constantly have the gameplay interrupted by story, and the story constantly interrupted by gameplay. Maybe it would have felt better if there were large story chunks at the end of a set of levels instead of a few sentences after every single level. It probably didn’t help that the demo only shows the first 3 sets of levels, which are probably the easiest in the game, all able to be solved in just a few seconds.
    • Cardbob: The aesthetic of cardboard robots is cool, and using the trailing bandana to show remaining HP is super unique, but the gameplay felt a bit generic and I could never find a way to survive the room immediately after the first boss.
    • Robotherapy: Very funny story, but that’s about all it has going for it.
    • Tiny Room Stories: Rift Escape: This one was pretty good and seems like it has an interesting story, but I ended up getting stuck in a room for about 10 minutes before giving up since there was no hint option available in the game.
    • Broken Lens: A spot the difference game where you play as a robot with a broken lens in one of its eyes. The screen is split into two halves, and you have to click and drag to explore a scene to find discrepancies. It has a hint function, but none of the objects are randomized in the scenes, which trivializes the gameplay if you don’t feel like finding the objects yourself. I liked how there were hidden papers in each of the levels that had a little bit of lore in them.
    • Street of Secrets: Another hidden object game, the gimmick of this one seems to be that the objects are hidden in multiple rooms within a house that you have to navigate between. Nothing really wrong with this one, it just doesn’t stand out to me in any special way.
    • One Lonely Outpost: I was previously planning on buying this one, but the demo convinced me otherwise. Terrible inventory management, the days are too short to do anything meaningful, and there is little explanation of what you are supposed to do.
    • Lovux: A neat puzzle game, but the music got really annoying really fast, and the animations for interacting with things took a long time, making a large part of the game just waiting for animations to finish so you can click on the next thing.