exercism / csharp

Exercism exercises in C#.
https://exercism.org/tracks/csharp
MIT License
333 stars 339 forks source link

Either support the current C# language or tell us what language version is being used for tasks. #2237

Closed bbarry closed 4 months ago

bbarry commented 4 months ago

Expected: C#12 (note: the project is targeting net8.0: https://github.com/exercism/csharp/blob/main/exercises/concept/bird-watcher/BirdWatcher.csproj)

Actual: C#11 (at least based on testing the fact that raw string literals work)

I was fooling around with the site and decided to stumble into the C# track, hitting the bird watcher exercise...

My solution:

using System;
using System.Linq;

class BirdCount(int[] birdsPerDay)
{
    public static int[] LastWeek() => [0, 2, 5, 3, 7, 8, 4];

    public int Today() => birdsPerDay[^1];

    public void IncrementTodaysCount() => birdsPerDay[^1]++;

    public bool HasDayWithoutBirds() => birdsPerDay.Any(b => b == 0);

    // the tests fail to notice the boundary cases here and the task is a little unclear, my first solution was: 
    // birdsPerDay[..Math.Clamp(numberOfDays, 0, birdsPerDay.Length)].Sum();
    // though I suppose maybe that is a little out of scope for a beginner
    public int CountForFirstDays(int numberOfDays) => birdsPerDay[..numberOfDays].Sum();

    public int BusyDays() => birdsPerDay.Count(birds => birds >= 5);
}

Is totally valid C# but doesn't compile.

github-actions[bot] commented 4 months ago

Hello. Thanks for opening an issue on Exercism 🙂

At Exercism we use our Community Forum, not GitHub issues, as the primary place for discussion. That allows maintainers and contributors from across Exercism's ecosystem to discuss your problems/ideas/suggestions without them having to subscribe to hundreds of repositories.

This issue will be automatically closed. Please use [this link](https://forum.exercism.org/new-topic?title=Either%20support%20the%20current%20C#%20language%20or%20tell%20us%20what%20language%20version%20is%20being%20used%20for%20tasks.&body=**Expected:%20C#12**%20(note:%20the%20project%20is%20targeting%20net8.0:%20https://github.com/exercism/csharp/blob/main/exercises/concept/bird-watcher/BirdWatcher.csproj)%0D%0A%0D%0A**Actual:%20C#11**%20(at%20least%20based%20on%20testing%20the%20fact%20that%20raw%20string%20literals%20work)%0D%0A%0D%0AI%20was%20fooling%20around%20with%20the%20site%20and%20decided%20to%20stumble%20into%20the%20C#%20track,%20hitting%20the%20bird%20watcher%20exercise...%0D%0A%0D%0AMy%20solution:%0D%0A%0D%0A%60%60%60csharp%0D%0Ausing%20System;%0D%0Ausing%20System.Linq;%0D%0A%0D%0Aclass%20BirdCount(int%5B%5D%20birdsPerDay)%0D%0A%7B%0D%0A%20%20%20%20public%20static%20int%5B%5D%20LastWeek()%20=%3E%20%5B0,%202,%205,%203,%207,%208,%204%5D;%0D%0A%0D%0A%20%20%20%20public%20int%20Today()%20=%3E%20birdsPerDay%5B%5E1%5D;%0D%0A%0D%0A%20%20%20%20public%20void%20IncrementTodaysCount()%20=%3E%20birdsPerDay%5B%5E1%5D++;%0D%0A%0D%0A%20%20%20%20public%20bool%20HasDayWithoutBirds()%20=%3E%20birdsPerDay.Any(b%20=%3E%20b%20==%200);%0D%0A%0D%0A%20%20%20%20//%20the%20tests%20fail%20to%20notice%20the%20boundary%20cases%20here%20and%20the%20task%20is%20a%20little%20unclear,%20my%20first%20solution%20was:%20%0D%0A%20%20%20%20//%20birdsPerDay%5B..Math.Clamp(numberOfDays,%200,%20birdsPerDay.Length)%5D.Sum();%0D%0A%20%20%20%20//%20though%20I%20suppose%20maybe%20that%20is%20a%20little%20out%20of%20scope%20for%20a%20beginner%0D%0A%20%20%20%20public%20int%20CountForFirstDays(int%20numberOfDays)%20=%3E%20birdsPerDay%5B..numberOfDays%5D.Sum();%0D%0A%20%20%20%20%0D%0A%20%20%20%20public%20int%20BusyDays()%20=%3E%20birdsPerDay.Count(birds%20=%3E%20birds%20%3E=%205);%0D%0A%7D%0D%0A%20%60%60%60%0D%0A%20%0D%0A%20Is%20totally%20valid%20C#%20but%20doesn't%20compile.&category=csharp ) to copy your GitHub Issue into a new topic on the forum, where we look forward to chatting with you!

If you're interested in learning more about this auto-responder, please read this blog post.

kotp commented 4 months ago

OP has no access to Forums, but sent a followup here.

ErikSchierboom commented 4 months ago

@bbarry Thanks for the report! This was fixed in https://github.com/exercism/csharp-test-runner/pull/218