@prologic I am very interested, but I need to setup a docker-capable machine first (I've always kinda shied away from using docker as it adds an extra layer of complexity to projects). I've got a couple of raspberry pis floating around the house, let me see what I can put together.
Timeline
Recent posts from feeds followed by sorenpeter@darch.dk
@GabesArcade I plan to oj ly projects 😅
@prologic Hmm. 🤔
Okay, suppose you host a project using this new forge, and I want to send a pull request. What do I have to do?
@prologic Haha. 😅
I’m not really sure what you have in mind. All I can safe with relatively big confidence is that users hate having to make another account. That’s why GitHub/Codeberg are so successful: One account gives you access to millions of projects.
So, once that problem is solved, anything else will probably just fall into place … ? 😅
@Sumomo if you're looking for a great static site generator/publishing tool by the way have a look at my project ZS
@klaxzy Turns out, it's not a cool project. :-D
Can you build from source? Perhaps not if there is just a download link.
It's been a hot minute since I last used alien to convert a Debian package into an RPM packge. Or was it the other way around? No clue.
when you stumble upon the cool project online and they say they have version for linux, then you click download but only .deb is available, i mean like heh, thanks for nothing
And just like that Problem 10 is done and correct whoohoo 🥳 It was easy because in Problem 7 I'd already written an iterator to produce infinite primes. So the solution for finding the sum of primes under 2,000,000 is basically (shortened):
primes := iter.take_while(iter.filter(prime_candidates(), is_prime), fn(p) { p < n })
print(iter.sum(primes))
And of course the answer is: 142913828922 which took ~21.ss for the Go Vm to compuete.
What's interesting here... Which is the interesting thing about Mu is the dual runtime. So the above solution for Euler Problem 9 finds the solution in ~429ms with the Go VM and ~327ms natively compiled to darwin/arm64. Not bad for a language I haven't really done any optimization work on yet (correctness first obviously).
Oh man wow 😮 Problem 9 was quite hard 😱 I had to build two new functions in the Mu stdlib for computing combinations and permutations, but then the combinations of range(1000) for triples such as a + b == c is enormous! So i had to write iterator versions of these to do lazy evaluation. Anyway solution follows:
#!/usr/bin/env mu
// Special Pythagorean Triplet
import "iter"
fn usage() {
print("Usage:", args()[0], "<n>")
}
fn sqr(x) { x * x }
fn main() {
if len(args()) < 2 {
usage()
exit(1)
}
n := must(int(args()[1]))
print("n:", n)
// For a < b < c and a + b + c == n, both a and b are strictly less
// than n/2. Generate only (a,b) combinations and derive c directly. This
// keeps the search lazy and reduces n=1000 from C(999,3) = 165,668,499
// candidate triples to C(499,2) = 124,251 candidate pairs.
pairs := iter.combinations(iter.range(1, n / 2), 2)
triples := iter.map(pairs, fn(xs) {
a := xs[0]
b := xs[1]
return [a, b, n - a - b]
})
// Enforce b < c; a < b is already guaranteed by combinations over an
// increasing range, and a + b + c == n holds by construction.
triples = iter.filter(triples, fn(xs) {
return xs[1] < xs[2]
})
// Euler 9 has one answer for n=1000. find() stops the entire upstream
// iterator chain as soon as the first Pythagorean triple is found.
answer := iter.find(triples, fn(xs) {
return sqr(xs[0]) + sqr(xs[1]) == sqr(xs[2])
})
print(answer)
if answer != nil {
print(answer[0] * answer[1] * answer[2])
}
}
main()
søren peter mørch