-
java.util.Random, An instance of this class is used to generate a stream of pseudorandom numbers. The class uses a 48-bit seed, which is modified using a linear congruential formula. (See Donald Knuth, The Art of Computer Programming, Volume 2, Section 3.2.1.)
-
This class has 6 nifty functions:
- nextBoolean()
- nextDouble()
-
nextFloat()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package app; | |
| /* In build.gradle add those lines: | |
| repositories { | |
| jcenter() | |
| mavenCentral() | |
| maven { | |
| url "https://jitpack.io" | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package javaECC; | |
| import org.bouncycastle.crypto.generators.ElGamalParametersGenerator; | |
| import org.bouncycastle.crypto.params.DHParameters; | |
| import org.bouncycastle.crypto.params.ElGamalParameters; | |
| import org.bouncycastle.util.BigIntegers; | |
| import java.math.BigInteger; | |
| import java.security.SecureRandom; | |
| import java.util.Objects; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protected void generateBands(long l) { | |
| this.clayBands = new BlockState[64]; | |
| Arrays.fill(this.clayBands, TERRACOTTA); | |
| WorldgenRandom worldgenRandom = new WorldgenRandom(l); | |
| this.clayBandsOffsetNoise = new PerlinSimplexNoise(worldgenRandom, (List<Integer>)ImmutableList.of((Object)0)); | |
| for (int orange_bound = 0; orange_bound < 64; ++orange_bound) { | |
| if ((orange_bound += worldgenRandom.nextInt(5) + 1) >= 64) continue; | |
| this.clayBands[orange_bound] = ORANGE_TERRACOTTA; | |
| } | |
| int orange_bound = worldgenRandom.nextInt(4) + 2; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def first_digit(n): | |
| from math import exp,log,pi,modf,sqrt | |
| w=log((n/exp(1)),10) | |
| f,i=modf(w*n) | |
| l=10**f | |
| p=sqrt(2*pi*n) | |
| return str(p*l)[0] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| from pylfsr import LFSR | |
| L = LFSR() | |
| state = [1,1,1,1,1,0,0,0,0,0] | |
| fpoly = [10,8,5,4] | |
| L = LFSR(fpoly=fpoly,initstate =state, verbose=False) | |
| L.info() | |
| period=1023 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function parse_pre_block(id) { | |
| let pre_block = document.getElementById(id) | |
| if (pre_block == null || pre_block.childElementCount === 0) { | |
| return null; | |
| } | |
| let children = pre_block.childNodes | |
| let res = "" | |
| for (const child of children) { | |
| if (child.nodeType === 3) { // text node | |
| res += child.data.replace(/\\\*.*(?=\*\\)\*\\/g, "") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <head> | |
| <meta name="viewport" content="initial-scale = 1.0,maximum-scale = 1.0" /> | |
| <style> | |
| body { | |
| margin: 0; | |
| color: #444; | |
| background: #000; | |
| font: 300 18px/18px Roboto, sans-serif; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| gs -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite -dCompatibilityLevel=1.3 -dPDFSETTINGS=/screen -dEmbedAllFonts=true -dSubsetFonts=true -dColorImageDownsampleType=/Bicubic -dColorImageResolution=144 -dGrayImageDownsampleType=/Bicubic -dGrayImageResolution=144 -dMonoImageDownsampleType=/Bicubic -dMonoImageResolution=144 -sOutputFile=out.pdf in.pdf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <NTL/ZZ.h> | |
| #include <NTL/vec_double.h> | |
| #include <NTL/vec_ZZ.h> | |
| #include <NTL/mat_ZZ.h> | |
| #include <NTL/mat_RR.h> | |
| #include <NTL/LLL.h> | |
| #include <iostream> |