Comments (2)
Hm I haven't studied our options too closely. Technically, the factorization algorithm introduced in #13 also needs randomness. The trouble is providing randomness guarantees strong enough to evade Codeforces hacking. Last I checked, I think the standard library doesn't yet expose the operating system's randomness primitives. Is there anything we can do?
from rust-algorithms.
Ah, good question. So there's two factors at play here:
- The PRNG algorithm. Most algorithms (besides linear congruential generators) have good enough statistical properties that we'll be fine no matter what.
- Adversarial hacking. This is actually based on the seed of the pseudorandom number generator. No matter how good the PRNG algorithm is, if a hacker knows the seed, then they can always adversarially select a test case input.
There's a good blog post about this. Generally, using the system's high resolution time (std::time::SystemTime
in nanoseconds from Unix epoch) is a good enough seed to prevent hacking.
For now I'll focus on just resolving issue 1 though, which is the PRNG algorithm itself, and we can add utilities for robustly seeding from time or unsafe { core::arch::x86::_rdtsc() }
if that's desired. Not all competition websites have an open hacking phase where people generate adversarial stuff! :)
(see also: https://ekzlib.netlify.app/view/rng.cpp)
from rust-algorithms.
Related Issues (12)
- Use tags to make this project searchable on Github HOT 2
- Request: an easy-to-augment balanced tree HOT 1
- Reading lots of integers HOT 8
- Suggestion: adding primality check and prime factorisation HOT 3
- Open to Open Source? HOT 3
- Online Docs HOT 4
- Q: How to use this crate in programming contests? HOT 1
- Inconsistency between documentation and code implementation HOT 2
- Document panics HOT 2
- Add a DFS iterator to Graph HOT 3
- Add bipartite vertex cover alongside dinic HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust-algorithms.