January 10, 2023

On Tuesday, 10 January 2023 at 06:45:40 UTC, Siarhei Siamashka wrote:
...

>

What kind of D class is that? Are you learning D language in a school or university? Or is it some kind of online language course?
...
I don't know if there are rules about sharing links and such but its a site called https://www.educative.io/learn. There are two D courses. I just finished the second class. The business model on 'Educative' is by subscription with maybe one week or month free trial. So you can get as many certificates as you can complete during your subscription. So I don't know how much weight the certificates carry but I have two D course certificates.

January 10, 2023
On Tuesday, 10 January 2023 at 01:31:28 UTC, Ali Çehreli wrote:
> On 1/9/23 16:17, Paul wrote:
>
> > coding challenges
>
> Perhaps the following two?
>
>   https://rosettacode.org/
>
>   https://adventofcode.com/
>
> Ali

Excellent.  Thanks.
January 12, 2023

On Tuesday, 10 January 2023 at 01:22:33 UTC, H. S. Teoh wrote:

>

Here's a challenge. Given an input year, for example, "2023", write a program that outputs (for the corresponding year):

Now, I wrote a nested class using range and copying from Matheus' code. Of course not as comprehensive as your dcal. I like this one and even thought of a new challenge!

void main()
{
  import std.stdio, std.string : cp = capitalize;
  import std.range, std.conv : to;

  with(new MyCalendar(2023, 12))
  {
    const title = dowToStr!2;
    foreach(month; range.take(6))
    {
      const mName = date.month.to!string;
      year.write(" ");           // current year
      mName.cp.writefln!"%s:";   // name of the month
      title.writefln!"%-(%s %)"; // days of week
      month.writeln;             // formatted days
    }
  }

class MyCalendar
{
  import std.array, std.datetime, std.conv : to;
  import std.string : capitalize;

  Range range;
  Date date;
  int year, month;

  this(int year, int month)
  {
    this.month = month;
    this.year = year;
    this.date = Date(year, month, 1);
    this.range = new Range();
  }

  class Range
  {
    enum empty = false;

    string front()
    {
      import std.format : fw = formattedWrite;
      auto res = appender!string;
      int day, dow = date.dayOfWeek;
      res.fw("%s", replicated(dow * 3)); // skip days

      for(day = 1; day <= date.daysInMonth; ++day)
      {
        if(++dow % 7) res.fw("%2s ", day);
        else res.fw("%2s\n", day);
      }
      if(dow % 7) res.put("\n");
      return res.data;
    }

    void popFront()
    {
      month++;
      if(month > 12)
      {
        ++year;
        month = 1;
      }
      date = Date(year, month, 1);
    }
  }

  auto dowToStr(size_t len = 0)()
  {
    alias E = DayOfWeek;
    string[] result;
    for(E x = E.min; x <= E.max; x++)
    {
      result ~= len ? x.to!string[0..len]
                    : x.to!string;
    }
    return result;
  }
}

SDB@79

January 12, 2023
On 10.01.23 23:22, monkyyy wrote:
> On Tuesday, 10 January 2023 at 19:10:09 UTC, Christian Köstlin wrote:
>> On 10.01.23 01:17, Paul wrote:
>> There is also https://exercism.org/tracks/d with some tasks for dlang.
>>
>> Kind regards,
>> Christian
> 
> Its all converted code; worthless
I was not aware, that the question was searching for solutions in dlang.
At least exorcism gives a skeleton for a dlang project (including
unittest) to solve the task.

Kind regards,
Christian

January 12, 2023
On 10.01.23 23:30, Paul wrote:
> On Tuesday, 10 January 2023 at 01:31:28 UTC, Ali Çehreli wrote:
>> On 1/9/23 16:17, Paul wrote:
>>
>> > coding challenges
>>
>> Perhaps the following two?
>>
>>   https://rosettacode.org/
>>
>>   https://adventofcode.com/
>>
>> Ali
> 
> Excellent.  Thanks.
For this years advent-of-code Steven Schveighoffer (https://github.com
/schveiguy/adventofcode/tree/master/2022) has a complete set of dlang
solutions.

Kind regards,
Christian

January 12, 2023
On Thursday, 12 January 2023 at 20:28:26 UTC, Christian Köstlin wrote:

> For this years advent-of-code Steven Schveighoffer (https://github.com
> /schveiguy/adventofcode/tree/master/2022) has a complete set of dlang
> solutions.
>
> Kind regards,
> Christian

Very helpful. Thanks Christian.




January 13, 2023
On Thursday, 12 January 2023 at 19:06:49 UTC, Salih Dincer wrote:
> ...
>
> Now, I wrote a nested class using range and copying from Matheus' code. Of course not as comprehensive as [your dcal](https://github.com/quickfur/dcal/blob/master/dcal.d). I like this one and even thought of a new challenge!
>
> ...

Hi Salih,

Unfortunately it's not working for me:

> .d(79): Error: found `End of File` when expecting `}` following compound statement

So I think it's missing a "}" in main, and after I added that, it gives:

> .d(46): Error: undefined identifier `replicated`, did you mean template `replicate(S)(S s, size_t n) if (isDynamicArray!S)`?

Matheus.
January 13, 2023

On Friday, 13 January 2023 at 18:59:01 UTC, matheus wrote:

>

Unfortunately it's not working for me

Yeah, it was an old development version. I also implemented another version the same day:

SDB@79

Sory...

January 14, 2023

On Tuesday, 10 January 2023 at 00:17:18 UTC, Paul wrote:

>

Greetings Dlang-ers
I was wondering if anyone knew of any coding challenges available where the input and output are specified and its left to the programmer to find a solution? Free would be nice but even paid services would be worth considering. I'm taking a D class right now and it has little challenges in the lessons where much of the work is done for you, but I'm thinking of a site/service that is dedicated to these types of challenges (without doing any work for you).

[...]

while not specifically D-related, the code golf stack exchange is good place to find challenges (even if you're not golfing).

January 17, 2023
On Friday, 13 January 2023 at 21:12:17 UTC, Salih Dincer wrote:
> On Friday, 13 January 2023 at 18:59:01 UTC, matheus wrote:
>> Unfortunately it's not working for me
>
> Yeah, it was an old development version. I also implemented another version the same day:
>
> * [Nested Class](https://forum.dlang.org/thread/vkjhkftvyprsivozyuyf@forum.dlang.org)
> * [Only One Struct](https://forum.dlang.org/post/thxvuddjimgswalzojgm@forum.dlang.org)
>
> SDB@79
>
> Sory...

No problem. =]

Question: Have you compared the timings between this way (With ranges) and a normal way (Without ranges)?

I'm using D Online Compiler from different platforms but unfortunately I can't loop too much because they don't accept, but anyway a normal version runs almost twice faster than this version (With ranges).

If you like I could send or post here a version without ranges to try out.

Matheus.