Skip to content

Instantly share code, notes, and snippets.

View bdw's full-sized avatar
💭
Hacking

Bart Wiegmans bdw

💭
Hacking
View GitHub Profile
@dogbert17
dogbert17 / euler-12.raku
Created October 7, 2021 12:57
Runs faster with expr-jit turned off
# What is the value of the first triangle number to have over five hundred divisors?
use v6;
my $numFactors = 500;
my $sum = 0;
for (1...*) -> $term {
$sum += $term;
my $factors = (1..floor(sqrt($sum))).grep( -> $x { $sum % $x == 0} ).elems * 2;
$factors-- if floor(sqrt($sum)) == sqrt($sum);
if $factors > $numFactors {
@bduggan
bduggan / rsa.p6
Last active October 12, 2016 14:48
sub random-prime(:$digits) {
repeat { $_ = (10**$digits .. (10**($digits+1))).pick } until .is-prime;
return $_;
}
sub encrypt(:$message, :$key) {
return expmod($message,$key[0],$key[1])
}
sub decrypt(:$message, :$key) {
Jun 15 09:08:29 test-t 50000 39.842 39.754
Jun 23 09:37:11 test-t 50000 43.348 43.262
Jun 26 09:58:21 test-t 50000 43.672 43.583
Jul 03 08:17:48 test-t 50000 42.542 42.454
Jul 10 08:53:26 test-t 50000 46.206 46.117
Jul 10 08:53:40 test-t 50000 47.031 46.939
Jul 12 11:12:51 test-t 50000 44.422 44.334
Jul 13 10:47:07 test-t 50000 46.427 46.337
Jul 22 21:49:44 test-t 50000 45.060 44.967
Jul 28 20:49:37 test-t 50000 46.398 46.300
@jnthn
jnthn / s17-changes.md
Last active October 13, 2015 02:59
Overview of planned some S17 changes, for community review

Changes and syntactic relief for S17

This document describes the eventual intended semantics of await, lays out some syntactic relief for working with supplies, considers the status of channels, and proposes the end of the syntax formerly known as earliest, winner, etc. - which I've never really liked. One further area to be covered in a similar document to this is cancellation.

Feedback welcome! -- jnthn

@emil-perhinschi
emil-perhinschi / native_call.p6
Created June 26, 2014 21:46
perl6 native call libgsl segmentation fault
emilper@main:~/bin/nqp$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.2-19ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-