Commit b54b5525 by Gürcan Güleç

committing treasure hunt

parent 8906f07b
/**
* File: tre.c
* Author: Gurcan Gulec
* Created: 15 December 2016
* Last Edit: 20 December 2016
*
* Description: Treasure hunt.
*
*/
#include "treasure.h"
void task1();
void task2();
int task3();
void task4(int length);
void task5();
int main()
{
init_treasure_hunt(165515);
task1();
task2();
task4(task3());
task5();
show_stats();
end_hunt();
return 0;
}
void task1()
{
long long a,b;
start_1(&a, &b);
printf("Start: %lli End: %lli\n", a, b);
for(int i = a; a < b+1; i++)
{
if(check_1(0, i) == 0)
{
check_1(2, i);
break;
}
}
//check_1(SHOW_RESULT, a + 94230);
}
void task2()
{
char *data;
start_2(&data);
printf("Data: %s\n", data);
long long number = atoi(data);
check_2(2, number);
}
int task3()
{
long long value;
char array[10];
start_3(&value);
printf("Data: %lli\n", value);
sprintf(&array[0], "%llx", value);
check_3(2, array);
return strlen(array);
}
void task4(int length)
{
start_4();
check_4(2, length);
}
void task5()
{
char *message;
char decripted[100];
start_5(&message);
int len = strlen(message);
int counter = 0;
while(1)
{
for(int i = 0; i < len; i++)
{
decripted[i] = (char)((int)message[i]-counter);
}
if(check_5(0, decripted) == 0)
{
printf("Message: %s\n", decripted);
check_5(2, decripted);
break;
}
counter++;
}
}
/*
* Authors:
* Jürgen Soom
* Jan Toodre
* Date:
* 19.11.2016
* Updated:
* 08.12.2016
* Description:
* Treasure hunt in programming 1
*
*/
#ifndef __TREASURE_H__
#define __TREASURE_H__
//
// Includes
//
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <inttypes.h>
#include <time.h>
#include <ctype.h>
//
// Defines
//
#define SHOW_NONE 0 // Displays nothing
#define SHOW_HINT 1 // Displays hint
#define SHOW_RESULT 2 // Shows only result
//
// Function prototypes
//
int8_t init_treasure_hunt(int code);
void end_hunt();
// Puzzles
int start_1(long long *begin, long long *end);
int start_2(char **data);
int start_3(long long *value);
int start_4();
int start_5(char **message);
int start_6(int **array, size_t *size);
int start_7();
int start_8(const char *input);
int start_9(const char *input, size_t *size);
int start_10(char **filename, size_t *size);
// Puzzle check / guess
int check_1(uint8_t show_msg, long long guess);
int check_2(uint8_t show_msg, long long guess);
int check_3(uint8_t show_msg, char *guess);
int check_4(uint8_t show_msg, size_t guess);
int check_5(uint8_t show_msg, char *hidden_message);
int check_6(uint8_t show_msg, int guess);
int check_7(uint8_t show_msg, int (*function)(const int *, size_t));
int check_8(uint8_t show_msg, const char *output);
int check_9(uint8_t show_msg, int *array);
int check_10(uint8_t show_msg, char *msg);
// Show statistics
void show_stats();
#endif
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment