Scimon Proctor · @scimon
152 followers · 540 posts · Server glasgow.social

sub MAIN(*@i){ @i.combinations(3).grep( { [!==] (|@^a,@^a[0]) } ).elems.say }

Week 234 part 2.

#rakulang #perlweeklychallenge

Last updated 1 year ago

Scimon Proctor · @scimon
152 followers · 538 posts · Server glasgow.social

sub MAIN(*@w) { say ( [(&)] @w.map(*.comb.Bag) ).map({|($_.key xx $_.value)}).sort; }

234 part 1.

#perlweeklychallenge

Last updated 1 year ago

seaker · @seaker
1 followers · 4 posts · Server fosstodon.org


233, Task 2

my solution:
```
my @n = +Β«$*IN.words;
my %freq = @N.Bag;
put @N.sort({ %freq{$_}, -$_ }).join(',');
```

#rakulang #perlweeklychallenge

Last updated 1 year ago

seaker · @seaker
1 followers · 4 posts · Server fosstodon.org


233, Task 1

my solution:
```
put $*IN.words.combinations(2).grep({ .[0].comb.Set eqv .[1].comb.Set }).join("\n");
```

#rakulang #perlweeklychallenge

Last updated 1 year ago

Massa πŸ‘½ Humberto · @massa
226 followers · 1175 posts · Server hachyderm.io

233/02:

You are given an array of integers.

Write a script to sort the given array in increasing order based on the frequency of the values. If multiple values have the same frequency then sort them in decreasing order.

my answer:

```
sub frequency-sort(@_) {
my $frequencies = @_.Bag;
@_.sort: { $frequencies{$^a} <=> $frequencies{$^b} || $^b <=> $^a }
}
```

#perlweeklychallenge #rakulang

Last updated 1 year ago

Massa πŸ‘½ Humberto · @massa
226 followers · 1173 posts · Server hachyderm.io

231/02:

You are given a list of passenger details in the form β€œ9999999999A1122”, where 9 denotes the phone number, A the sex, 1 the age and 2 the seat number.

Write a script to return the count of all senior citizens (age >= 60).

my answer:

```
sub number-of-senior-citizens(@_) {
@_.grep(/^ \d ** 10 \D (\d\d) <?{$0 β‰₯ 60}> \d ** 2 $/).elems
}
```

#perlweeklychallenge #rakulang

Last updated 1 year ago

Massa πŸ‘½ Humberto · @massa
226 followers · 1173 posts · Server hachyderm.io

231/01:

You are given a list of passenger details in the form β€œ9999999999A1122”, where 9 denotes the phone number, A the sex, 1 the age and 2 the seat number.

Write a script to return the count of all senior citizens (age >= 60).

my answer:

```
sub number-of-senior-citizens(@_) {
@_.grep(/^ \d ** 10 \D (\d\d) <?{$0 β‰₯ 60}> \d ** 2 $/).elems
}
```

#perlweeklychallenge #rakulang

Last updated 1 year ago

Massa πŸ‘½ Humberto · @massa
226 followers · 1172 posts · Server hachyderm.io

231/01:

You are given an array of distinct integers.

Write a script to find all elements that is neither minimum nor maximum. Return -1 if you can’t.

my answer:

```
sub without-min-and-max(@_) {
@_.grep: * βˆ‰ @_.minmax.bounds or -1
}
```

#perlweeklychallenge #rakulang

Last updated 1 year ago

Scimon Proctor · @scimon
145 followers · 505 posts · Server glasgow.social

It's nice when I'm the first pull request on the .
Part one this week is very simple in thanks to the is-prime method.
Part two is a nice little bit of recursion. Woke me right up... well mostly, time for more coffee.

#raku #perlweeklychallenge

Last updated 1 year ago

LanceW · @lancew
117 followers · 159 posts · Server mastodon.cloud

Enjoyed spending some time coding this weekend. for the

#perl #python #golang #perlweeklychallenge

Last updated 1 year ago