blk_box_tc/main/steps/wires_puzzle.h
2024-08-04 15:51:39 -05:00

40 lines
1.1 KiB
C

#ifndef WIRES_PUZZLE_H
#define WIRES_PUZZLE_H
#include <stdint.h>
#include <esp_random.h>
#include <string.h>
#include "esp_vfs_fat.h"
#define NUM_COLORS 6
#define NUM_WIRES 8
typedef enum {
red = 0,
yellow = 1,
green = 2,
blue = 3,
black = 4,
white = 5,
} WiresColor;
void solve_wires(WiresColor* wires, bool* out_cut);
void generate_new_wires(WiresColor* wires);
void cut_to_string(bool* cut, char* out_cut_string);
void wires_to_string(WiresColor* wires, char* out_wires_string);
void string_to_wires(char* wires_string, WiresColor* out_wires);
void save_wires_to_sd_card(WiresColor* wires);
void load_wires_from_sd_card(WiresColor* out_wires);
/// @brief Fills the array with 6 random WiresColors.
/// @param wires the array of len >= 6 to be populated with random colors
void generate_new_wires(WiresColor* wires);
/// @brief Solves the wires puzzle, setting `out_cut` according to which wires are cut.
/// @param wires the array of len >= 6 as input to the solver
/// @param out_cut the output array of len >= 6 for which wires to cut
void solve_wires(WiresColor* wires, bool* out_cut);
#endif /* WIRES_PUZZLE_H */