Advent of Code 2019

Steven Schveighoffer schveiguy at gmail.com
Mon Nov 25 15:30:47 UTC 2019


On 11/25/19 6:32 AM, Sergei Nosov wrote:
> On Saturday, 23 November 2019 at 04:38:14 UTC, mipri wrote:
>> Hello all,
>>
>> There's one more week in November, and then Advent of Code'll
>> start again with Christmas-themed programming puzzles, one
>> released every midnight US/Eastern, with a second part to each
>> puzzle unlocked after you complete the first part. You can read
>> more about it at the website: https://adventofcode.com/2019/about
> 
> I've only made it halfway through last year.
> 
> One of the unexpected difficulties for me was, actually, working with 
> strings. The problems involve only ASCII characters, so you don't care 
> about the UTF stuff at all. Yet, D always tries to be cautious of it and 
> you have to workaround it all the time which leads to ugly-looking 
> hacks, like 
> https://github.com/snosov1/adventofcode.com/blob/master/2018/day05/day05_2.d 
> 
> 
> What would be a recommended way to handle such cases? (i.e. when you 
> know for sure that your characters are always 8-bit, so it's safe to 
> call `sort`, `toUpper` and all the other std functions without ever 
> trying to decode)
> 
> 

https://dlang.org/phobos/std_ascii.html#toLower
https://dlang.org/phobos/std_ascii.html#toUpper
https://dlang.org/phobos/std_utf.html#byCodeUnit

-Steve


More information about the Digitalmars-d mailing list