-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEuler_Problem-033.b93
69 lines (50 loc) · 2.45 KB
/
Euler_Problem-033.b93
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
v
>110p120p"cc" v
vp09p08 < >80g55+/90g55+/-#v_v
>90g80g`!#v_>80g55+/| >80g90g55+/*90g80g55+/*-#v_v
v < < <
>80g55+/90g55+%-#v_v
>80g55+/| >80g90g55+/*90g80g55+%*-#v_v
@v\p05:< v < < <
.>50g%:|: < >80g55+%90g55+/-#v_v
^/\g02$< g>80g55+%| >80g90g55+%*90g80g55+/*-#v_v
0v < < <
2 >80g55+%90g55+%-#v_v
g>80g55+%| >80g90g55+%*90g80g55+%*-#v_v
0v < < <
1> v
^ $_v#!-9p08:-1g08<_v#!-9p09:-1g09<p02*g09g02p01*g08g01<
^ p0 9"c"<
^ ># ^#<
[1,0] numerator
[2,0] denominator
[5,0] euclid (temp)
[8,0] A
[9,0] B
// Iterate through every possible fraction
v ># #< v# p09"c"<
"cc"80p90p>90g80g`!#^_ 80g."/",90g.55+, 90g1-:90p9-#^_>80g1-:80p9-#^_$ @
// isDCF
>80g55+/90g55+/-#v_v
>80g55+/| >80g90g55+/*90g80g55+/*-#v_> @ true
v < < < > @ false
>80g55+/90g55+%-#v_v
>80g55+/| >80g90g55+/*90g80g55+%*-#v_^
v < < <
>80g55+%90g55+/-#v_v
>80g55+%| >80g90g55+%*90g80g55+/*-#v_^
v < < <
>80g55+%90g55+%-#v_v
>80g55+%| >80g90g55+%*90g80g55+%*-#v_^
v < < <
> ^
// GCD (stack,stack -> stack) # uses 50 as temp
>:50p\v
> :|:%g05<
>$ @
---------------------------------------
This one was relaxing. You can simple iterate through all 8100 cases and test each one in short time.
Three notable things:
- You can test two fraction `a/b` and `c/d` simple of equality with the formula `a*d == b*c`.
- This is my compact [GCD algorithm](http://en.wikipedia.org/wiki/Euclidean_algorithm) in befunge (stack -> stack)
- This is one of the few *real* Befunge-93 programs in this series. (It doesn't violate the [80x25](https://github.com/catseye/Befunge-93/blob/master/doc/Befunge-93.markdown) size rule)