Re: Advent of Code 2023

2023-12-03 Thread Julian Fondren via Digitalmars-d-learn
On Monday, 4 December 2023 at 03:50:47 UTC, Siarhei Siamashka wrote: On Monday, 4 December 2023 at 03:07:07 UTC, matheus wrote: import std.stdio; import std.algorithm; import std.array; import std.format; import std.conv; import std.string; ... Why do you do multiple imports instead of one

Re: Advent of Code 2023

2023-12-03 Thread Siarhei Siamashka via Digitalmars-d-learn
On Monday, 4 December 2023 at 03:07:07 UTC, matheus wrote: import std.stdio; import std.algorithm; import std.array; import std.format; import std.conv; import std.string; ... Why do you do multiple imports instead of one import std;? I means is there any difference in CT? The code indeed

Re: Advent of Code 2023

2023-12-03 Thread matheus via Digitalmars-d-learn
On Saturday, 2 December 2023 at 13:33:33 UTC, Johannes Miesenhardt wrote: On Friday, 1 December 2023 at 01:01:31 UTC, Siarhei Siamashka wrote: Advent of Code 2023 starts in a few hours from now. I suggest to discuss D language solutions here. But to avoid spoilers, it's best to do this with a

Re: Advent of Code 2023

2023-12-03 Thread Julian Fondren via Digitalmars-d-learn
On Sunday, 3 December 2023 at 23:44:43 UTC, Julian Fondren wrote: ```d if (str[i..$].startsWith(key)) return value; ``` Corrected. The other doesn't compile, unless you never run it with -version=Part2 ...

Re: Advent of Code 2023

2023-12-03 Thread Julian Fondren via Digitalmars-d-learn
On Saturday, 2 December 2023 at 13:33:33 UTC, Johannes Miesenhardt wrote: I am a bloody beginner so if there are any things that are very wrong with this please point them out. The fact that I need a template for accepting both a string and a char[] is very weird but I went with it. I am also

Re: Advent of Code 2023

2023-12-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On Sunday, 3 December 2023 at 18:56:32 UTC, Johannes Miesenhardt wrote: On Sunday, 3 December 2023 at 14:51:37 UTC, Siarhei Siamashka wrote: [...] Thanks, this is super helpful. I have one other question, in the solution you posted and also the one I posted in the discord today. I was

Re: Advent of Code 2023

2023-12-03 Thread Johannes Miesenhardt via Digitalmars-d-learn
On Sunday, 3 December 2023 at 14:51:37 UTC, Siarhei Siamashka wrote: [...] Thanks, this is super helpful. I have one other question, in the solution you posted and also the one I posted in the discord today. I was required to use byLineCopy. I first used byLine but I for some reason that I

Re: Advent of Code 2023

2023-12-03 Thread Siarhei Siamashka via Digitalmars-d-learn
On Saturday, 2 December 2023 at 14:35:19 UTC, Sergey wrote: Some other solutions that could be worth to check: https://github.com/andrewlalis/AdventOfCode2023/blob/main/day_1/solution.d https://github.com/schveiguy/adventofcode/blob/master/2023/day1/trebuchet.d It's indeed a good idea to have

Re: Advent of Code 2023

2023-12-03 Thread Siarhei Siamashka via Digitalmars-d-learn
On Saturday, 2 December 2023 at 13:33:33 UTC, Johannes Miesenhardt wrote: I am a bloody beginner so if there are any things that are very wrong with this please point them out. Everything is fine as long as it works and does the job. The fact that I need a template for accepting both a string

Re: How to hash SHA256 from string?

2023-12-03 Thread zoujiaqing via Digitalmars-d-learn
Thank u every one ;) Use botan so easy: ```D import std.stdio; import botan; void main() { string appKey = "1"; auto sha256 = retrieveHash("SHA-256").clone(); sha256.update(appKey); string sign =