fork download
  1.  
  2. use std::char;
  3.  
  4.  
  5. fn check(vec: &Vec<u8>) -> bool {
  6. let mut acc: u32 = 0;
  7.  
  8. for &i in vec {
  9. // sifreyi_bul_01 is accepting
  10. // characters between 48 and 128
  11. if i < 48 || i > 128 {
  12. return false;
  13. }
  14.  
  15. let i = i - 48;
  16.  
  17. match i {
  18. 5 => acc *= i as u32,
  19. 2 => acc /= i as u32,
  20. _ => acc += i as u32
  21. }
  22. }
  23.  
  24. if acc == 178 {
  25. true
  26. } else {
  27. false
  28. }
  29. }
  30.  
  31.  
  32. fn to_string(vec: &Vec<u8>) -> String {
  33. let mut s = String::new();
  34. for &i in vec {
  35. match char::from_u32(i as u32) {
  36. Some(c) => s.push(c),
  37. _ => return "".to_string()
  38. };
  39. }
  40. s
  41. }
  42.  
  43.  
  44. // test "check" and "to_string" first
  45. // rust is making tdd really easy
  46. #[test]
  47. fn test_check() {
  48. assert_eq!(check(&vec!(126, 126, 70)), true);
  49. assert_eq!(check(&vec!(126, 126, 69, 49)), true);
  50. assert_eq!(check(&vec!(126, 126, 68, 49, 49)), true);
  51. assert_eq!(check(&vec!(83, 53, 51)), true);
  52.  
  53. // 128 should pass
  54. assert_eq!(check(&vec!(0x7f, 0x7f, 0x44)), true);
  55.  
  56. assert_eq!(check(&vec!(0)), false);
  57. assert_eq!(check(&vec!(0, 0, 0)), false);
  58. assert_eq!(check(&vec!(48, 48, 48)), false);
  59. }
  60.  
  61. #[test]
  62. fn test_to_string() {
  63. assert_eq!(to_string(&vec!(126, 126, 70)), "~~F");
  64. assert_eq!(to_string(&vec!(83, 53, 51)), "S53");
  65.  
  66. // this kind of string should never generated
  67. // but still its good to test it
  68. assert_eq!(to_string(&vec!(0, 0, 0)), "\u{0}\u{0}\u{0}");
  69. assert_eq!(to_string(&vec!(0xff, 0xff, 0xff)), "\u{ff}\u{ff}\u{ff}");
  70. }
  71.  
  72.  
  73.  
  74. fn find_right_vecs(vec: &mut Vec<u8>, n: usize, depth: usize) {
  75.  
  76. // check only readable characters
  77. for x in 49..127 {
  78. vec[n] = x as u8;
  79.  
  80. if n < depth {
  81. find_right_vecs(vec, n+1, depth);
  82. }
  83.  
  84. if check(&vec) {
  85. println!("{}", to_string(&vec));
  86. }
  87. }
  88.  
  89. }
  90.  
  91. fn find_vecs(max: usize) {
  92. for i in 0..max {
  93. let mut vec: Vec<u8> = vec![0; i + 1];
  94. find_right_vecs(&mut vec, 0, i);
  95. }
  96. }
  97.  
  98.  
  99. fn main() {
  100. // find stuff for only maximum 3 characters
  101. find_vecs(3);
  102. }
  103.  
Success #stdin #stdout 0.24s 10984KB
stdin
Standard input is empty
stdout
D5~
D5~
E5y
F5t
F~~
F~~
F~~
G5o
G}~
G}~
G~}
H5j
H|~
H|~
H}}
H~|
I5e
I{~
I{~
I|}
I}|
I~{
J5`
Jz~
Jz~
J{}
J||
J}{
J~z
K5[
Ky~
Ky~
Kz}
K{|
K|{
K}z
K~y
L5V
Lx~
Lx~
Ly}
Lz|
L{{
L|z
L}y
L~x
M5Q
Mw~
Mw~
Mx}
My|
Mz{
M{z
M|y
M}x
M~w
N5L
Nv~
Nv~
Nw}
Nx|
Ny{
Nzz
N{y
N|x
N}w
N~v
O5G
Ou~
Ou~
Ov}
Ow|
Ox{
Oyz
Ozy
O{x
O|w
O}v
O~u
P5B
Pt~
Pt~
Pu}
Pv|
Pw{
Pxz
Pyy
Pzx
P{w
P|v
P}u
P~t
Q5=
Qs~
Qs~
Qt}
Qu|
Qv{
Qwz
Qxy
Qyx
Qzw
Q{v
Q|u
Q}t
Q~s
R58
Rr~
Rr~
Rs}
Rt|
Ru{
Rvz
Rwy
Rxx
Ryw
Rzv
R{u
R|t
R}s
R~r
S53
Sq~
Sq~
Sr}
Ss|
St{
Suz
Svy
Swx
Sxw
Syv
Szu
S{t
S|s
S}r
S~q
Tp~
Tp~
Tq}
Tr|
Ts{
Ttz
Tuy
Tvx
Tww
Txv
Tyu
Tzt
T{s
T|r
T}q
T~p
Uo~
Uo~
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