aboutsummaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-04-13 19:22:49 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2024-04-13 19:22:49 +0200
commit59ecc0ee72a180692fcccab88db310d60021f2ab (patch)
tree0038b500b6af1bb5b5c95e5aed590ce33b13401b /example
parentec87f96ffec31c430b6058663ae831c1b3a29ff9 (diff)
downloadcubecore-59ecc0ee72a180692fcccab88db310d60021f2ab.tar.gz
cubecore-59ecc0ee72a180692fcccab88db310d60021f2ab.zip
Fixed howto, added example
Diffstat (limited to 'example')
-rwxr-xr-xexample/a.outbin0 -> 49752 bytes
-rwxr-xr-xexample/compile.sh1
-rw-r--r--example/example.cpp34
-rw-r--r--example/example.obin0 -> 33856 bytes
4 files changed, 35 insertions, 0 deletions
diff --git a/example/a.out b/example/a.out
new file mode 100755
index 0000000..ef2babe
--- /dev/null
+++ b/example/a.out
Binary files differ
diff --git a/example/compile.sh b/example/compile.sh
new file mode 100755
index 0000000..4ce3bd2
--- /dev/null
+++ b/example/compile.sh
@@ -0,0 +1 @@
g++ example.cpp ../cube.o
diff --git a/example/example.cpp b/example/example.cpp
new file mode 100644
index 0000000..60c998f
--- /dev/null
+++ b/example/example.cpp
@@ -0,0 +1,34 @@
1#include <cinttypes>
2#include <iostream>
3#include <vector>
4
5extern "C" {
6#include "../cube.h"
7}
8
9cube_t apply_alg(cube_t cube, std::vector<move_t> *moves) {
10 auto ret = cube;
11
12 for (auto m : *moves)
13 ret = cube_move(ret, m);
14
15 return ret;
16}
17
18int main() {
19 auto cube = cube_new();
20 auto moves = new std::vector<move_t> { R, U, R3, U3 };
21 char cstr[500];
22
23 std::cout << "The solved cube looks like this in H48 notation:\n";
24 cube_write((char *)"H48", cube, cstr);
25 std::string solvedstr(cstr);
26 std::cout << solvedstr << "\n";
27 std::cout << "After a sexy move it looks like this:\n";
28 cube = apply_alg(cube, moves);
29 cube_write((char *)"H48", cube, cstr);
30 std::string sexystr(cstr);
31 std::cout << sexystr << "\n";
32
33 return 0;
34}
diff --git a/example/example.o b/example/example.o
new file mode 100644
index 0000000..af95a15
--- /dev/null
+++ b/example/example.o
Binary files differ

Generated with cgit - Back to sebastiano.tronto.net