diff --git a/src/bin/08_revisit_everything.rs b/src/bin/08_revisit_everything.rs index 88f0bb1..679484a 100644 --- a/src/bin/08_revisit_everything.rs +++ b/src/bin/08_revisit_everything.rs @@ -1,18 +1,13 @@ #![allow(dead_code)] -// https://button.qedaka.de/08_revisit_everything.html?name=Jonah&n=1000000000000000001&x=1141722273008339915328938587151716754833048258848475681487735516970602226114183939065675583898686553774198065467756506859865498694600744286363279646703886300858182075206964546562179673525530750445867781284063290359534951870422248538689162221 - // You can change the color of your name without changing your name. -use std::str::FromStr; use lazy_static::lazy_static; -use rug::Integer; +use lib::submit_with_name; use rug::ops::{DivRounding, Pow}; -use lib::compute_async; +use rug::Integer; +use std::str::FromStr; -const N: u128 = 1000000000073185001u128; lazy_static!( - static ref X: Integer = Integer::from_str("674404660282415099554286008259705897519728869877764551165256987500863620745793154396934476537394982658025146065927801862469915739446118680825670854157276563716625217760696826462684682154873582522786834148305185591910769146737370100544900325").unwrap(); - static ref M: Vec = vec![ Integer::from_str("1434008120931012805118743381511953470053626771934922366720474361817092344508461315782084314493561729943207476618986862630642339876124303277669871276872966561372584096756184146218943438497504108129008248947186295903702650936563195517405177267").unwrap(), Integer::from_str("2279983661166952569412337967792106681853682761140508555222469060830820310854240357968620360297575902950280777825697828457195462861233847516393870602678279643129330544204145040751369969379909048248974150190225328726111083312867874886821021103").unwrap(), @@ -60,39 +55,34 @@ lazy_static!( static ref E: Integer = Integer::from(65537); static ref E_100: Integer = Integer::from(65537).pow(100); + static ref E_1000: Integer = Integer::from(65537).pow(1000); + + static ref P: Integer = Integer::from_str("2134638905903015345595412931439525422327695207079839833349799642610037970639957457078422305821013930668706217301787851463").unwrap(); + static ref Q: Integer = Integer::from_str("2134638905903015345595412931439525422327695207079839833349799642610037970639957457078422305821013930668706217301787851473").unwrap(); + static ref PHI: Integer = Integer::from_str("4556683258594822402855414380362620295231673046713752880933967889771646856051745784462468117575177892006513392693685616565666555545842363207724851343853529903674824524238732001458342230627654145983386115997227846421784693186847971068054052064").unwrap(); ); -/* - -n = 1000000000001145001 -x = 935504152258349142153756545027828333134502429815898853337434111035772753274298247562421282857225670294658871951566740526892519325930337394689734885958045678674585250121996049281620596578037697388040730892475705736002027099964789174115489575 - - -n = 1000000000072575001 -x = 546106984416375692279579316993165581647744624953870698906430198525494209177887357935777586504349202038571291730277816358008624296244276841351481284323881231286987401276869989221861844649820074846780554419816669235773068026326964231557588363 - - */ +const LIMIT: u128 = 100_000_000_000_000_000_000; +const NAME: &str = " Jonah"; +const N: u128 = 1000000000000000000; +const X: &str = "3595876711108608978"; fn main() { + assert_eq!(M[30].clone(), P.clone() * Q.clone()); + assert_eq!(PHI.clone(), (P.clone() - 1) * (Q.clone() - 1)); + let truth = Integer::from(42); - let w: usize = X.clone().modulo(&truth).try_into().unwrap(); - println!("w = {w}"); + let k = Integer::from(LIMIT - N) * 100; + let e = E.clone().pow_mod(&k, &PHI).unwrap(); - compute_async(move |tx| { - let mut n = N; - let y = X.clone().div_floor(&truth); + let x = Integer::from_str(X).unwrap(); + let w: usize = x.clone().modulo(&truth).try_into().unwrap(); + assert_eq!(w, 30); - let mut temp = y.clone(); - loop { - for _ in 0..10_000 { - n += 1; - temp = temp.pow_mod(&E_100, &M[w]).unwrap(); - } + let mut y = x.clone().div_floor(&truth); + y = y.pow_mod(&e, &M[30]).unwrap(); - let mut res = temp.clone(); - res *= &truth; - res += w; - tx.send((n, res)).unwrap(); - } - }); + let x: Integer = y * 42 + w; + println!("x = {x}\nn = {LIMIT}"); + submit_with_name(NAME, LIMIT, x).unwrap(); } \ No newline at end of file diff --git a/src/bin/main.rs b/src/bin/main.rs index 7e4d6af..1f6fe7b 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -1,26 +1,40 @@ +use rug::Integer; use lib::submit_with_name; fn main() { - let name = "Яана"; + let mut name0 = String::from("ZetaX"); + loop { + let name: &str = &name0; - let (n, x) = lib::challenges::c1_welcome::solve(); - println!("n = {:?}\nx = {:?}\n{:?}\n", n, x, submit_with_name(name, n, x)); + let (n, x) = lib::challenges::c1_welcome::solve(); + println!("n = {:?}\nx = {:?}\n{:?}\n", n, x, submit_with_name(name, n, x)); - let (n, x) = lib::challenges::c2_these_numbers_are_big::solve(name); - println!("n = {:?}\nx = {:?}\n{:?}\n", n, x, submit_with_name(name, n, x.clone())); + let (n, x) = lib::challenges::c2_these_numbers_are_big::solve(name); + println!("n = {:?}\nx = {:?}\n{:?}\n", n, x, submit_with_name(name, n, x.clone())); - let (n, x) = lib::challenges::c3_are_you_still_doing_this_by_hand::solve(n, x); - println!("n = {:?}\nx = {:?}\n{:?}\n", n, x, submit_with_name(name, n, x.clone())); + let (n, x) = lib::challenges::c3_are_you_still_doing_this_by_hand::solve(n, x); + println!("n = {:?}\nx = {:?}\n{:?}\n", n, x, submit_with_name(name, n, x.clone())); - let (n, x) = lib::challenges::c4_broken_proof_of_work::solve(n, x); - println!("n = {:?}\nx = {:?}\n{:?}\n", n, x, submit_with_name(name, n, x.clone())); + let (n, x) = lib::challenges::c4_broken_proof_of_work::solve(n, x); + println!("n = {:?}\nx = {:?}\n{:?}\n", n, x, submit_with_name(name, n, x.clone())); - let (n, x) = lib::challenges::c5_what_the_bf::solve(n, x); - println!("n = {:?}\nx = {:?}\n{:?}\n", n, x, submit_with_name(name, n, x.clone())); + let (n, x) = lib::challenges::c5_what_the_bf::solve(n, x); + println!("n = {:?}\nx = {:?}\n{:?}\n", n, x, submit_with_name(name, n, x.clone())); - let (n, x) = lib::challenges::c6_automation_is_not_enough::solve(n, x); - println!("n = {:?}\nx = {:?}\n{:?}\n", n, x, submit_with_name(name, n, x.clone())); + let (n, x) = lib::challenges::c6_automation_is_not_enough::solve(n, x); + println!("n = {:?}\nx = {:?}\n{:?}\n", n, x, submit_with_name(name, n, x.clone())); - let (n, x) = lib::challenges::c7_weird_assembly_machine::solve(n, x); - println!("n = {:?}\nx = {:?}\n{:?}\n", n, x, submit_with_name(name, n, x.clone())); + let (n, x) = lib::challenges::c7_weird_assembly_machine::solve(n, x); + println!("n = {:?}\nx = {:?}\n{:?}\n", n, x, submit_with_name(name, n, x.clone())); + + let truth = Integer::from(42); + let w: usize = x.clone().modulo(&truth).try_into().unwrap(); + println!("n = {n:?}\nx = {x:?}\nw = {w:?}\nname={name}"); + + if w == 30 { + break; + } + + name0.insert_str(0, " "); + } } \ No newline at end of file