task_url stringlengths 30 116 | task_name stringlengths 2 86 | task_description stringlengths 0 14.4k | language_url stringlengths 2 53 | language_name stringlengths 1 52 | code stringlengths 0 61.9k |
|---|---|---|---|---|---|
http://rosettacode.org/wiki/Pseudo-random_numbers/Splitmix64 | Pseudo-random numbers/Splitmix64 | Splitmix64 is the default pseudo-random number generator algorithm in Java and is included / available in many other languages. It uses a fairly simple algorithm that, though it is considered to be poor for cryptographic purposes, is very fast to calculate, and is "good enough" for many random number needs. It passes s... | #11l | 11l | T Splitmix64
UInt64 state
F seed(seed_state)
.state = seed_state
F next_int()
.state += 9E37'79B9'7F4A'7C15
V z = .state
z = (z (+) (z >> 30)) * BF58'476D'1CE4'E5B9
z = (z (+) (z >> 27)) * 94D0'49BB'1331'11EB
R z (+) (z >> 31)
F next_float()
R Float(.next_int(... |
http://rosettacode.org/wiki/Pseudo-random_numbers/Middle-square_method | Pseudo-random numbers/Middle-square method | Middle-square_method Generator
The Method
To generate a sequence of n-digit pseudorandom numbers, an n-digit starting value is created and squared, producing a 2n-digit number. If the result has fewer than 2n digits, leading zeroes are added to compensate. The middle n digits of the result would be the next number i... | #C.2B.2B | C++ | #include <exception>
#include <iostream>
using ulong = unsigned long;
class MiddleSquare {
private:
ulong state;
ulong div, mod;
public:
MiddleSquare() = delete;
MiddleSquare(ulong start, ulong length) {
if (length % 2) throw std::invalid_argument("length must be even");
div = mod = ... |
http://rosettacode.org/wiki/Pseudo-random_numbers/Middle-square_method | Pseudo-random numbers/Middle-square method | Middle-square_method Generator
The Method
To generate a sequence of n-digit pseudorandom numbers, an n-digit starting value is created and squared, producing a 2n-digit number. If the result has fewer than 2n digits, leading zeroes are added to compensate. The middle n digits of the result would be the next number i... | #CLU | CLU | middle_square = cluster is seed, next
rep = null
own state: int
seed = proc (s: int)
state := s
end seed
next = proc () returns (int)
state := (state ** 2) / 1000 // 1000000
return(state)
end next
end middle_square
start_up = proc ()
po: stream := stream$primary... |
http://rosettacode.org/wiki/Pseudo-random_numbers/Xorshift_star | Pseudo-random numbers/Xorshift star | Some definitions to help in the explanation
Floor operation
https://en.wikipedia.org/wiki/Floor_and_ceiling_functions
Greatest integer less than or equal to a real number.
Bitwise Logical shift operators (c-inspired)
https://en.wikipedia.org/wiki/Bitwise_operation#Bit_shifts
Binary bits of value shifted left or ri... | #Lua | Lua | function create()
local g = {
magic = 0x2545F4914F6CDD1D,
state = 0,
seed = function(self, num)
self.state = num
end,
next_int = function(self)
local x = self.state
x = x ~ (x >> 12)
x = x ~ (x << 25)
x = x ~ (x >> 2... |
http://rosettacode.org/wiki/Quine | Quine | A quine is a self-referential program that can,
without any external access, output its own source.
A quine (named after Willard Van Orman Quine) is also known as:
self-reproducing automata (1972)
self-replicating program or self-replicating computer program
self-reproducing program ... | #OxygenBasic | OxygenBasic | 'RUNTIME COMPILING
source="print source"
a=compile source : call a : freememory a |
http://rosettacode.org/wiki/Pseudo-random_numbers/PCG32 | Pseudo-random numbers/PCG32 | Some definitions to help in the explanation
Floor operation
https://en.wikipedia.org/wiki/Floor_and_ceiling_functions
Greatest integer less than or equal to a real number.
Bitwise Logical shift operators (c-inspired)
https://en.wikipedia.org/wiki/Bitwise_operation#Bit_shifts
Binary bits of value shifted left or ri... | #D | D | import std.math;
import std.stdio;
struct PCG32 {
private:
immutable ulong N = 6364136223846793005;
ulong state = 0x853c49e6748fea9b;
ulong inc = 0xda3e39cb94b95bdb;
public:
void seed(ulong seed_state, ulong seed_sequence) {
state = 0;
inc = (seed_sequence << 1) | 1;
nextInt(... |
http://rosettacode.org/wiki/Pythagorean_quadruples | Pythagorean quadruples |
One form of Pythagorean quadruples is (for positive integers a, b, c, and d):
a2 + b2 + c2 = d2
An example:
22 + 32 + 62 = 72
which is:
4 + 9 + 36 = 49
Task
For positive integers up 2,200 (inclusive), for all values of ... | #C | C | #include <stdio.h>
#include <math.h>
#include <string.h>
#define N 2200
int main(int argc, char **argv){
int a,b,c,d;
int r[N+1];
memset(r,0,sizeof(r)); // zero solution array
for(a=1; a<=N; a++){
for(b=a; b<=N; b++){
int aabb;
if(a&1 && b&1) continue; // for positive odd a and b, no solution... |
http://rosettacode.org/wiki/Pythagoras_tree | Pythagoras tree |
The Pythagoras tree is a fractal tree constructed from squares. It is named after Pythagoras because each triple of touching squares encloses a right triangle, in a configuration traditionally used to represent the Pythagorean theorem.
Task
Construct a Pythagoras tree of order 7 using only vectors (no rotation or ... | #AutoHotkey | AutoHotkey | pToken := Gdip_Startup()
gdip1()
Pythagoras_tree(600, 600, 712, 600, 1)
UpdateLayeredWindow(hwnd1, hdc, 0, 0, Width, Height)
OnExit, Exit
return
Pythagoras_tree(x1, y1, x2, y2, depth){
global G, hwnd1, hdc, Width, Height
if (depth > 7)
Return
Pen := Gdip_CreatePen(0xFF808080, 1)
Brush1 := Gd... |
http://rosettacode.org/wiki/Pseudo-random_numbers/Splitmix64 | Pseudo-random numbers/Splitmix64 | Splitmix64 is the default pseudo-random number generator algorithm in Java and is included / available in many other languages. It uses a fairly simple algorithm that, though it is considered to be poor for cryptographic purposes, is very fast to calculate, and is "good enough" for many random number needs. It passes s... | #Ada | Ada | with Interfaces; use Interfaces;
package Random_Splitmix64 is
function next_Int return Unsigned_64;
function next_float return Float;
procedure Set_State (Seed : in Unsigned_64);
end Random_Splitmix64; |
http://rosettacode.org/wiki/Pseudo-random_numbers/Splitmix64 | Pseudo-random numbers/Splitmix64 | Splitmix64 is the default pseudo-random number generator algorithm in Java and is included / available in many other languages. It uses a fairly simple algorithm that, though it is considered to be poor for cryptographic purposes, is very fast to calculate, and is "good enough" for many random number needs. It passes s... | #ALGOL_68 | ALGOL 68 | BEGIN # generate some pseudo random numbers using Splitmix64 #
# note that although LONG INT is 64 bits in Algol 68G, LONG BITS is longer than 64 bits #
LONG BITS mask 64 = LONG 16rffffffffffffffff;
LONG BITS state := 16r1234567;
LONG INT one shl 64 = ABS ( LONG 16r1 SHL 64 );
# sets the sta... |
http://rosettacode.org/wiki/Pseudo-random_numbers/Middle-square_method | Pseudo-random numbers/Middle-square method | Middle-square_method Generator
The Method
To generate a sequence of n-digit pseudorandom numbers, an n-digit starting value is created and squared, producing a 2n-digit number. If the result has fewer than 2n digits, leading zeroes are added to compensate. The middle n digits of the result would be the next number i... | #COBOL | COBOL | IDENTIFICATION DIVISION.
PROGRAM-ID. MIDDLE-SQUARE.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 STATE.
03 SEED PIC 9(6) VALUE 675248.
03 SQUARE PIC 9(12).
03 FILLER REDEFINES SQUARE.
05 FILLER PIC 9(3).
05... |
http://rosettacode.org/wiki/Pseudo-random_numbers/Middle-square_method | Pseudo-random numbers/Middle-square method | Middle-square_method Generator
The Method
To generate a sequence of n-digit pseudorandom numbers, an n-digit starting value is created and squared, producing a 2n-digit number. If the result has fewer than 2n digits, leading zeroes are added to compensate. The middle n digits of the result would be the next number i... | #F.23 | F# |
// Pseudo-random numbers/Middle-square method. Nigel Galloway: January 5th., 2022
Seq.unfold(fun n->let n=n*n%1000000000L/1000L in Some(n,n)) 675248L|>Seq.take 5|>Seq.iter(printfn "%d")
|
http://rosettacode.org/wiki/Pseudo-random_numbers/Xorshift_star | Pseudo-random numbers/Xorshift star | Some definitions to help in the explanation
Floor operation
https://en.wikipedia.org/wiki/Floor_and_ceiling_functions
Greatest integer less than or equal to a real number.
Bitwise Logical shift operators (c-inspired)
https://en.wikipedia.org/wiki/Bitwise_operation#Bit_shifts
Binary bits of value shifted left or ri... | #Nim | Nim | import algorithm, sequtils, strutils, tables
const C = 0x2545F4914F6CDD1Du64
type XorShift = object
state: uint64
func seed(gen: var XorShift; num: uint64) =
gen.state = num
func nextInt(gen: var XorShift): uint32 =
var x = gen.state
x = x xor x shr 12
x = x xor x shl 25
x = x xor x shr 27
gen.sta... |
http://rosettacode.org/wiki/Pseudo-random_numbers/Xorshift_star | Pseudo-random numbers/Xorshift star | Some definitions to help in the explanation
Floor operation
https://en.wikipedia.org/wiki/Floor_and_ceiling_functions
Greatest integer less than or equal to a real number.
Bitwise Logical shift operators (c-inspired)
https://en.wikipedia.org/wiki/Bitwise_operation#Bit_shifts
Binary bits of value shifted left or ri... | #Perl | Perl | use strict;
use warnings;
no warnings 'portable';
use feature 'say';
use Math::AnyNum qw(:overload);
package Xorshift_star {
sub new {
my ($class, %opt) = @_;
bless {state => $opt{seed}}, $class;
}
sub next_int {
my ($self) = @_;
my $state = $self->{state};
$sta... |
http://rosettacode.org/wiki/Quine | Quine | A quine is a self-referential program that can,
without any external access, output its own source.
A quine (named after Willard Van Orman Quine) is also known as:
self-reproducing automata (1972)
self-replicating program or self-replicating computer program
self-reproducing program ... | #Oz | Oz | declare I in thread {System.showInfo I#[34]#I#[34]} end I ="declare I in thread {System.showInfo I#[34]#I#[34]} end I =" |
http://rosettacode.org/wiki/Pseudo-random_numbers/PCG32 | Pseudo-random numbers/PCG32 | Some definitions to help in the explanation
Floor operation
https://en.wikipedia.org/wiki/Floor_and_ceiling_functions
Greatest integer less than or equal to a real number.
Bitwise Logical shift operators (c-inspired)
https://en.wikipedia.org/wiki/Bitwise_operation#Bit_shifts
Binary bits of value shifted left or ri... | #Delphi | Delphi |
program PCG32_test;
{$APPTYPE CONSOLE}
uses
System.SysUtils,
Velthuis.BigIntegers,
System.Generics.Collections;
type
TPCG32 = class
public
FState: BigInteger;
FInc: BigInteger;
mask64: BigInteger;
mask32: BigInteger;
k: BigInteger;
constructor Create(seedState, seedSequence: BigI... |
http://rosettacode.org/wiki/Pythagorean_quadruples | Pythagorean quadruples |
One form of Pythagorean quadruples is (for positive integers a, b, c, and d):
a2 + b2 + c2 = d2
An example:
22 + 32 + 62 = 72
which is:
4 + 9 + 36 = 49
Task
For positive integers up 2,200 (inclusive), for all values of ... | #C.23 | C# | using System;
namespace PythagoreanQuadruples {
class Program {
const int MAX = 2200;
const int MAX2 = MAX * MAX * 2;
static void Main(string[] args) {
bool[] found = new bool[MAX + 1]; // all false by default
bool[] a2b2 = new bool[MAX2 + 1]; // ditto
... |
http://rosettacode.org/wiki/Pythagoras_tree | Pythagoras tree |
The Pythagoras tree is a fractal tree constructed from squares. It is named after Pythagoras because each triple of touching squares encloses a right triangle, in a configuration traditionally used to represent the Pythagorean theorem.
Task
Construct a Pythagoras tree of order 7 using only vectors (no rotation or ... | #BASIC256 | BASIC256 |
Subroutine pythagoras_tree(x1, y1, x2, y2, depth)
If depth > 10 Then Return
dx = x2 - x1 : dy = y1 - y2
x3 = x2 - dy : y3 = y2 - dx
x4 = x1 - dy : y4 = y1 - dx
x5 = x4 + (dx - dy) / 2
y5 = y4 - (dx + dy) / 2
#draw the box
Line x1, y1, x2, y2 : Line x2, y2, x3, y3
Line x3, y3, x4, y4 : Line x4, y4, x1, y1
... |
http://rosettacode.org/wiki/Pythagoras_tree | Pythagoras tree |
The Pythagoras tree is a fractal tree constructed from squares. It is named after Pythagoras because each triple of touching squares encloses a right triangle, in a configuration traditionally used to represent the Pythagorean theorem.
Task
Construct a Pythagoras tree of order 7 using only vectors (no rotation or ... | #C | C |
#include<graphics.h>
#include<stdlib.h>
#include<stdio.h>
#include<time.h>
typedef struct{
double x,y;
}point;
void pythagorasTree(point a,point b,int times){
point c,d,e;
c.x = b.x - (a.y - b.y);
c.y = b.y - (b.x - a.x);
d.x = a.x - (a.y - b.y);
d.y = a.y - (b.x - a.x);
e.x = d.x + ( b.x - a.x ... |
http://rosettacode.org/wiki/Pseudo-random_numbers/Splitmix64 | Pseudo-random numbers/Splitmix64 | Splitmix64 is the default pseudo-random number generator algorithm in Java and is included / available in many other languages. It uses a fairly simple algorithm that, though it is considered to be poor for cryptographic purposes, is very fast to calculate, and is "good enough" for many random number needs. It passes s... | #C | C | /* Written in 2015 by Sebastiano Vigna (vigna@acm.org)
To the extent possible under law, the author has dedicated all copyright
and related and neighboring rights to this software to the public domain
worldwide. This software is distributed without any warranty.
See <http://creativecommons.org/publicdomain/zero/1.... |
http://rosettacode.org/wiki/Pseudo-random_numbers/Middle-square_method | Pseudo-random numbers/Middle-square method | Middle-square_method Generator
The Method
To generate a sequence of n-digit pseudorandom numbers, an n-digit starting value is created and squared, producing a 2n-digit number. If the result has fewer than 2n digits, leading zeroes are added to compensate. The middle n digits of the result would be the next number i... | #Factor | Factor | USING: kernel math namespaces prettyprint ;
SYMBOL: seed
675248 seed set-global
: rand ( -- n ) seed get sq 1000 /i 1000000 mod dup seed set ;
5 [ rand . ] times |
http://rosettacode.org/wiki/Pseudo-random_numbers/Middle-square_method | Pseudo-random numbers/Middle-square method | Middle-square_method Generator
The Method
To generate a sequence of n-digit pseudorandom numbers, an n-digit starting value is created and squared, producing a 2n-digit number. If the result has fewer than 2n digits, leading zeroes are added to compensate. The middle n digits of the result would be the next number i... | #Forth | Forth | : next-random dup * 1000 / 1000000 mod ;
: 5-random-num 5 0 do next-random dup . loop ;
675248 5-random-num |
http://rosettacode.org/wiki/Pseudo-random_numbers/Middle-square_method | Pseudo-random numbers/Middle-square method | Middle-square_method Generator
The Method
To generate a sequence of n-digit pseudorandom numbers, an n-digit starting value is created and squared, producing a 2n-digit number. If the result has fewer than 2n digits, leading zeroes are added to compensate. The middle n digits of the result would be the next number i... | #FreeBASIC | FreeBASIC | Dim Shared seed As Integer = 675248
Dim i As Integer
Declare Function Rand As Integer
For i = 1 To 5
Print Rand
Next i
Sleep
Function Rand As Integer
Dim s As String
s = Str(seed ^ 2)
Do While Len(s) <> 12
s = "0" + s
Loop
seed = Val(Mid(s, 4, 6))
Rand = seed
End Function
|
http://rosettacode.org/wiki/Pseudo-random_numbers/Xorshift_star | Pseudo-random numbers/Xorshift star | Some definitions to help in the explanation
Floor operation
https://en.wikipedia.org/wiki/Floor_and_ceiling_functions
Greatest integer less than or equal to a real number.
Bitwise Logical shift operators (c-inspired)
https://en.wikipedia.org/wiki/Bitwise_operation#Bit_shifts
Binary bits of value shifted left or ri... | #Phix | Phix | with javascript_semantics
include mpfr.e
mpz cmult = mpz_init("0x2545F4914F6CDD1D"),
state = mpz_init(),
b64 = mpz_init("0x10000000000000000"), -- (truncate to 64 bits)
b32 = mpz_init("0x100000000"), -- (truncate to 32 bits)
tmp = mpz_init(),
x = mpz_init()
procedure seed(inte... |
http://rosettacode.org/wiki/Quine | Quine | A quine is a self-referential program that can,
without any external access, output its own source.
A quine (named after Willard Van Orman Quine) is also known as:
self-reproducing automata (1972)
self-replicating program or self-replicating computer program
self-reproducing program ... | #PARI.2FGP | PARI/GP | ()->quine |
http://rosettacode.org/wiki/Pseudo-random_numbers/PCG32 | Pseudo-random numbers/PCG32 | Some definitions to help in the explanation
Floor operation
https://en.wikipedia.org/wiki/Floor_and_ceiling_functions
Greatest integer less than or equal to a real number.
Bitwise Logical shift operators (c-inspired)
https://en.wikipedia.org/wiki/Bitwise_operation#Bit_shifts
Binary bits of value shifted left or ri... | #F.23 | F# |
// PCG32. Nigel Galloway: August 13th., 2020
let N=6364136223846793005UL
let seed n g=let g=g<<<1|||1UL in (g,(g+n)*N+g)
let pcg32=Seq.unfold(fun(n,g)->let rot,xs=uint32(g>>>59),uint32(((g>>>18)^^^g)>>>27) in Some(uint32((xs>>>(int rot))|||(xs<<<(-(int rot)&&&31))),(n,g*N+n)))
let pcgFloat n=pcg32 n|>Seq.map(fun n-> ... |
http://rosettacode.org/wiki/Pythagorean_quadruples | Pythagorean quadruples |
One form of Pythagorean quadruples is (for positive integers a, b, c, and d):
a2 + b2 + c2 = d2
An example:
22 + 32 + 62 = 72
which is:
4 + 9 + 36 = 49
Task
For positive integers up 2,200 (inclusive), for all values of ... | #C.2B.2B | C++ | #include <iostream>
#include <vector>
constexpr int N = 2200;
constexpr int N2 = 2 * N * N;
int main() {
using namespace std;
vector<bool> found(N + 1);
vector<bool> aabb(N2 + 1);
int s = 3;
for (int a = 1; a < N; ++a) {
int aa = a * a;
for (int b = 1; b < N; ++b) {
... |
http://rosettacode.org/wiki/Pythagoras_tree | Pythagoras tree |
The Pythagoras tree is a fractal tree constructed from squares. It is named after Pythagoras because each triple of touching squares encloses a right triangle, in a configuration traditionally used to represent the Pythagorean theorem.
Task
Construct a Pythagoras tree of order 7 using only vectors (no rotation or ... | #C.2B.2B | C++ | #include <windows.h>
#include <string>
#include <iostream>
const int BMP_SIZE = 720, LINE_LEN = 120, BORDER = 100;
class myBitmap {
public:
myBitmap() : pen( NULL ), brush( NULL ), clr( 0 ), wid( 1 ) {}
~myBitmap() {
DeleteObject( pen ); DeleteObject( brush );
DeleteDC( hdc ); DeleteObject( ... |
http://rosettacode.org/wiki/Pseudo-random_numbers/Splitmix64 | Pseudo-random numbers/Splitmix64 | Splitmix64 is the default pseudo-random number generator algorithm in Java and is included / available in many other languages. It uses a fairly simple algorithm that, though it is considered to be poor for cryptographic purposes, is very fast to calculate, and is "good enough" for many random number needs. It passes s... | #Factor | Factor | USING: io kernel math math.bitwise math.functions
math.statistics namespaces prettyprint sequences ;
SYMBOL: state
: seed ( n -- ) 64 bits state set ;
: next-int ( -- n )
0x9e3779b97f4a7c15 state [ + 64 bits ] change
state get -30 0xbf58476d1ce4e5b9 -27 0x94d049bb133111eb -31 1
[ [ dupd shift bitxor ]... |
http://rosettacode.org/wiki/Pseudo-random_numbers/Splitmix64 | Pseudo-random numbers/Splitmix64 | Splitmix64 is the default pseudo-random number generator algorithm in Java and is included / available in many other languages. It uses a fairly simple algorithm that, though it is considered to be poor for cryptographic purposes, is very fast to calculate, and is "good enough" for many random number needs. It passes s... | #Forth | Forth | variable rnd-state
: rnd-base-op ( z factor shift -- u ) 2 pick swap rshift rot xor * ;
: rnd-next ( -- u )
$9e3779b97f4a7c15 rnd-state +!
rnd-state @
$bf58476d1ce4e5b9 #30 rnd-base-op
$94d049bb133111eb #27 rnd-base-op
#1 #31 rnd-base-op
;
#1234567 rnd-state !
cr
rnd-next u. cr
rnd-next u. cr
rnd-next u... |
http://rosettacode.org/wiki/Pseudo-random_numbers/Middle-square_method | Pseudo-random numbers/Middle-square method | Middle-square_method Generator
The Method
To generate a sequence of n-digit pseudorandom numbers, an n-digit starting value is created and squared, producing a 2n-digit number. If the result has fewer than 2n digits, leading zeroes are added to compensate. The middle n digits of the result would be the next number i... | #Go | Go | package main
import "fmt"
func random(seed int) int {
return seed * seed / 1e3 % 1e6
}
func main() {
seed := 675248
for i := 1; i <= 5; i++ {
seed = random(seed)
fmt.Println(seed)
}
} |
http://rosettacode.org/wiki/Pseudo-random_numbers/Middle-square_method | Pseudo-random numbers/Middle-square method | Middle-square_method Generator
The Method
To generate a sequence of n-digit pseudorandom numbers, an n-digit starting value is created and squared, producing a 2n-digit number. If the result has fewer than 2n digits, leading zeroes are added to compensate. The middle n digits of the result would be the next number i... | #Haskell | Haskell | findPseudoRandom :: Int -> Int
findPseudoRandom seed =
let square = seed * seed
squarestr = show square
enlarged = replicate ( 12 - length squarestr ) '0' ++ squarestr
in read $ take 6 $ drop 3 enlarged
solution :: [Int]
solution = tail $ take 6 $ iterate findPseudoRandom 675248 |
http://rosettacode.org/wiki/Pseudo-random_numbers/Xorshift_star | Pseudo-random numbers/Xorshift star | Some definitions to help in the explanation
Floor operation
https://en.wikipedia.org/wiki/Floor_and_ceiling_functions
Greatest integer less than or equal to a real number.
Bitwise Logical shift operators (c-inspired)
https://en.wikipedia.org/wiki/Bitwise_operation#Bit_shifts
Binary bits of value shifted left or ri... | #Python | Python | mask64 = (1 << 64) - 1
mask32 = (1 << 32) - 1
const = 0x2545F4914F6CDD1D
class Xorshift_star():
def __init__(self, seed=0):
self.state = seed & mask64
def seed(self, num):
self.state = num & mask64
def next_int(self):
"return random int between 0 and 2**32"
x = s... |
http://rosettacode.org/wiki/Quine | Quine | A quine is a self-referential program that can,
without any external access, output its own source.
A quine (named after Willard Van Orman Quine) is also known as:
self-reproducing automata (1972)
self-replicating program or self-replicating computer program
self-reproducing program ... | #Pascal | Pascal | const s=';begin writeln(#99#111#110#115#116#32#115#61#39,s,#39,s)end.';begin writeln(#99#111#110#115#116#32#115#61#39,s,#39,s)end. |
http://rosettacode.org/wiki/Pseudo-random_numbers/PCG32 | Pseudo-random numbers/PCG32 | Some definitions to help in the explanation
Floor operation
https://en.wikipedia.org/wiki/Floor_and_ceiling_functions
Greatest integer less than or equal to a real number.
Bitwise Logical shift operators (c-inspired)
https://en.wikipedia.org/wiki/Bitwise_operation#Bit_shifts
Binary bits of value shifted left or ri... | #Factor | Factor | USING: accessors kernel locals math math.bitwise math.statistics
prettyprint sequences ;
CONSTANT: const 6364136223846793005
TUPLE: pcg32 state inc ;
: <pcg32> ( -- pcg32 )
0x853c49e6748fea9b 0xda3e39cb94b95bdb pcg32 boa ;
:: next-int ( pcg -- n )
pcg state>> :> old
old const * pcg inc>> + 64 bits p... |
http://rosettacode.org/wiki/Pseudo-random_numbers/PCG32 | Pseudo-random numbers/PCG32 | Some definitions to help in the explanation
Floor operation
https://en.wikipedia.org/wiki/Floor_and_ceiling_functions
Greatest integer less than or equal to a real number.
Bitwise Logical shift operators (c-inspired)
https://en.wikipedia.org/wiki/Bitwise_operation#Bit_shifts
Binary bits of value shifted left or ri... | #Go | Go | package main
import (
"fmt"
"math"
)
const CONST = 6364136223846793005
type Pcg32 struct{ state, inc uint64 }
func Pcg32New() *Pcg32 { return &Pcg32{0x853c49e6748fea9b, 0xda3e39cb94b95bdb} }
func (pcg *Pcg32) seed(seedState, seedSequence uint64) {
pcg.state = 0
pcg.inc = (seedSequence << 1) | ... |
http://rosettacode.org/wiki/Pythagorean_quadruples | Pythagorean quadruples |
One form of Pythagorean quadruples is (for positive integers a, b, c, and d):
a2 + b2 + c2 = d2
An example:
22 + 32 + 62 = 72
which is:
4 + 9 + 36 = 49
Task
For positive integers up 2,200 (inclusive), for all values of ... | #Crystal | Crystal | n = 2200
l_add, l = Hash(Int32, Bool).new(false), Hash(Int32, Bool).new(false)
(1..n).each do |x|
x2 = x * x
(x..n).each { |y| l_add[x2 + y * y] = true }
end
s = 3
(1..n).each do |x|
s1 = s
s += 2
s2 = s
((x+1)..n).each do |y|
l[y] = true if l_add[s1]
s1 += s2
s2 += 2
end
end
puts (1..n)... |
http://rosettacode.org/wiki/Pythagoras_tree | Pythagoras tree |
The Pythagoras tree is a fractal tree constructed from squares. It is named after Pythagoras because each triple of touching squares encloses a right triangle, in a configuration traditionally used to represent the Pythagorean theorem.
Task
Construct a Pythagoras tree of order 7 using only vectors (no rotation or ... | #EasyLang | EasyLang | func tree x1 y1 x2 y2 depth . .
if depth < 8
dx = x2 - x1
dy = y1 - y2
x3 = x2 - dy
y3 = y2 - dx
x4 = x1 - dy
y4 = y1 - dx
x5 = x4 + 0.5 * (dx - dy)
y5 = y4 - 0.5 * (dx + dy)
color3 0.3 0.2 + depth / 18 0.1
polygon [ x1 y1 x2 y2 x3 y3 x4 y4 ]
polygon [ x3 y3 x4 y4 x5 y5 ]
... |
http://rosettacode.org/wiki/Pseudo-random_numbers/Splitmix64 | Pseudo-random numbers/Splitmix64 | Splitmix64 is the default pseudo-random number generator algorithm in Java and is included / available in many other languages. It uses a fairly simple algorithm that, though it is considered to be poor for cryptographic purposes, is very fast to calculate, and is "good enough" for many random number needs. It passes s... | #F.23 | F# | // Pure F# Implementation of SplitMix64
let a: uint64 = 0x9e3779b97f4a7c15UL
let nextInt (state: uint64) =
let newstate = state + (0x9e3779b97f4a7c15UL)
let rand = newstate
let rand = (rand ^^^ (rand >>> 30)) * 0xbf58476d1ce4e5b9UL
let rand = (rand ^^^ (rand >>> 27)) * 0x94d049bb133111ebUL
let ran... |
http://rosettacode.org/wiki/Pseudo-random_numbers/Splitmix64 | Pseudo-random numbers/Splitmix64 | Splitmix64 is the default pseudo-random number generator algorithm in Java and is included / available in many other languages. It uses a fairly simple algorithm that, though it is considered to be poor for cryptographic purposes, is very fast to calculate, and is "good enough" for many random number needs. It passes s... | #Go | Go | package main
import (
"fmt"
"math"
)
type Splitmix64 struct{ state uint64 }
func Splitmix64New(state uint64) *Splitmix64 { return &Splitmix64{state} }
func (sm64 *Splitmix64) nextInt() uint64 {
sm64.state += 0x9e3779b97f4a7c15
z := sm64.state
z = (z ^ (z >> 30)) * 0xbf58476d1ce4e5b9
z = ... |
http://rosettacode.org/wiki/Pseudo-random_numbers/Middle-square_method | Pseudo-random numbers/Middle-square method | Middle-square_method Generator
The Method
To generate a sequence of n-digit pseudorandom numbers, an n-digit starting value is created and squared, producing a 2n-digit number. If the result has fewer than 2n digits, leading zeroes are added to compensate. The middle n digits of the result would be the next number i... | #J | J | (_6{._3}.])&.:(10&#.^:_1)@(*~) ^: (>:i.6) 675248 |
http://rosettacode.org/wiki/Pseudo-random_numbers/Middle-square_method | Pseudo-random numbers/Middle-square method | Middle-square_method Generator
The Method
To generate a sequence of n-digit pseudorandom numbers, an n-digit starting value is created and squared, producing a 2n-digit number. If the result has fewer than 2n digits, leading zeroes are added to compensate. The middle n digits of the result would be the next number i... | #jq | jq | # Input: a positive integer
# Output: the "middle-square"
def middle_square:
(tostring|length) as $len
| (. * .)
| tostring
| (3*length/4|ceil) as $n
| .[ -$n : $len-$n]
| if length == 0 then 0 else tonumber end;
# Input: a positive integer
# Output: middle_square, applied recursively
def middle_squares:
... |
http://rosettacode.org/wiki/Pseudo-random_numbers/Middle-square_method | Pseudo-random numbers/Middle-square method | Middle-square_method Generator
The Method
To generate a sequence of n-digit pseudorandom numbers, an n-digit starting value is created and squared, producing a 2n-digit number. If the result has fewer than 2n digits, leading zeroes are added to compensate. The middle n digits of the result would be the next number i... | #Julia | Julia | const seed = [675248]
function random()
s = string(seed[] * seed[], pad=12) # turn a number into string, pad to 12 digits
seed[] = parse(Int, s[begin+3:end-3]) # take middle of number string, parse to Int
return seed[]
end
# Middle-square method use
for i = 1:5
println(random())
end
|
http://rosettacode.org/wiki/Pseudo-random_numbers/Middle-square_method | Pseudo-random numbers/Middle-square method | Middle-square_method Generator
The Method
To generate a sequence of n-digit pseudorandom numbers, an n-digit starting value is created and squared, producing a 2n-digit number. If the result has fewer than 2n digits, leading zeroes are added to compensate. The middle n digits of the result would be the next number i... | #Nim | Nim | proc rand:int =
var seed {.global.} = 675248
seed = int(seed*seed) div 1000 mod 1000000
return seed
for _ in 1..5: echo rand() |
http://rosettacode.org/wiki/Pseudo-random_numbers/Xorshift_star | Pseudo-random numbers/Xorshift star | Some definitions to help in the explanation
Floor operation
https://en.wikipedia.org/wiki/Floor_and_ceiling_functions
Greatest integer less than or equal to a real number.
Bitwise Logical shift operators (c-inspired)
https://en.wikipedia.org/wiki/Bitwise_operation#Bit_shifts
Binary bits of value shifted left or ri... | #Raku | Raku | class Xorshift-star {
has $!state;
submethod BUILD ( Int :$seed where * > 0 = 1 ) { $!state = $seed }
method next-int {
$!state +^= $!state +> 12;
$!state +^= $!state +< 25 +& (2⁶⁴ - 1);
$!state +^= $!state +> 27;
($!state * 0x2545F4914F6CDD1D) +> 32 +& (2³² - 1)
}
... |
http://rosettacode.org/wiki/Quine | Quine | A quine is a self-referential program that can,
without any external access, output its own source.
A quine (named after Willard Van Orman Quine) is also known as:
self-reproducing automata (1972)
self-replicating program or self-replicating computer program
self-reproducing program ... | #Perl | Perl | $s = q($s = q(%s); printf($s, $s);
); printf($s, $s);
|
http://rosettacode.org/wiki/Pseudo-random_numbers/PCG32 | Pseudo-random numbers/PCG32 | Some definitions to help in the explanation
Floor operation
https://en.wikipedia.org/wiki/Floor_and_ceiling_functions
Greatest integer less than or equal to a real number.
Bitwise Logical shift operators (c-inspired)
https://en.wikipedia.org/wiki/Bitwise_operation#Bit_shifts
Binary bits of value shifted left or ri... | #Haskell | Haskell | import Data.Bits
import Data.Word
import System.Random
import Data.List
data PCGen = PCGen !Word64 !Word64
mkPCGen state sequence =
let
n = 6364136223846793005 :: Word64
inc = (sequence `shiftL` 1) .|. 1 :: Word64
in PCGen ((inc + state)*n + inc) inc
instance RandomGen PCGen where
next (PCGen s... |
http://rosettacode.org/wiki/Pythagorean_quadruples | Pythagorean quadruples |
One form of Pythagorean quadruples is (for positive integers a, b, c, and d):
a2 + b2 + c2 = d2
An example:
22 + 32 + 62 = 72
which is:
4 + 9 + 36 = 49
Task
For positive integers up 2,200 (inclusive), for all values of ... | #D | D | import std.bitmanip : BitArray;
import std.stdio;
enum N = 2_200;
enum N2 = 2*N*N;
void main() {
BitArray found;
found.length = N+1;
BitArray aabb;
aabb.length = N2+1;
uint s=3;
for (uint a=1; a<=N; ++a) {
uint aa = a*a;
for (uint b=1; b<N; ++b) {
aabb[aa + ... |
http://rosettacode.org/wiki/Pythagoras_tree | Pythagoras tree |
The Pythagoras tree is a fractal tree constructed from squares. It is named after Pythagoras because each triple of touching squares encloses a right triangle, in a configuration traditionally used to represent the Pythagorean theorem.
Task
Construct a Pythagoras tree of order 7 using only vectors (no rotation or ... | #F.23 | F# | type Point = { x:float; y:float }
type Line = { left : Point; right : Point }
let draw_start_html = """<!DOCTYPE html>
<html><head><title>Phytagoras tree</title>
<style type="text/css">polygon{fill:none;stroke:black;stroke-width:1}</style>
</head><body>
<svg width="640" height="640">"""
let draw_end_html = """Sorry... |
http://rosettacode.org/wiki/Pseudo-random_numbers/Splitmix64 | Pseudo-random numbers/Splitmix64 | Splitmix64 is the default pseudo-random number generator algorithm in Java and is included / available in many other languages. It uses a fairly simple algorithm that, though it is considered to be poor for cryptographic purposes, is very fast to calculate, and is "good enough" for many random number needs. It passes s... | #Haskell | Haskell | import Data.Bits
import Data.Word
import Data.List
next :: Word64 -> (Word64, Word64)
next state = f4 $ state + 0x9e3779b97f4a7c15
where
f1 z = (z `xor` (z `shiftR` 30)) * 0xbf58476d1ce4e5b9
f2 z = (z `xor` (z `shiftR` 27)) * 0x94d049bb133111eb
f3 z = z `xor` (z `shiftR` 31)
f4 s = ((f3 . f2 . f1) s... |
http://rosettacode.org/wiki/Pseudo-random_numbers/Splitmix64 | Pseudo-random numbers/Splitmix64 | Splitmix64 is the default pseudo-random number generator algorithm in Java and is included / available in many other languages. It uses a fairly simple algorithm that, though it is considered to be poor for cryptographic purposes, is very fast to calculate, and is "good enough" for many random number needs. It passes s... | #Julia | Julia | const C1 = 0x9e3779b97f4a7c15
const C2 = 0xbf58476d1ce4e5b9
const C3 = 0x94d049bb133111eb
mutable struct Splitmix64
state::UInt
end
""" return random int between 0 and 2**64 """
function next_int(smx::Splitmix64)
z = smx.state = smx.state + C1
z = (z ⊻ (z >> 30)) * C2
z = (z ⊻ (z >> 27)) * C3
re... |
http://rosettacode.org/wiki/Pseudo-random_numbers/Middle-square_method | Pseudo-random numbers/Middle-square method | Middle-square_method Generator
The Method
To generate a sequence of n-digit pseudorandom numbers, an n-digit starting value is created and squared, producing a 2n-digit number. If the result has fewer than 2n digits, leading zeroes are added to compensate. The middle n digits of the result would be the next number i... | #Perl | Perl | #!/usr/bin/perl
use strict; # https://rosettacode.org/wiki/Pseudo-random_numbers/Middle-square_method
use warnings;
sub msq
{
use feature qw( state );
state $seed = 675248;
$seed = sprintf "%06d", $seed ** 2 / 1000 % 1e6;
}
print msq, "\n" for 1 .. 5; |
http://rosettacode.org/wiki/Pseudo-random_numbers/Middle-square_method | Pseudo-random numbers/Middle-square method | Middle-square_method Generator
The Method
To generate a sequence of n-digit pseudorandom numbers, an n-digit starting value is created and squared, producing a 2n-digit number. If the result has fewer than 2n digits, leading zeroes are added to compensate. The middle n digits of the result would be the next number i... | #Phix | Phix | with javascript_semantics
integer seed = 675248
function random()
seed = remainder(floor(seed*seed/1000),1e6)
-- seed = to_integer(sprintf("%012d",seed*seed)[4..9])
return seed
end function
for i=1 to 5 do
?random()
end for
|
http://rosettacode.org/wiki/Pseudo-random_numbers/Xorshift_star | Pseudo-random numbers/Xorshift star | Some definitions to help in the explanation
Floor operation
https://en.wikipedia.org/wiki/Floor_and_ceiling_functions
Greatest integer less than or equal to a real number.
Bitwise Logical shift operators (c-inspired)
https://en.wikipedia.org/wiki/Bitwise_operation#Bit_shifts
Binary bits of value shifted left or ri... | #REXX | REXX | /*REXX program generates pseudo─random numbers using the XOR─shift─star method. */
numeric digits 200 /*ensure enough decimal digs for mult. */
parse arg n reps pick seed1 seed2 . /*obtain optional arguments from the CL*/
if n=='' | n=="," then n= ... |
http://rosettacode.org/wiki/Quine | Quine | A quine is a self-referential program that can,
without any external access, output its own source.
A quine (named after Willard Van Orman Quine) is also known as:
self-reproducing automata (1972)
self-replicating program or self-replicating computer program
self-reproducing program ... | #Phix | Phix | constant c="constant c=%sprintf(1,c,{34&c&34})"printf(1,c,{34&c&34})
|
http://rosettacode.org/wiki/Pseudo-random_numbers/PCG32 | Pseudo-random numbers/PCG32 | Some definitions to help in the explanation
Floor operation
https://en.wikipedia.org/wiki/Floor_and_ceiling_functions
Greatest integer less than or equal to a real number.
Bitwise Logical shift operators (c-inspired)
https://en.wikipedia.org/wiki/Bitwise_operation#Bit_shifts
Binary bits of value shifted left or ri... | #Java | Java | public class PCG32 {
private static final long N = 6364136223846793005L;
private long state = 0x853c49e6748fea9bL;
private long inc = 0xda3e39cb94b95bdbL;
public void seed(long seedState, long seedSequence) {
state = 0;
inc = (seedSequence << 1) | 1;
nextInt();
state ... |
http://rosettacode.org/wiki/Pythagorean_quadruples | Pythagorean quadruples |
One form of Pythagorean quadruples is (for positive integers a, b, c, and d):
a2 + b2 + c2 = d2
An example:
22 + 32 + 62 = 72
which is:
4 + 9 + 36 = 49
Task
For positive integers up 2,200 (inclusive), for all values of ... | #FreeBASIC | FreeBASIC | ' version 12-08-2017
' compile with: fbc -s console
#Define max 2200
Dim As UInteger l, m, n, l2, l2m2
Dim As UInteger limit = max * 4 \ 15
Dim As UInteger max2 = limit * limit * 2
ReDim As Ubyte list_1(max2), list_2(max2 +1)
' prime sieve, list_2(l) contains a 0 if l = prime
For l = 4 To max2 Step 2
list_1... |
http://rosettacode.org/wiki/Pythagoras_tree | Pythagoras tree |
The Pythagoras tree is a fractal tree constructed from squares. It is named after Pythagoras because each triple of touching squares encloses a right triangle, in a configuration traditionally used to represent the Pythagorean theorem.
Task
Construct a Pythagoras tree of order 7 using only vectors (no rotation or ... | #FreeBASIC | FreeBASIC | ' version 03-12-2016
' compile with: fbc -s gui
' or fbc -s console
Sub pythagoras_tree(x1 As Double, y1 As Double, x2 As Double, y2 As Double, depth As ULong)
If depth > 10 Then Return
Dim As Double dx = x2 - x1, dy = y1 - y2
Dim As Double x3 = x2 - dy, y3 = y2 - dx
Dim As Double x4 = x1 - dy, y... |
http://rosettacode.org/wiki/Pseudo-random_numbers/Splitmix64 | Pseudo-random numbers/Splitmix64 | Splitmix64 is the default pseudo-random number generator algorithm in Java and is included / available in many other languages. It uses a fairly simple algorithm that, though it is considered to be poor for cryptographic purposes, is very fast to calculate, and is "good enough" for many random number needs. It passes s... | #Mathematica.2FWolfram_Language | Mathematica/Wolfram Language | ClearAll[BitShiftLevelUint, MultiplyUint, GenerateRandomNumbers]
BitShiftLevelUint[z_, n_] := BitShiftRight[z, n]
MultiplyUint[z_, n_] := Mod[z n, 2^64]
GenerateRandomNumbers[st_, n_] := Module[{state = st},
Table[
state += 16^^9e3779b97f4a7c15;
state = Mod[state, 2^64];
z = state;
z = MultiplyUint[BitXor... |
http://rosettacode.org/wiki/Pseudo-random_numbers/Splitmix64 | Pseudo-random numbers/Splitmix64 | Splitmix64 is the default pseudo-random number generator algorithm in Java and is included / available in many other languages. It uses a fairly simple algorithm that, though it is considered to be poor for cryptographic purposes, is very fast to calculate, and is "good enough" for many random number needs. It passes s... | #Nim | Nim | import math, sequtils, strutils
const Two64 = 2.0^64
type Splitmix64 = object
state: uint64
func initSplitmix64(seed: uint64): Splitmix64 =
## Initialize a Splitmiax64 PRNG.
Splitmix64(state: seed)
func nextInt(r: var Splitmix64): uint64 =
## Return the next pseudorandom integer (actually a uint64 value... |
http://rosettacode.org/wiki/Pseudo-random_numbers/Splitmix64 | Pseudo-random numbers/Splitmix64 | Splitmix64 is the default pseudo-random number generator algorithm in Java and is included / available in many other languages. It uses a fairly simple algorithm that, though it is considered to be poor for cryptographic purposes, is very fast to calculate, and is "good enough" for many random number needs. It passes s... | #Perl | Perl | use strict;
use warnings;
no warnings 'portable';
use feature 'say';
use Math::AnyNum qw(:overload);
package splitmix64 {
sub new {
my ($class, %opt) = @_;
bless {state => $opt{seed}}, $class;
}
sub next_int {
my ($self) = @_;
my $next = $self->{state} = ($self->{state}... |
http://rosettacode.org/wiki/Pythagorean_triples | Pythagorean triples | A Pythagorean triple is defined as three positive integers
(
a
,
b
,
c
)
{\displaystyle (a,b,c)}
where
a
<
b
<
c
{\displaystyle a<b<c}
, and
a
2
+
b
2
=
c
2
.
{\displaystyle a^{2}+b^{2}=c^{2}.}
They are called primitive triples if
a
,
b
,
c
{\displaystyle a,b,c}
are co-prime,... | #11l | 11l | Int64 nTriples, nPrimitives, limit
F countTriples(Int64 =x, =y, =z)
L
V p = x + y + z
I p > :limit
R
:nPrimitives++
:nTriples += :limit I/ p
V t0 = x - 2 * y + 2 * z
V t1 = 2 * x - y + 2 * z
V t2 = t1 - y + z
countTriples(t0, t1, t2)
t0 += 4 * y
... |
http://rosettacode.org/wiki/Pseudo-random_numbers/Middle-square_method | Pseudo-random numbers/Middle-square method | Middle-square_method Generator
The Method
To generate a sequence of n-digit pseudorandom numbers, an n-digit starting value is created and squared, producing a 2n-digit number. If the result has fewer than 2n digits, leading zeroes are added to compensate. The middle n digits of the result would be the next number i... | #PureBasic | PureBasic | Procedure.i MSRandom()
Static.i seed=675248
seed = (seed*seed/1000)%1000000
ProcedureReturn seed
EndProcedure
If OpenConsole()
For i=1 To 5 : PrintN(Str(i)+": "+Str(MSRandom())) : Next
Input()
EndIf |
http://rosettacode.org/wiki/Pseudo-random_numbers/Middle-square_method | Pseudo-random numbers/Middle-square method | Middle-square_method Generator
The Method
To generate a sequence of n-digit pseudorandom numbers, an n-digit starting value is created and squared, producing a 2n-digit number. If the result has fewer than 2n digits, leading zeroes are added to compensate. The middle n digits of the result would be the next number i... | #Python | Python | seed = 675248
def random():
global seed
s = str(seed ** 2)
while len(s) != 12:
s = "0" + s
seed = int(s[3:9])
return seed
for i in range(0,5):
print(random())
|
http://rosettacode.org/wiki/Pseudo-random_numbers/Xorshift_star | Pseudo-random numbers/Xorshift star | Some definitions to help in the explanation
Floor operation
https://en.wikipedia.org/wiki/Floor_and_ceiling_functions
Greatest integer less than or equal to a real number.
Bitwise Logical shift operators (c-inspired)
https://en.wikipedia.org/wiki/Bitwise_operation#Bit_shifts
Binary bits of value shifted left or ri... | #Ruby | Ruby | class Xorshift_star
MASK64 = (1 << 64) - 1
MASK32 = (1 << 32) - 1
def initialize(seed = 0) = @state = seed & MASK64
def next_int
x = @state
x = x ^ (x >> 12)
x = (x ^ (x << 25)) & MASK64
x = x ^ (x >> 27)
@state = x
(((x * 0x2545F4914F6CDD1D) & MASK64) >> 32) & MASK32
end
d... |
http://rosettacode.org/wiki/Quine | Quine | A quine is a self-referential program that can,
without any external access, output its own source.
A quine (named after Willard Van Orman Quine) is also known as:
self-reproducing automata (1972)
self-replicating program or self-replicating computer program
self-reproducing program ... | #PHP | PHP | <?php $p = '<?php $p = %c%s%c; printf($p,39,$p,39); ?>
'; printf($p,39,$p,39); ?> |
http://rosettacode.org/wiki/Pseudo-random_numbers/PCG32 | Pseudo-random numbers/PCG32 | Some definitions to help in the explanation
Floor operation
https://en.wikipedia.org/wiki/Floor_and_ceiling_functions
Greatest integer less than or equal to a real number.
Bitwise Logical shift operators (c-inspired)
https://en.wikipedia.org/wiki/Bitwise_operation#Bit_shifts
Binary bits of value shifted left or ri... | #Julia | Julia | const mask32, CONST = 0xffffffff, UInt(6364136223846793005)
mutable struct PCG32
state::UInt64
inc::UInt64
PCG32(st=0x853c49e6748fea9b, i=0xda3e39cb94b95bdb) = new(st, i)
end
"""return random 32 bit unsigned int"""
function next_int!(x::PCG32)
old = x.state
x.state = (old * CONST) + x.inc
xo... |
http://rosettacode.org/wiki/Pseudo-random_numbers/PCG32 | Pseudo-random numbers/PCG32 | Some definitions to help in the explanation
Floor operation
https://en.wikipedia.org/wiki/Floor_and_ceiling_functions
Greatest integer less than or equal to a real number.
Bitwise Logical shift operators (c-inspired)
https://en.wikipedia.org/wiki/Bitwise_operation#Bit_shifts
Binary bits of value shifted left or ri... | #Kotlin | Kotlin | import kotlin.math.floor
class PCG32 {
private var state = 0x853c49e6748fea9buL
private var inc = 0xda3e39cb94b95bdbuL
fun nextInt(): UInt {
val old = state
state = old * N + inc
val shifted = old.shr(18).xor(old).shr(27).toUInt()
val rot = old.shr(59)
return (shi... |
http://rosettacode.org/wiki/Pythagorean_quadruples | Pythagorean quadruples |
One form of Pythagorean quadruples is (for positive integers a, b, c, and d):
a2 + b2 + c2 = d2
An example:
22 + 32 + 62 = 72
which is:
4 + 9 + 36 = 49
Task
For positive integers up 2,200 (inclusive), for all values of ... | #Go | Go | package main
import "fmt"
const (
N = 2200
N2 = N * N * 2
)
func main() {
s := 3
var s1, s2 int
var r [N + 1]bool
var ab [N2 + 1]bool
for a := 1; a <= N; a++ {
a2 := a * a
for b := a; b <= N; b++ {
ab[a2 + b * b] = true
}
}
for c :... |
http://rosettacode.org/wiki/Pythagoras_tree | Pythagoras tree |
The Pythagoras tree is a fractal tree constructed from squares. It is named after Pythagoras because each triple of touching squares encloses a right triangle, in a configuration traditionally used to represent the Pythagorean theorem.
Task
Construct a Pythagoras tree of order 7 using only vectors (no rotation or ... | #Go | Go | package main
import (
"image"
"image/color"
"image/draw"
"image/png"
"log"
"os"
)
const (
width, height = 800, 600
maxDepth = 11 // how far to recurse, between 1 and 20 is reasonable
colFactor = uint8(255 / maxDepth) // adjusts the colour so leaves get greener further out
fileN... |
http://rosettacode.org/wiki/Pseudo-random_numbers/Splitmix64 | Pseudo-random numbers/Splitmix64 | Splitmix64 is the default pseudo-random number generator algorithm in Java and is included / available in many other languages. It uses a fairly simple algorithm that, though it is considered to be poor for cryptographic purposes, is very fast to calculate, and is "good enough" for many random number needs. It passes s... | #Phix | Phix | with javascript_semantics
include mpfr.e
mpz state = mpz_init(),
shift = mpz_init("0x9e3779b97f4a7c15"),
mult1 = mpz_init("0xbf58476d1ce4e5b9"),
mult2 = mpz_init("0x94d049bb133111eb"),
b64 = mpz_init("0x10000000000000000"), -- (truncate to 64 bits)
tmp = mpz_init(),
z = mpz_init()
pro... |
http://rosettacode.org/wiki/Pythagorean_triples | Pythagorean triples | A Pythagorean triple is defined as three positive integers
(
a
,
b
,
c
)
{\displaystyle (a,b,c)}
where
a
<
b
<
c
{\displaystyle a<b<c}
, and
a
2
+
b
2
=
c
2
.
{\displaystyle a^{2}+b^{2}=c^{2}.}
They are called primitive triples if
a
,
b
,
c
{\displaystyle a,b,c}
are co-prime,... | #360_Assembly | 360 Assembly | * Pythagorean triples - 12/06/2018
PYTHTRI CSECT
USING PYTHTRI,R13 base register
B 72(R15) skip savearea
DC 17F'0' savearea
SAVE (14,12) save previous context
ST R13,4(R15) link backward
ST... |
http://rosettacode.org/wiki/Pseudo-random_numbers/Middle-square_method | Pseudo-random numbers/Middle-square method | Middle-square_method Generator
The Method
To generate a sequence of n-digit pseudorandom numbers, an n-digit starting value is created and squared, producing a 2n-digit number. If the result has fewer than 2n digits, leading zeroes are added to compensate. The middle n digits of the result would be the next number i... | #Raku | Raku | sub msq {
state $seed = 675248;
$seed = $seed² div 1000 mod 1000000;
}
say msq() xx 5; |
http://rosettacode.org/wiki/Pseudo-random_numbers/Middle-square_method | Pseudo-random numbers/Middle-square method | Middle-square_method Generator
The Method
To generate a sequence of n-digit pseudorandom numbers, an n-digit starting value is created and squared, producing a 2n-digit number. If the result has fewer than 2n digits, leading zeroes are added to compensate. The middle n digits of the result would be the next number i... | #Red | Red | Red[]
seed: 675248
rand: does [seed: to-integer (seed * 1.0 * seed / 1000) % 1000000] ; multiply by 1.0 to avoid integer overflow (32-bit)
loop 5 [print rand] |
http://rosettacode.org/wiki/Pseudo-random_numbers/Middle-square_method | Pseudo-random numbers/Middle-square method | Middle-square_method Generator
The Method
To generate a sequence of n-digit pseudorandom numbers, an n-digit starting value is created and squared, producing a 2n-digit number. If the result has fewer than 2n digits, leading zeroes are added to compensate. The middle n digits of the result would be the next number i... | #Ruby | Ruby | def middle_square (seed)
return to_enum(__method__, seed) unless block_given?
s = seed.digits.size
loop { yield seed = (seed*seed).to_s.rjust(s*2, "0")[s/2, s].to_i }
end
puts middle_square(675248).take(5) |
http://rosettacode.org/wiki/Pseudo-random_numbers/Xorshift_star | Pseudo-random numbers/Xorshift star | Some definitions to help in the explanation
Floor operation
https://en.wikipedia.org/wiki/Floor_and_ceiling_functions
Greatest integer less than or equal to a real number.
Bitwise Logical shift operators (c-inspired)
https://en.wikipedia.org/wiki/Bitwise_operation#Bit_shifts
Binary bits of value shifted left or ri... | #Sidef | Sidef | class Xorshift_star(state) {
define (
mask32 = (2**32 - 1),
mask64 = (2**64 - 1),
)
method next_int {
state ^= (state >> 12)
state ^= (state << 25 & mask64)
state ^= (state >> 27)
(state * 0x2545F4914F6CDD1D) >> 32 & mask32
}
method next_float {
... |
http://rosettacode.org/wiki/Quine | Quine | A quine is a self-referential program that can,
without any external access, output its own source.
A quine (named after Willard Van Orman Quine) is also known as:
self-reproducing automata (1972)
self-replicating program or self-replicating computer program
self-reproducing program ... | #PicoLisp | PicoLisp | ('((X) (list (lit X) (lit X))) '((X) (list (lit X) (lit X)))) |
http://rosettacode.org/wiki/Quine | Quine | A quine is a self-referential program that can,
without any external access, output its own source.
A quine (named after Willard Van Orman Quine) is also known as:
self-reproducing automata (1972)
self-replicating program or self-replicating computer program
self-reproducing program ... | #PL.2FI | PL/I | s:proc options(main)reorder;dcl sysprint file,m(7)init(
' s:proc options(main)reorder\dcl sysprint file,m(7)init(',
' *)char(99),i,j,(translate,substr)builtin,c char\i=1\j=n',
' \do i=1 to 6\put skip list('' '''''')\do j=2 to 56\c=substr',
' (m(i),j)\put edit(c)(a)\n:proc\put list(translate(m(i),',
' ''5e''x,''e0... |
http://rosettacode.org/wiki/Pseudo-random_numbers/Combined_recursive_generator_MRG32k3a | Pseudo-random numbers/Combined recursive generator MRG32k3a | MRG32k3a Combined recursive generator (pseudo-code)
/* Constants */
/* First generator */
a1 = [0, 1403580, -810728]
m1 = 2**32 - 209
/* Second Generator */
a2 = [527612, 0, -1370589]
m2 = 2**32 - 22853
d = m1 + 1
class MRG32k3a
x1 = [0, 0, 0] /* list of three last values of... | #11l | 11l | V a1 = [Int64(0), 1403580, -810728]
V m1 = Int64(2) ^ 32 - 209
V a2 = [Int64(527612), 0, -1370589]
V m2 = Int64(2) ^ 32 - 22853
V d = m1 + 1
T MRG32k3a
[Int64] x1, x2
F (seed_state = 123)
.seed(seed_state)
F seed(Int64 seed_state)
assert(seed_state C Int64(0) <.< :d, ‘Out of Range 0 x < #.’.f... |
http://rosettacode.org/wiki/Pseudo-random_numbers/PCG32 | Pseudo-random numbers/PCG32 | Some definitions to help in the explanation
Floor operation
https://en.wikipedia.org/wiki/Floor_and_ceiling_functions
Greatest integer less than or equal to a real number.
Bitwise Logical shift operators (c-inspired)
https://en.wikipedia.org/wiki/Bitwise_operation#Bit_shifts
Binary bits of value shifted left or ri... | #Lua | Lua | function uint32(n)
return n & 0xffffffff
end
function uint64(n)
return n & 0xffffffffffffffff
end
N = 6364136223846793005
state = 0x853c49e6748fea9b
inc = 0xda3e39cb94b95bdb
function pcg32_seed(seed_state, seed_sequence)
state = 0
inc = (seed_sequence << 1) | 1
pcg32_int()
state = state + ... |
http://rosettacode.org/wiki/Pythagorean_quadruples | Pythagorean quadruples |
One form of Pythagorean quadruples is (for positive integers a, b, c, and d):
a2 + b2 + c2 = d2
An example:
22 + 32 + 62 = 72
which is:
4 + 9 + 36 = 49
Task
For positive integers up 2,200 (inclusive), for all values of ... | #Haskell | Haskell | powersOfTwo :: [Int]
powersOfTwo = iterate (2 *) 1
unrepresentable :: [Int]
unrepresentable = merge powersOfTwo ((5 *) <$> powersOfTwo)
merge :: [Int] -> [Int] -> [Int]
merge xxs@(x:xs) yys@(y:ys)
| x < y = x : merge xs yys
| otherwise = y : merge xxs ys
main :: IO ()
main = do
putStrLn "The values of d <= ... |
http://rosettacode.org/wiki/Pythagoras_tree | Pythagoras tree |
The Pythagoras tree is a fractal tree constructed from squares. It is named after Pythagoras because each triple of touching squares encloses a right triangle, in a configuration traditionally used to represent the Pythagorean theorem.
Task
Construct a Pythagoras tree of order 7 using only vectors (no rotation or ... | #Haskell | Haskell | mkBranches :: [(Float,Float)] -> [[(Float,Float)]]
mkBranches [a, b, c, d] = let d = 0.5 <*> (b <+> (-1 <*> a))
l1 = d <+> orth d
l2 = orth l1
in
[ [a <+> l2, b <+> (2 <*> l2), a <+> l1, a]
, [a ... |
http://rosettacode.org/wiki/Pseudo-random_numbers/Splitmix64 | Pseudo-random numbers/Splitmix64 | Splitmix64 is the default pseudo-random number generator algorithm in Java and is included / available in many other languages. It uses a fairly simple algorithm that, though it is considered to be poor for cryptographic purposes, is very fast to calculate, and is "good enough" for many random number needs. It passes s... | #Object_Pascal | Object Pascal |
program splitmix64;
{$IF Defined(FPC)}{$MODE Delphi}{$ENDIF}
{$INLINE ON}
{$Q-}{$R-}
{
Written in 2015 by Sebastiano Vigna (vigna@acm.org)
http://prng.di.unimi.it/splitmix64.c
Onject Pascal port written in 2020 by I. Kakoulidis
To the extent possible under law, the author has dedicated all copyright
... |
http://rosettacode.org/wiki/Pythagorean_triples | Pythagorean triples | A Pythagorean triple is defined as three positive integers
(
a
,
b
,
c
)
{\displaystyle (a,b,c)}
where
a
<
b
<
c
{\displaystyle a<b<c}
, and
a
2
+
b
2
=
c
2
.
{\displaystyle a^{2}+b^{2}=c^{2}.}
They are called primitive triples if
a
,
b
,
c
{\displaystyle a,b,c}
are co-prime,... | #Action.21 | Action! | DEFINE PTR="CARD"
DEFINE ENTRY_SIZE="3"
TYPE TRIPLE=[BYTE a,b,c]
TYPE TRIPLES=[
PTR buf ;BYTE ARRAY
BYTE count]
PTR FUNC GetItemAddr(TRIPLES POINTER arr BYTE index)
PTR addr
addr=arr.buf+index*ENTRY_SIZE
RETURN (addr)
PROC PrintTriples(TRIPLES POINTER arr)
INT i
TRIPLE POINTER t
FOR i=0 TO arr.cou... |
http://rosettacode.org/wiki/Pseudo-random_numbers/Middle-square_method | Pseudo-random numbers/Middle-square method | Middle-square_method Generator
The Method
To generate a sequence of n-digit pseudorandom numbers, an n-digit starting value is created and squared, producing a 2n-digit number. If the result has fewer than 2n digits, leading zeroes are added to compensate. The middle n digits of the result would be the next number i... | #Sidef | Sidef | class MiddleSquareMethod(seed, k = 1000) {
method next {
seed = (seed**2 // k % k**2)
}
}
var obj = MiddleSquareMethod(675248)
say 5.of { obj.next } |
http://rosettacode.org/wiki/Pseudo-random_numbers/Middle-square_method | Pseudo-random numbers/Middle-square method | Middle-square_method Generator
The Method
To generate a sequence of n-digit pseudorandom numbers, an n-digit starting value is created and squared, producing a 2n-digit number. If the result has fewer than 2n digits, leading zeroes are added to compensate. The middle n digits of the result would be the next number i... | #uBasic.2F4tH | uBasic/4tH | If Info("wordsize") < 64 Then Print "This needs a 64-bit uBasic" : End
s = 675248
For i = 1 To 5
Print Set(s, FUNC(_random(s)))
Next
End
_random Param (1) : Return (a@*a@/1000%1000000) |
http://rosettacode.org/wiki/Pseudo-random_numbers/Middle-square_method | Pseudo-random numbers/Middle-square method | Middle-square_method Generator
The Method
To generate a sequence of n-digit pseudorandom numbers, an n-digit starting value is created and squared, producing a 2n-digit number. If the result has fewer than 2n digits, leading zeroes are added to compensate. The middle n digits of the result would be the next number i... | #UNIX_Shell | UNIX Shell | seed=675248
random(){
seed=`expr $seed \* $seed / 1000 % 1000000`
return seed
}
for ((i=1;i<=5;i++));
do
random
echo $?
done |
http://rosettacode.org/wiki/Pseudo-random_numbers/Xorshift_star | Pseudo-random numbers/Xorshift star | Some definitions to help in the explanation
Floor operation
https://en.wikipedia.org/wiki/Floor_and_ceiling_functions
Greatest integer less than or equal to a real number.
Bitwise Logical shift operators (c-inspired)
https://en.wikipedia.org/wiki/Bitwise_operation#Bit_shifts
Binary bits of value shifted left or ri... | #Swift | Swift | import Foundation
struct XorshiftStar {
private let magic: UInt64 = 0x2545F4914F6CDD1D
private var state: UInt64
init(seed: UInt64) {
state = seed
}
mutating func nextInt() -> UInt64 {
state ^= state &>> 12
state ^= state &<< 25
state ^= state &>> 27
return (state &* magic) &>> 32
... |
http://rosettacode.org/wiki/Pseudo-random_numbers/Xorshift_star | Pseudo-random numbers/Xorshift star | Some definitions to help in the explanation
Floor operation
https://en.wikipedia.org/wiki/Floor_and_ceiling_functions
Greatest integer less than or equal to a real number.
Bitwise Logical shift operators (c-inspired)
https://en.wikipedia.org/wiki/Bitwise_operation#Bit_shifts
Binary bits of value shifted left or ri... | #Wren | Wren | import "/big" for BigInt
var Const = BigInt.fromBaseString("2545F4914F6CDD1D", 16)
var Mask64 = (BigInt.one << 64) - BigInt.one
var Mask32 = (BigInt.one << 32) - BigInt.one
class XorshiftStar {
construct new(state) {
_state = state & Mask64
}
seed(num) { _state = num & Mask64}
nextInt ... |
http://rosettacode.org/wiki/Quine | Quine | A quine is a self-referential program that can,
without any external access, output its own source.
A quine (named after Willard Van Orman Quine) is also known as:
self-reproducing automata (1972)
self-replicating program or self-replicating computer program
self-reproducing program ... | #Plain_TeX | Plain TeX | This is TeX, Version 3.1415926 (no format preloaded)
(q.tex \output {\message {\output \the \output \end }\batchmode }\end |
http://rosettacode.org/wiki/Pseudo-random_numbers/Combined_recursive_generator_MRG32k3a | Pseudo-random numbers/Combined recursive generator MRG32k3a | MRG32k3a Combined recursive generator (pseudo-code)
/* Constants */
/* First generator */
a1 = [0, 1403580, -810728]
m1 = 2**32 - 209
/* Second Generator */
a2 = [527612, 0, -1370589]
m2 = 2**32 - 22853
d = m1 + 1
class MRG32k3a
x1 = [0, 0, 0] /* list of three last values of... | #Ada | Ada | package MRG32KA is
type I64 is range -2**63..2**63 - 1;
m1 : constant I64 := 2**32 - 209;
m2 : constant I64 := 2**32 - 22853;
subtype state_value is I64 range 1..m1;
procedure Seed (seed_state : state_value);
function Next_Int return I64;
function Next_Float return Long_Float;
end MRG32KA;
|
http://rosettacode.org/wiki/Pseudo-random_numbers/Combined_recursive_generator_MRG32k3a | Pseudo-random numbers/Combined recursive generator MRG32k3a | MRG32k3a Combined recursive generator (pseudo-code)
/* Constants */
/* First generator */
a1 = [0, 1403580, -810728]
m1 = 2**32 - 209
/* Second Generator */
a2 = [527612, 0, -1370589]
m2 = 2**32 - 22853
d = m1 + 1
class MRG32k3a
x1 = [0, 0, 0] /* list of three last values of... | #C | C | #include <math.h>
#include <stdio.h>
#include <stdint.h>
int64_t mod(int64_t x, int64_t y) {
int64_t m = x % y;
if (m < 0) {
if (y < 0) {
return m - y;
} else {
return m + y;
}
}
return m;
}
// Constants
// First generator
const static int64_t a1[3] = ... |
http://rosettacode.org/wiki/Pseudo-random_numbers/PCG32 | Pseudo-random numbers/PCG32 | Some definitions to help in the explanation
Floor operation
https://en.wikipedia.org/wiki/Floor_and_ceiling_functions
Greatest integer less than or equal to a real number.
Bitwise Logical shift operators (c-inspired)
https://en.wikipedia.org/wiki/Bitwise_operation#Bit_shifts
Binary bits of value shifted left or ri... | #Nim | Nim | import algorithm, sequtils, strutils, tables
const N = 6364136223846793005u64
type PCG32 = object
inc: uint64
state: uint64
func seed(gen: var PCG32; seedState, seedSequence: uint64) =
gen.inc = seedSequence shl 1 or 1
gen.state = (gen.inc + seedState) * N + gen.inc
func nextInt(gen: var PCG32): uint32 ... |
http://rosettacode.org/wiki/Pseudo-random_numbers/PCG32 | Pseudo-random numbers/PCG32 | Some definitions to help in the explanation
Floor operation
https://en.wikipedia.org/wiki/Floor_and_ceiling_functions
Greatest integer less than or equal to a real number.
Bitwise Logical shift operators (c-inspired)
https://en.wikipedia.org/wiki/Bitwise_operation#Bit_shifts
Binary bits of value shifted left or ri... | #Perl | Perl | use strict;
use warnings;
use feature 'say';
use Math::AnyNum qw(:overload);
package PCG32 {
use constant {
mask32 => 2**32 - 1,
mask64 => 2**64 - 1,
const => 6364136223846793005,
};
sub new {
my ($class, %opt) = @_;
my $seed = $opt{seed} // 1;
my $incr... |
http://rosettacode.org/wiki/Pythagorean_quadruples | Pythagorean quadruples |
One form of Pythagorean quadruples is (for positive integers a, b, c, and d):
a2 + b2 + c2 = d2
An example:
22 + 32 + 62 = 72
which is:
4 + 9 + 36 = 49
Task
For positive integers up 2,200 (inclusive), for all values of ... | #J | J |
Filter =: (#~`)(`:6)
B =: *: A =: i. >: i. 2200
S1 =: , B +/ B NB. S1 is a raveled table of the sums of squares
S1 =: <:&({:B)Filter S1 NB. remove sums of squares exceeding bound
S1 =: ~. S1 NB. remove duplicate entries
S2 =: , B +/ S1
S2 =: <:&({:B)Filter S2... |
http://rosettacode.org/wiki/Pythagorean_quadruples | Pythagorean quadruples |
One form of Pythagorean quadruples is (for positive integers a, b, c, and d):
a2 + b2 + c2 = d2
An example:
22 + 32 + 62 = 72
which is:
4 + 9 + 36 = 49
Task
For positive integers up 2,200 (inclusive), for all values of ... | #Java | Java |
import java.util.ArrayList;
import java.util.List;
public class PythagoreanQuadruples {
public static void main(String[] args) {
long d = 2200;
System.out.printf("Values of d < %d where a, b, and c are non-zero and a^2 + b^2 + c^2 = d^2 has no solutions:%n%s%n", d, getPythagoreanQuadruples(d))... |
http://rosettacode.org/wiki/Pythagoras_tree | Pythagoras tree |
The Pythagoras tree is a fractal tree constructed from squares. It is named after Pythagoras because each triple of touching squares encloses a right triangle, in a configuration traditionally used to represent the Pythagorean theorem.
Task
Construct a Pythagoras tree of order 7 using only vectors (no rotation or ... | #IS-BASIC | IS-BASIC | 100 PROGRAM "Pythagor.bas"
110 OPTION ANGLE DEGREES
120 LET SQ2=SQR(2)
130 SET VIDEO MODE 1:SET VIDEO COLOUR 0:SET VIDEO X 42:SET VIDEO Y 25
140 OPEN #101:"video:"
150 SET PALETTE 0,141
160 DISPLAY #101:AT 1 FROM 1 TO 25
170 PLOT 580,20;ANGLE 90;
180 CALL BROCCOLI(225,10)
190 DO
200 LOOP WHILE INKEY$=""
210 TEXT
220 DE... |
http://rosettacode.org/wiki/Pseudo-random_numbers/Splitmix64 | Pseudo-random numbers/Splitmix64 | Splitmix64 is the default pseudo-random number generator algorithm in Java and is included / available in many other languages. It uses a fairly simple algorithm that, though it is considered to be poor for cryptographic purposes, is very fast to calculate, and is "good enough" for many random number needs. It passes s... | #PicoLisp | PicoLisp | (zero *Split) # global state
(de mod64 (N)
(& N `(hex "FFFFFFFFFFFFFFFF")) )
(de mod64+ (A B)
(mod64 (+ A B)) )
(de mod64* (A B)
(mod64 (* A B)) )
(de roundf (N) # rounds down
(/ N (** 10 *Scl)) )
(de nextSplit ()
(setq *Split (mod64+ *Split `(hex "9e3779b97f4a7c15")))
(let Z *Split
(se... |
http://rosettacode.org/wiki/Pseudo-random_numbers/Splitmix64 | Pseudo-random numbers/Splitmix64 | Splitmix64 is the default pseudo-random number generator algorithm in Java and is included / available in many other languages. It uses a fairly simple algorithm that, though it is considered to be poor for cryptographic purposes, is very fast to calculate, and is "good enough" for many random number needs. It passes s... | #Python | Python | MASK64 = (1 << 64) - 1
C1 = 0x9e3779b97f4a7c15
C2 = 0xbf58476d1ce4e5b9
C3 = 0x94d049bb133111eb
class Splitmix64():
def __init__(self, seed=0):
self.state = seed & MASK64
def seed(self, num):
self.state = num & MASK64
def next_int(self):
"return random int between 0 and 2... |
http://rosettacode.org/wiki/Pythagorean_triples | Pythagorean triples | A Pythagorean triple is defined as three positive integers
(
a
,
b
,
c
)
{\displaystyle (a,b,c)}
where
a
<
b
<
c
{\displaystyle a<b<c}
, and
a
2
+
b
2
=
c
2
.
{\displaystyle a^{2}+b^{2}=c^{2}.}
They are called primitive triples if
a
,
b
,
c
{\displaystyle a,b,c}
are co-prime,... | #Ada | Ada | with Ada.Text_IO;
procedure Pythagorean_Triples is
type Large_Natural is range 0 .. 2**63-1;
-- this is the maximum for gnat
procedure New_Triangle(A, B, C: Large_Natural;
Max_Perimeter: Large_Natural;
Total_Cnt, Primitive_Cnt: in out Large_Natural) i... |
Subsets and Splits
Rosetta Code COBOL Python Hard Tasks
Identifies and retrieves challenging tasks that exist in both COBOL and Python, revealing cross-language programming patterns and difficulty levels for comparative analysis.
Rosetta Code Task Comparisons
Identifies tasks common to both COBOL and Python languages that are described as having difficulty levels, revealing cross-language task similarities and providing useful comparative programming examples.
SQL Code Examples from Training Data
Retrieves raw SQL code examples for the SQL language, which is basic data retrieval without meaningful analysis or patterns.
SQL Code Examples from Training Data
Retrieves raw SQL code examples for the SQL language, which is basic filtering that shows what data looks like but doesn't provide meaningful analysis or patterns.
Select Specific Languages Codes
Retrieves specific programming language names and codes from training data, providing basic filtering but limited analytical value beyond identifying these particular languages.