Size: 1570 bytes.


 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
// cs/q/numeronym/numeronym.h
#ifndef CS_Q_NUMERONYM_NUMERONYM_H
#define CS_Q_NUMERONYM_NUMERONYM_H

#include <stdbool.h>
#include <stddef.h>

// Determines if the given input string is a numeronym of
// the given pattern.
bool IsNumeronym(char* pattern, size_t m, char* input,
                 size_t n);

// Determines if the given index is in the bounds of the
// array.
bool InArrayBounds(const char* s, size_t n, size_t i);

// Checks if a character is in [A-Za-z].
bool IsAlpha(char c);

// Checks if a character is in [0-9].
bool IsNumeral(char c);

// Tries to parse an unsigned int at and after pattern[i].
//
// If an unsigned int can be parsed from the string, the
// indexer *i will be incremented to the last index of the
// number in the string, the *number out param will be
// set to the parsed number, and true will be returned.
//
// If the unsigned int cannot be parsed, *i will not be
// incremented, *number will not be set, and false will be
// returned.
bool TryParseUInt(char* pattern, size_t* i, size_t m,
                  size_t* number);

// Moves the cursor forward in the input string by the given
// `number` of steps. If the final cursor position will be
// in-bounds, `j` will be set. `n` is the length of the
// `input`. The method returns a success flag. If not
// successful, `j` is not set. The cursor will stop on the
// last character of the substring `input[j:j+number]`, i.e.
// `j + number - 1`.
bool ScrollForward(const char* input, size_t* j, size_t n,
                   size_t number);

#endif  // CS_Q_NUMERONYM_NUMERONYM_H
v0 (commit) © 2025 @p13i.io | Load balancer proxied to: cs-code-viewer-1:8080 in 4ms.