diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/nissy.c | 41 | ||||
| -rw-r--r-- | src/nissy.h | 25 |
2 files changed, 0 insertions, 66 deletions
diff --git a/src/nissy.c b/src/nissy.c index 8aa0334..bf56f40 100644 --- a/src/nissy.c +++ b/src/nissy.c | |||
| @@ -142,47 +142,6 @@ my_strnlen(const char *str, size_t maxlen) | |||
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | long long | 144 | long long |
| 145 | nissy_compose( | ||
| 146 | const char cube[static NISSY_SIZE_CUBE], | ||
| 147 | const char permutation[static NISSY_SIZE_CUBE], | ||
| 148 | char result[static NISSY_SIZE_CUBE] | ||
| 149 | ) | ||
| 150 | { | ||
| 151 | cube_t c, p, res; | ||
| 152 | long long err; | ||
| 153 | |||
| 154 | c = readcube(cube); | ||
| 155 | |||
| 156 | if (!isconsistent(c)) { | ||
| 157 | LOG("[compose] Error: the given cube is invalid\n"); | ||
| 158 | err = NISSY_ERROR_INVALID_CUBE; | ||
| 159 | goto nissy_compose_error; | ||
| 160 | } | ||
| 161 | |||
| 162 | p = readcube(permutation); | ||
| 163 | |||
| 164 | if (!isconsistent(p)) { | ||
| 165 | LOG("[compose] Error: given permutation is invalid\n"); | ||
| 166 | err = NISSY_ERROR_INVALID_CUBE; | ||
| 167 | goto nissy_compose_error; | ||
| 168 | } | ||
| 169 | |||
| 170 | res = compose(c, p); | ||
| 171 | |||
| 172 | if (!isconsistent(res)) { | ||
| 173 | LOG("[compose] Unknown error: resulting cube is invalid\n"); | ||
| 174 | err = NISSY_ERROR_UNKNOWN; | ||
| 175 | goto nissy_compose_error; | ||
| 176 | } | ||
| 177 | |||
| 178 | return write_result(res, result); | ||
| 179 | |||
| 180 | nissy_compose_error: | ||
| 181 | writecube(ZERO_CUBE, NISSY_SIZE_CUBE, result); | ||
| 182 | return err; | ||
| 183 | } | ||
| 184 | |||
| 185 | long long | ||
| 186 | nissy_inverse( | 145 | nissy_inverse( |
| 187 | const char cube[static NISSY_SIZE_CUBE], | 146 | const char cube[static NISSY_SIZE_CUBE], |
| 188 | char result[static NISSY_SIZE_CUBE] | 147 | char result[static NISSY_SIZE_CUBE] |
diff --git a/src/nissy.h b/src/nissy.h index 4b2d1eb..e7ae50e 100644 --- a/src/nissy.h +++ b/src/nissy.h | |||
| @@ -126,31 +126,6 @@ of this kind to sebastiano@tronto.net. Thanks! | |||
| 126 | /* Library functions *********************************************************/ | 126 | /* Library functions *********************************************************/ |
| 127 | 127 | ||
| 128 | /* | 128 | /* |
| 129 | Apply the secod argument as a permutation on the first argument. | ||
| 130 | |||
| 131 | Parameters: | ||
| 132 | cube - The first cube. | ||
| 133 | permutation - The second cub. This cube is treated as a permutation and | ||
| 134 | "applied" to the first cube. | ||
| 135 | result - The return parameter for the resulting cube. | ||
| 136 | |||
| 137 | Return values: | ||
| 138 | NISSY_OK - The cubes were composed succesfully. | ||
| 139 | NISSY_WARNING_UNSOLVABLE - The resulting cube is not solvable. This is | ||
| 140 | either because at least on of the given cubes | ||
| 141 | was not solvable, or due to an unknown internal | ||
| 142 | error. | ||
| 143 | NISSY_ERROR_INVALID_CUBE - At least one of the given cubes is invalid. | ||
| 144 | NISSY_ERROR_UNKNOWN - An unknown error occurred. | ||
| 145 | */ | ||
| 146 | long long | ||
| 147 | nissy_compose( | ||
| 148 | const char cube[static NISSY_SIZE_CUBE], | ||
| 149 | const char permutation[static NISSY_SIZE_CUBE], | ||
| 150 | char result[static NISSY_SIZE_CUBE] | ||
| 151 | ); | ||
| 152 | |||
| 153 | /* | ||
| 154 | Compute the inverse of the given cube. | 129 | Compute the inverse of the given cube. |
| 155 | 130 | ||
| 156 | Parameters: | 131 | Parameters: |
