aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--max2.bf36
1 files changed, 36 insertions, 0 deletions
diff --git a/max2.bf b/max2.bf
new file mode 100644
index 0000000..f2665d4
--- /dev/null
+++ b/max2.bf
@@ -0,0 +1,36 @@
+# Show the maximum number
+
+# == Preparations ==
+
+# input the 1st number into the 1st cell
+, # |a|0|0|0|0|0|
+
+# copy 1st cell into the 2nd and the 5th cells
+[->+>>>+<<<<] # |0|a|0|0|a|0|
+
+
+# input the 2nd number into the 1st cell
+, # |b|a|0|0|a|0|
+
+# copy 1st cell into the 3nd and the 6th cells
+[->>+>>>+<<<<<] # |0|a|b|0|a|b|
+
+> # move to the 2nd cell
+
+
+
+# == Main loop ==
+
+# decrement both 2nd and 3rd cells by 1,
+# the final position depends on which number is bigger
+[[->]<<]
+
+
+# == Result ==
+# go to the answer
+>>>>
+
+# show the answer
+.
+
+