summaryrefslogtreecommitdiff
path: root/code-jam22/round1b/a-se-dat-ab/src/main.rs
diff options
context:
space:
mode:
authormathiasmagnusson <mathiasmagnussons@gmail.com>2022-12-09 18:01:29 +0100
committermathiasmagnusson <mathiasmagnussons@gmail.com>2022-12-09 18:01:29 +0100
commitac1f723d39b6d25903237af86a7319209373731b (patch)
tree834a897b19d1fc6ef6abd9d4af4b553d98e64bea /code-jam22/round1b/a-se-dat-ab/src/main.rs
parenta1eb38bebe6ce1668c3f96489506c3b05b9fe5cb (diff)
downloadprogramming-problem-solving-ac1f723d39b6d25903237af86a7319209373731b.tar.gz
Code jam
Diffstat (limited to 'code-jam22/round1b/a-se-dat-ab/src/main.rs')
-rw-r--r--code-jam22/round1b/a-se-dat-ab/src/main.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/code-jam22/round1b/a-se-dat-ab/src/main.rs b/code-jam22/round1b/a-se-dat-ab/src/main.rs
new file mode 100644
index 0000000..a0cbb6b
--- /dev/null
+++ b/code-jam22/round1b/a-se-dat-ab/src/main.rs
@@ -0,0 +1,37 @@
+use std::io::{stdin, stdout, BufRead, Write};
+
+fn main() {
+ let stdin = stdin();
+ let mut lines = stdin.lock().lines().map(|l| l.unwrap());
+ let mut line = || lines.next().unwrap();
+ let stdout = stdout();
+ let mut stdout = stdout.lock();
+
+ let mut state = 8473859;
+ let mut r = || {
+ state = state * 252533 % 33554393;
+ state
+ };
+
+ for _ in 1u8..=line().parse().unwrap() {
+ stdout.write_all(b"00000000\n").unwrap();
+ loop {
+ let n = line().parse::<i8>().unwrap();
+ if n == -1 {
+ return; // Wrong answer
+ }
+ if n == 0 {
+ break;
+ }
+ let mut out = *b"00000000\n";
+ for _ in 0..n {
+ let mut v = r() % 8;
+ while out[v] != b'0' {
+ v = r() % 8;
+ }
+ out[v] = b'1';
+ }
+ stdout.write_all(&out).unwrap();
+ }
+ }
+}