Ah! Your using Kanban then!
Ah! Your using Kanban then!
Someone has a compiler if statement left somewhere in their code (… probably)
It’s not that I like manuals, it’s that I hate automatics randomly shifting and accelerating/slowing down randomly because of it.
It might not be as big an issue in bigger engines cars though, not driven anything bigger than a 1L engine in over a decade.
Looking forward to a direct drive electric car (with customisable acceleration profiles - even better!)
It’s probably a single dev that made the decision, then moves onto something else. They (probably?) don’t have the ability to just raise a recurring PO etc to easily pay you and don’t care enough to worth through the paperwork.
If you had a paid licencing model they may have done it, or just found another lib/ wrote their own.
This posts entire comment chain is an interesting example of people that have extensive knowledge in completely different areas of programming to me. And have some concepts I had never heard/thought of.
EF can have big problems with “Cartesian explosions” if an object has two lists of sub objects to return, it will get listA length x listB length items due to how the joins work. You can see how this leads to the explosion part of the name (with more objects or lists).
Their solution is a “split query” option, that does each sub table as a separate query, then seamlessly gives you the combined result.
If a change like this let’s you get those different table lists as distinct lists with the processing and round trip time of multiple requests then it could be a game changer.
(Source - my last week 🤣😭 + lots of EF docs)
SQL returns subsets of all tables with only those tuples that would be part of the traditional (single-table) query result set
So it returns only the data that would be returned from the query, so the filtering is done.
I can see some uses of it. If you look at what something like Entity Framework does behind the scenes to return nested objects, you can see how something like this might help.
It needs to understand that that code is bad to be able to do that though
For some slightly less common games: Golf with your friends is a great mini game to play, effectively really crazy golf online
From the Depths build ships/planes/tanks with entirely custom guns, engines etc. then play on the campaign map with fleets of these ships. you can make some really complicated vehicles if that’s your thing. Unlimited player count as far as I’m aware.
A less deep version of that is Avorion - Mine resources to build custom ships (less complicated) then even small fleets and do quests, make allies/enemies as you venture to the centre of the galaxy. Supports unlimited players as far as I’m aware. It also allows you to form an alliance to share resources with other players. Resource gathering (mining/salvaging) can be automated by your fleets if that’s not your thing.
Get a client (or instance) that allows it then 🙂
I don’t think you can have private communities currently?
C# I had fun with this one and overbuilt it somewhat. Disappointed I didn’t get/need to implement Dijkstra’s algorithm.
For part two I did a x2 expand, so the example input expanded and found the middles like this (0s for the targets as their easier to distinguish):
namespace AdventOfCode2023.Days.Ten
{
internal class Day10Task1 : IRunnable
{
private HashSet<(int, int)> _visitedNodes = new HashSet<(int, int)>();
public void Run()
{
//var inputLines = File.ReadAllLines("Days/Ten/Day10ExampleInput.txt");
//var inputLines = File.ReadAllLines("Days/Ten/Day10ExampleInput2.txt");
var inputLines = File.ReadAllLines("Days/Ten/Day10Input.txt");
var map = new PipeMap(inputLines);
_visitedNodes.Add((map.XCoord, map.YCoord));
while (true)
{
bool haveMoved = false;
for (int i = 0; i < 4; i++)
{
if (map.CanMove((Direction)i))
{
map.Move((Direction)i);
if (_visitedNodes.Contains((map.XCoord, map.YCoord)))
{
map.Move(GetOppositeDirection((Direction)i));
}
else
{
_visitedNodes.Add((map.XCoord, map.YCoord));
haveMoved = true;
}
}
}
if (!haveMoved)
{
break;
}
}
Console.WriteLine("Nodes Visited: "+ _visitedNodes.Count);
Console.WriteLine("Furthest Node: "+ _visitedNodes.Count/2);
}
public class PipeMap
{
public int XCoord { get; private set; }
public int YCoord { get; private set; }
public char CurrentPipe { get { return Map[YCoord][XCoord]; } }
private string[] Map { get; set; }
public PipeMap(string[] mapString)
{
Map = mapString;
for (int y = 0; y < mapString.Length; y++)
{
for (int x = 0; x < mapString[y].Length; x++)
{
if (mapString[y][x] == 'S')
{
YCoord = y;
XCoord = x;
}
}
}
}
public void Move(Direction direction)
{
var adjacent = GetAdjacent(direction);
XCoord = adjacent.Item1;
YCoord = adjacent.Item2;
}
public bool CanMove(Direction direction)
{
bool currentPositionAllow = CanMoveFromCoord(direction, XCoord, YCoord);
if (!currentPositionAllow) return false;
var adjacent = GetAdjacent(direction);
if (adjacent.Item3 != '.' && CanMoveFromCoord(GetOppositeDirection(direction), adjacent.Item1, adjacent.Item2))
{
return true;
}
return false;
}
private bool CanMoveFromCoord(Direction direction, int xCoord, int yCoord)
{
switch (Map[yCoord][xCoord])
{
case '|':
return direction == Direction.Up || direction == Direction.Down;
case '-':
return direction == Direction.Left || direction == Direction.Right;
case 'L':
return direction == Direction.Up || direction == Direction.Right;
case 'J':
return direction == Direction.Up || direction == Direction.Left;
case '7':
return direction == Direction.Left || direction == Direction.Down;
case 'F':
return direction == Direction.Right || direction == Direction.Down;
case 'S':
return true;
case '.':
default:
throw new Exception("you dun fucked up");
}
}
private (int, int, char) GetAdjacent(Direction direction)
{
var newXCoord = XCoord;
var newYCoord = YCoord;
switch (direction)
{
case Direction.Up:
newYCoord--;
break;
case Direction.Down:
newYCoord++;
break;
case Direction.Left:
newXCoord--;
break;
case Direction.Right:
newXCoord++;
break;
}
return (newXCoord, newYCoord, Map[newYCoord][newXCoord]);
}
}
public enum Direction
{
Up, Right, Down, Left
}
public static Direction GetOppositeDirection(Direction direction)
{
switch (direction)
{
case Direction.Up:
return Direction.Down;
case Direction.Down:
return Direction.Up;
case Direction.Right:
return Direction.Left;
case Direction.Left:
return Direction.Right;
default: throw new Exception("You dun fucked up... again");
}
}
}
}
Part 2 is too big to post… see pastebin link
haha, thats genius
huh… expand x2 worked for me. I wonder if I had a nice input set
It’s a good thing I killed my CPU attempt after 2 hours then!
I would have definitely died in that sandstorm!
I think that has been an outlier so far, its good to have one that makes you re-evaluate your solution once in a while.
Definitely a time sink though!
C#
Not too bad - I just scored every hand for the first part so I could easily sort it.
For the second part I just brute forced the replacements for the hand type matchinge (first digit of score)
public class Day7Task1:IRunnable {
public static Dictionary CardValues = new Dictionary()
{
{ '2', "01" },
{ '3', "02" },
{ '4', "03" },
{ '5', "04" },
{ '6', "05" },
{ '7', "06" },
{ '8', "07" },
{ '9', "08" },
{ 'T', "09" },
{ 'J', "10" },
{ 'Q', "11" },
{ 'K', "12" },
{ 'A', "13" }
};
public void Run()
{
//var inputLines = File.ReadAllLines("Days/Seven/Day7ExampleInput.txt");
var inputLines = File.ReadAllLines("Days/Seven/Day7Input.txt");
var hands = inputLines.Select(line =>
{
var split = line.Split(' ', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
return new Hand(split[0], split[1] );
}).ToList();
var sortedHands = hands.OrderBy(hand => hand.Score).ToList();
long resultValue = 0;
for (int i = 1; i < hands.Count()+1; i++)
{
resultValue += i * sortedHands[i-1].Bid;
}
Console.WriteLine("Result:" + resultValue);
}
public class Hand
{
public Hand(string cards, string bid)
{
Cards = cards;
Bid = int.Parse(bid);
Score = GenerateScore();
}
public string Cards { get; set; }
public int Bid { get; set; }
public long Score { get; }
private long GenerateScore()
{
var resultString = new StringBuilder();
var cardGroups = Cards.GroupBy(c => c).ToList();
var groupCounts = cardGroups.OrderByDescending(g => g.Count()).Select(g => g.Count()).ToList();
if (cardGroups.Count() == 1)
{
resultString.Append("7");
}
else if(cardGroups.Count() == 2 && (cardGroups[0].Count() == 4 || cardGroups[0].Count() == 1))
{
resultString.Append("6");
}
else if(cardGroups.Count() == 2 && (cardGroups[0].Count() == 3 || cardGroups[0].Count() == 2))
{
resultString.Append("5");
}
else if(cardGroups.Count() == 3 && (cardGroups[0].Count() == 3 || cardGroups[1].Count() == 3 || cardGroups[2].Count() == 3))
{
resultString.Append("4");
}
else if(cardGroups.Count() == 3 && groupCounts[0] == 2 && groupCounts[1] == 2 && groupCounts[2] == 1)
{
resultString.Append("3");
}
else if(cardGroups.Count() == 4 )
{
resultString.Append("2");
}
else
{
resultString.Append("1");
}
foreach (var card in Cards)
{
resultString.Append(Day7Task1.CardValues[card]);
}
Console.WriteLine("Cards:{0} Score:{1}",Cards,resultString);
return long.Parse(resultString.ToString());
}
}
}
public class Day7Task2:IRunnable
{
public static Dictionary CardValues = new Dictionary()
{
{ '2', "01" },
{ '3', "02" },
{ '4', "03" },
{ '5', "04" },
{ '6', "05" },
{ '7', "06" },
{ '8', "07" },
{ '9', "08" },
{ 'T', "09" },
{ 'J', "00" },
{ 'Q', "11" },
{ 'K', "12" },
{ 'A', "13" }
};
public void Run()
{
//var inputLines = File.ReadAllLines("Days/Seven/Day7ExampleInput.txt");
var inputLines = File.ReadAllLines("Days/Seven/Day7Input.txt");
var hands = inputLines.Select(line =>
{
var split = line.Split(' ', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
return new Hand(split[0], split[1] );
}).ToList();
var sortedHands = hands.OrderBy(hand => hand.Score).ToList();
long resultValue = 0;
for (int i = 1; i < hands.Count()+1; i++)
{
resultValue += i * sortedHands[i-1].Bid;
}
Console.WriteLine("Result:" + resultValue);
}
public class Hand
{
public Hand(string cards, string bid)
{
Cards = cards;
Bid = int.Parse(bid);
Score = GenerateScore();
}
public string Cards { get; set; }
public int Bid { get; set; }
public long Score { get; }
private long GenerateScore()
{
var generateFirstDigit = new Func(cards =>
{
var cardGroups = cards.GroupBy(c => c).ToList();
var groupCounts = cardGroups.OrderByDescending(g => g.Count()).Select(g => g.Count()).ToList();
if (cardGroups.Count() == 1)
{
return 7;
}
else if (cardGroups.Count() == 2 && (cardGroups[0].Count() == 4 || cardGroups[0].Count() == 1))
{
return 6;
}
else if (cardGroups.Count() == 2 && (cardGroups[0].Count() == 3 || cardGroups[0].Count() == 2))
{
return 5;
}
else if (cardGroups.Count() == 3 && (cardGroups[0].Count() == 3 || cardGroups[1].Count() == 3 || cardGroups[2].Count() == 3))
{
return 4;
}
else if (cardGroups.Count() == 3 && groupCounts[0] == 2 && groupCounts[1] == 2 && groupCounts[2] == 1)
{
return 3;
}
else if (cardGroups.Count() == 4)
{
return 2;
}
else
{
return 1;
}
});
var resultString = new StringBuilder();
var maxFistDigit = Day7Task2.CardValues.Keys.Select(card => generateFirstDigit(Cards.Replace('J', card))).Max();
resultString.Append(maxFistDigit);
foreach (var card in Cards)
{
resultString.Append(Day7Task2.CardValues[card]);
}
Console.WriteLine("Cards:{0} Score:{1}",Cards,resultString);
return long.Parse(resultString.ToString());
}
}
}
on my first attempt my computer couldn’t run Spotify at the same time because it was paging so hard >.<
final go was in the order of 20 seconds or so I think (with practically 0 memory usage)
deleted by creator
It’s the only time that tabs Vs spaces really riles me up. So annoying when everyone has different tab lengths