Skip to content

Add baffling-birthdays exercise - #779

Merged
glennj merged 8 commits into
exercism:mainfrom
resu-xuniL:baffling-birthdays
Sep 20, 2026
Merged

glennj merged 8 commits into
exercism:mainfrom
resu-xuniL:baffling-birthdays

Conversation

@resu-xuniL

Copy link
Copy Markdown
Contributor

Add baffling-birthdays exercice to track.
I change difficulty from 1 to 4.

Hope everything is correct.

float with bash !
I increase the tolerance for the exercice with 10 and 23 people because, after multiple runs (many time consuming), sometimes one or the other fail when checking only respectively 11|12|13 and 50|51|52.
or might be another way to do it more precisely ?

The other option is to increase the number of runs, but this is very time consuming in bash! (set now at 1000)
maybe I can try to parallelize the computings? or creating a file would help?

I got these result while debbuging :

   (from function `assert_output' in file bats-extra.bash, line 394,
    in test file baffling_birthdays.bats, line 162)
     `assert_output $expect' failed
   
   -- output differs --
   expected : 11.694818
   actual   : 12.70
   --
   
 ✗ estimated probability of at least one shared birthday -> among twenty-three people
   (from function `assert_output' in file bats-extra.bash, line 394,
    in test file baffling_birthdays.bats, line 170)
     `assert_output $expect' failed
   
   -- output differs --
   expected : 50.729723
   actual   : 51.10
   --
   
 ✗ estimated probability of at least one shared birthday -> among seventy people
   (from function `assert_output' in file bats-extra.bash, line 394,
    in test file baffling_birthdays.bats, line 178)
     `assert_output $expect' failed
   
   -- output differs --
   expected : 99.915958
   actual   : 99.90
   --```
---

Reviewer Resources:

[Track Policies](https://github.com/exercism/bash/blob/master/POLICIES.md)

Comment thread exercises/practice/baffling-birthdays/.meta/example.sh Outdated
Comment thread exercises/practice/baffling-birthdays/.meta/example.sh Outdated
Comment thread exercises/practice/baffling-birthdays/baffling_birthdays.bats Outdated
Comment thread exercises/practice/baffling-birthdays/baffling_birthdays.bats Outdated
Comment thread exercises/practice/baffling-birthdays/baffling_birthdays.bats Outdated
Comment thread exercises/practice/baffling-birthdays/baffling_birthdays.bats Outdated
Comment thread exercises/practice/baffling-birthdays/.meta/example.sh Outdated
@resu-xuniL

resu-xuniL commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

23 persons test failed again...
I'll work on it. Any suggestions are welcome! ^^
it passed just before the this test ...

Comment thread exercises/practice/baffling-birthdays/baffling_birthdays.bats Outdated
@IsaacG

IsaacG commented Jun 12, 2026

Copy link
Copy Markdown
Member

Geez... 23 persons test failed again... I'll work on it tomorrow. Any suggestions are welcome! ^^ it passed just before the this test ...

You can try doubling your runs from 1k to 2k. You can try widening the acceptable probability range.

@resu-xuniL
resu-xuniL force-pushed the baffling-birthdays branch from f401a42 to a95d347 Compare June 13, 2026 10:26
@resu-xuniL

resu-xuniL commented Jun 13, 2026

Copy link
Copy Markdown
Contributor Author

OK, it passes 6 times in a row (with this one) so far...
Thank you for your help!
(with runs at 1500)

@resu-xuniL
resu-xuniL requested a review from IsaacG June 13, 2026 10:59
Comment thread exercises/practice/baffling-birthdays/.meta/example.sh Outdated
Comment thread exercises/practice/baffling-birthdays/baffling_birthdays.bats Outdated
Comment thread exercises/practice/baffling-birthdays/baffling_birthdays.bats Outdated
Comment thread exercises/practice/baffling-birthdays/baffling_birthdays.bats Outdated
Comment thread exercises/practice/baffling-birthdays/baffling_birthdays.bats Outdated
@resu-xuniL
resu-xuniL force-pushed the baffling-birthdays branch from a95d347 to d01f64f Compare June 14, 2026 10:03
@resu-xuniL

resu-xuniL commented Jun 14, 2026

Copy link
Copy Markdown
Contributor Author

It passed 4 times in a row before i push this, and now it failed for 10 and 23 people tests!
shall i increase back the tolerence (i decreased them)? or increase the runs to 3k ?

(in the php track, I ran it 10k ... but in bash it would take so much time !!)

@resu-xuniL
resu-xuniL force-pushed the baffling-birthdays branch 6 times, most recently from b77a468 to 1d4dfd3 Compare June 14, 2026 12:08
@resu-xuniL

Copy link
Copy Markdown
Contributor Author

re-increased tolerance for 23 people test.

@IsaacG

IsaacG commented Jun 14, 2026

Copy link
Copy Markdown
Member

(in the php track, I ran it 10k ... but in bash it would take so much time !!)

How much time is too much time? How slow is 3k? 4k?

If it takes more than, say, 5 seconds, we probably want to widen the tolerance.

Comment thread exercises/practice/baffling-birthdays/.meta/example.sh Outdated
Comment thread exercises/practice/baffling-birthdays/.meta/example.sh Outdated
Comment thread exercises/practice/baffling-birthdays/.meta/example.sh Outdated
Comment thread exercises/practice/baffling-birthdays/baffling_birthdays.bats Outdated
Comment thread exercises/practice/baffling-birthdays/baffling_birthdays.bats Outdated
@resu-xuniL

resu-xuniL commented Jun 14, 2026

Copy link
Copy Markdown
Contributor Author

(in the php track, I ran it 10k ... but in bash it would take so much time !!)

How much time is too much time? How slow is 3k? 4k?

If it takes more than, say, 5 seconds, we probably want to widen the tolerance.

it was about 20+ minutes for 2k - 3k before modifications...

@resu-xuniL
resu-xuniL force-pushed the baffling-birthdays branch from 1d4dfd3 to f4268c2 Compare June 14, 2026 15:04
Comment thread exercises/practice/baffling-birthdays/baffling_birthdays.bats Outdated
Comment thread exercises/practice/baffling-birthdays/baffling_birthdays.bats Outdated
Comment thread exercises/practice/baffling-birthdays/baffling_birthdays.bats Outdated
Comment thread exercises/practice/baffling-birthdays/baffling_birthdays.bats Outdated
@glennj

glennj commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Regarding the slowness, you'll get must faster performance by using the builtin $RANDOM variable instead of calling out to shuf

# return a random number in the range 0 <= n < $1
random_int() {
    echo $(( RANDOM % $1 ))
}
february_days=$(( 1 + $(random_int 28) ))

With group_size = 10 and runs = 5000, you're calling shuf 150,000 times and date 50,000 times.

Comment thread exercises/practice/baffling-birthdays/.meta/example.sh Outdated
Comment thread exercises/practice/baffling-birthdays/.meta/example.sh Outdated
@resu-xuniL
resu-xuniL force-pushed the baffling-birthdays branch 4 times, most recently from 11fe39c to 8bffcb9 Compare June 14, 2026 19:23
@resu-xuniL

Copy link
Copy Markdown
Contributor Author

I don't think this is 'hoops', this is just that I need learning more and more :)

@resu-xuniL

resu-xuniL commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

new stats with runs=2k

      1 x 9
     12 x 10
     65 x 11
     40 x 12
      8 x 13

      1 x 47
      5 x 48
     15 x 49
     28 x 50
     25 x 51
     11 x 52
      3 x 53

@IsaacG

IsaacG commented Jun 25, 2026

Copy link
Copy Markdown
Member

The fact that this requires so much work and learning to get working in a reasonable amount of time indicates to me that this may not be a great fit for the bash track 😄

Thoughts on marking this foregone, @glennj ?

@glennj

glennj commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

The fact that this requires so much work and learning to get working in a reasonable amount of time indicates to me that this may not be a great fit for the bash track 😄

Thoughts on marking this foregone, @glennj ?

We have:

  1. a monte-carlo approach that takes an unreasonable amount of time,
  2. a monte-carlo approach that is reasonable, and
  3. non-randomized mathematical approaches (not demonstrated here, but https://exercism.org/tracks/lua/exercises/baffling-birthdays/solutions has some)

I think we can proceed. We'll probably see monstly 1 and 3 submitted.

An instructions.append.md file would be useful to gently steer people along. Approaches articles might help too.

@IsaacG

IsaacG commented Jun 25, 2026

Copy link
Copy Markdown
Member

I think we can proceed. We'll probably see monstly 1 and 3 submitted.

An instructions.append.md file would be useful to gently steer people along. Approaches articles might help too.

Solutions that take long to run will fail the test runner. The approaches article can only be viewed after passing tests.

We'd want to provide a fair bit of guidance in the append file to help students get this to pass on the test runner.

@glennj

glennj commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

How about this approach:

  1. add "status": "wip" to the exercise blob in config.json and we merge this PR.
  2. then we work on a new PR to add .docs/instructions.append.md and change the status to "beta".

@resu-xuniL resu-xuniL changed the title Add baffling-birthdays exercice Add baffling-birthdays exercise Jul 23, 2026
@IsaacG

IsaacG commented Aug 6, 2026

Copy link
Copy Markdown
Member

What's the status on this PR?

@resu-xuniL resu-xuniL closed this Sep 12, 2026
@resu-xuniL
resu-xuniL deleted the baffling-birthdays branch September 12, 2026 21:22
@resu-xuniL
resu-xuniL restored the baffling-birthdays branch September 12, 2026 21:46
@resu-xuniL resu-xuniL reopened this Sep 12, 2026
Comment thread config.json Outdated
Co-authored-by: Glenn Jackman <glenn.jackman@gmail.com>
@glennj

glennj commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

@IsaacG I think this is ready to merge. The exercise status is "wip".

Comment thread exercises/practice/baffling-birthdays/baffling_birthdays.bats
@glennj
glennj merged commit 99c10e1 into exercism:main Sep 20, 2026
3 checks passed
@resu-xuniL
resu-xuniL deleted the baffling-birthdays branch September 20, 2026 10:00
@resu-xuniL

Copy link
Copy Markdown
Contributor Author

fixes at #893

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants