Tupper's self-referential formula: Difference between revisions
Content added Content deleted
(→{{header|Lua}}: Tweak) |
m (Rust) |
||
Line 314: | Line 314: | ||
{{out}} |
{{out}} |
||
The result is the file tupper.txt with the content: |
The result is the file tupper.txt with the content: |
||
<pre> |
|||
█ █ █ ██ █ █ █ █ █ █ █ ██ █ █ █ |
|||
█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ |
|||
██ █ █ █ █ ██ █ █ █ █ █ █ ██ ████ ███ ███ █ █ █ █ █ █ █ █ █ █ |
|||
█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ |
|||
█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ███ ███ █ █ █ █ █ █ █ █ █ |
|||
█ █ █ █ █ █ █ ██ █ █ █ █ █ █ █ █ ██ █ █ |
|||
███ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ |
|||
█ █ ██ █ ██ ███ █ █ █ █ ███ ███ █ ███ ███ █ █ █ █ █ |
|||
███ █ █ █ █ █ █ █ █ █ █ █ ████ █ █ █ █ █ |
|||
█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ |
|||
██ █ █ █ █ █ ██ ███ █ █ █ ██ █ ████ ████ █ █ |
|||
█ █ █ █ █ █ █ █ █ █ |
|||
█ █ █ █ █ █ █ █ █ █ |
|||
█ █ █ █ █ █ █ █ █ █ |
|||
███ █ █ █ █ █ █ █ █ |
|||
█ █ █ █ █ █ |
|||
███ █ ███ ███ █ ███ |
|||
</pre> |
|||
=={{header|Rust}}== |
|||
<syntaxhighlight lang="rust">use num::bigint::BigInt; |
|||
use num::{FromPrimitive, pow}; |
|||
use std::primitive::bool; |
|||
/// Tupper function value maxtrix for graphic |
|||
fn tupper_mat(kconst: BigInt) -> Vec<[bool; 106]> { |
|||
let mut tmatrix = vec![[true; 106]; 17]; |
|||
let bigone: BigInt = BigInt::from_u32(1).unwrap(); |
|||
let bigtwo: BigInt = BigInt::from_u32(2).unwrap(); |
|||
for i in 0..106 { |
|||
for j in 0..17 { |
|||
let y: BigInt = kconst.clone() + j; |
|||
let mut a: BigInt = y.clone() / 17; |
|||
let mut b: BigInt = y.clone() % 17; |
|||
b += i * 17; |
|||
b = pow(bigtwo.clone(), b.try_into().unwrap()); |
|||
a /= b; |
|||
a %= 2; |
|||
tmatrix[16 - j][105 - i] = a == bigone; |
|||
} |
|||
} |
|||
return tmatrix |
|||
} |
|||
fn main() { |
|||
let k: BigInt = BigInt::parse_bytes(b"960939379918958884971672962127852754715004339660129306651505519_271_702_802_395_266_424_689_642_842_174_350_718_121_267_153_782_770_623_355993_237_280_874_144_307_891_325_963_941_337_723_487_857_735_749_823_926_629_715517_173_716_995_165_232_890_538_221_612_403_238_855_866_184_013_235_585_136_048828_693_337_902_491_454_229_288_667_081_096_184_496_091_705_183_454_067_827_731551_705_405_381_627_380_967_602_565_625_016_981_482_083_418_783_163_849_115_590225_610_003_652_351_370_343_874_461_848_378_737_238_198_224_849_863_465_033_159410_054_974_700_593_138_339_226_497_249_461_751_545_728_366_702_369_745_461_014655_997_933_798_537_483_143_786_841_806_593_422_227_898_388_722_980_000_748_404_719", |
|||
10).unwrap(); |
|||
let bmap = tupper_mat(k); |
|||
for line in bmap.iter().rev() { |
|||
for c in line.iter() { |
|||
if *c { |
|||
print!("\u{25A0}"); |
|||
} |
|||
else { |
|||
print!(" "); |
|||
} |
|||
} |
|||
println!() |
|||
} |
|||
} |
|||
</syntaxhighlight>{{out}} |
|||
<pre> |
|||
use num::bigint::BigInt; |
|||
use num::{FromPrimitive, pow}; |
|||
use std::primitive::bool; |
|||
/// Tupper function value maxtrix for graphic |
|||
fn tupper_mat(kconst: BigInt) -> Vec<[bool; 106]> { |
|||
let mut tmatrix = vec![[true; 106]; 17]; |
|||
let bigone: BigInt = BigInt::from_u32(1).unwrap(); |
|||
let bigtwo: BigInt = BigInt::from_u32(2).unwrap(); |
|||
for i in 0..106 { |
|||
for j in 0..17 { |
|||
let y: BigInt = kconst.clone() + j; |
|||
let mut a: BigInt = y.clone() / 17; |
|||
let mut b: BigInt = y.clone() % 17; |
|||
b += i * 17; |
|||
b = pow(bigtwo.clone(), b.try_into().unwrap()); |
|||
a /= b; |
|||
a %= 2; |
|||
tmatrix[16 - j][105 - i] = a == bigone; |
|||
} |
|||
} |
|||
return tmatrix |
|||
} |
|||
fn main() { |
|||
let k: BigInt = BigInt::parse_bytes(b"960939379918958884971672962127852754715004339660129306651505519_271_702_802_395_266_424_689_642_842_174_350_718_121_267_153_782_770_623_355993_237_280_874_144_307_891_325_963_941_337_723_487_857_735_749_823_926_629_715517_173_716_995_165_232_890_538_221_612_403_238_855_866_184_013_235_585_136_048828_693_337_902_491_454_229_288_667_081_096_184_496_091_705_183_454_067_827_731551_705_405_381_627_380_967_602_565_625_016_981_482_083_418_783_163_849_115_590225_610_003_652_351_370_343_874_461_848_378_737_238_198_224_849_863_465_033_159410_054_974_700_593_138_339_226_497_249_461_751_545_728_366_702_369_745_461_014655_997_933_798_537_483_143_786_841_806_593_422_227_898_388_722_980_000_748_404_719", |
|||
10).unwrap(); |
|||
let bmap = tupper_mat(k); |
|||
for line in bmap.iter().rev() { |
|||
for c in line.iter() { |
|||
if *c { |
|||
print!("\u{25A0}"); |
|||
} |
|||
else { |
|||
print!(" "); |
|||
} |
|||
} |
|||
println!() |
|||
} |
|||
} |
|||
</syntaxhighlight>{{out}} |
|||
<pre> |
<pre> |
||
█ █ █ ██ █ █ █ █ █ █ █ ██ █ █ █ |
█ █ █ ██ █ █ █ █ █ █ █ ██ █ █ █ |