Exactly my feelings when I heard "Smells Like Teen Spirit" called "classic rock" a few years ago.
SteveDinn
Create a docker container without explicitly naming it. Job done.
Has anyone here installed friendica? I tried to give it a go yesterday with the the docker image. The login page is showing up, but it is giving me HTTP 500 errors when I click sign up I also get no errors in any logs.
The Porg?
A person's state becomes the name of the zone when they're in them.
In the current version of Home Assistant, if a person is in two overlapping zones, what happens? It's possible to be in that state today.
I suppose it doesn't really matter though. I've named all my home zones similarly: home1, home2, etc. It would be easy enough to check for a zone where the object_id starts with "home"
I...honestly thought I just did that. I want to have an irregularly-shaped zone. I don't see why they couldn't logically be grouped, you just aren't able to do it right now.
Anyway, thanks for reading what I typed.
I am pretty sure I'm not confused. I want to group zones together so they can be used in automation triggers and I can change the group's membership and not have to change every automation trigger. The group's state should indicate the number of person entities that were in any zone in the group.
I'm not talking about areas at all.
Just to be clear, I don't believe grouping zones is currently possible. It's just a want I have.
You don't get the choice to use more than one zone as your official "home" zone though, do you?
Like when you create a zone, it's a circle. It has a radius. I want a zone that is an arbitrary shape, so I compose it out of several smaller zones. I want to formally make it a single zone in Home Assistant by grouping them. Currently you can't add zones to groups or create a zone with type: group
or anything like that.
This is the way. Web client to MPV Shim for local playback.
C#
Part 2 was pretty much the same as Part 2 except we can't short-circuit when we find the first match. So, implement a cache of each sub-pattern and the number of ways to form it from the towels, and things get much faster.
using System.Collections.Immutable;
using System.Diagnostics;
using Common;
namespace Day19;
static class Program
{
static void Main()
{
var start = Stopwatch.GetTimestamp();
var sampleInput = ReceiveInput("sample.txt");
var programInput = ReceiveInput("input.txt");
Console.WriteLine($"Part 1 sample: {Part1(sampleInput)}");
Console.WriteLine($"Part 1 input: {Part1(programInput)}");
Console.WriteLine($"Part 2 sample: {Part2(sampleInput)}");
Console.WriteLine($"Part 2 input: {Part2(programInput)}");
Console.WriteLine($"That took about {Stopwatch.GetElapsedTime(start)}");
}
static object Part1(Input input)
{
return input.Patterns
.Select(p => AnyTowelMatches(p, input.Towels) ? 1 : 0)
.Sum();
}
static object Part2(Input input)
{
var matchCache = new Dictionary<string, long>();
return input.Patterns
.Select(p => CountTowelMatches(p, input.Towels, matchCache))
.Sum();
}
private static bool AnyTowelMatches(
string pattern,
ImmutableArray<string> towels)
{
return towels
.Where(t => t.Length <= pattern.Length)
.Select(t =>
!pattern.StartsWith(t) ? false :
(pattern.Length == t.Length) ? true :
AnyTowelMatches(pattern.Substring(t.Length), towels))
.Any(r => r);
}
private static long CountTowelMatches(
string pattern,
ImmutableArray<string> towels,
Dictionary<string, long> matchCache)
{
if (matchCache.TryGetValue(pattern, out var count)) return count;
count = towels
.Where(t => t.Length <= pattern.Length)
.Select(t =>
!pattern.StartsWith(t) ? 0 :
(pattern.Length == t.Length) ? 1 :
CountTowelMatches(pattern.Substring(t.Length), towels, matchCache))
.Sum();
matchCache[pattern] = count;
return count;
}
static Input ReceiveInput(string file)
{
using var reader = new StreamReader(file);
var towels = reader.ReadLine()!.SplitAndTrim(',').ToImmutableArray();
var patterns = new List<string>();
reader.ReadLine();
var line = reader.ReadLine();
while (line is not null)
{
patterns.Add(line);
line = reader.ReadLine();
}
return new Input()
{
Towels = towels,
Patterns = [..patterns],
};
}
public class Input
{
public required ImmutableArray<string> Towels { get; init; }
public required ImmutableArray<string> Patterns { get; init; }
}
}
I'm no international law expert but I don't think that follows the Geneva convention.