Skip to content

Instantly share code, notes, and snippets.

View ghoomfrog's full-sized avatar
💭
losing

ghoom ghoomfrog

💭
losing
  • Agadir, Morocco
  • 14:48 (UTC +01:00)
  • Reddit u/Unlimiter
View GitHub Profile
@ghoomfrog
ghoomfrog / extract_from_date.c
Last active May 27, 2019 08:48
Functions to extract the year, the month and the day of a date integer (like 20151126), without using strings.
/* Functions to extract the year, the month and the day of a date integer (like 20151126), without using strings.
*
* by Unlimiter
*/
#include <stdio.h>
#include <math.h>
// returns the number of digits in an integer
int get_int_len(int n) {
@ghoomfrog
ghoomfrog / upisc.c
Last active May 24, 2019 19:14
A method to compress strings of digit pairs to strings of predefined symbols.
/* upisc (Unlimiter's Pair-based Integer String Compression)
* A method to compress strings of digit pairs into strings of predefined symbols.
* The symbol dictionary doesn't contain every possible combination of pairs, but pairs that can be reversed to produce other pairs.
*
* In the command line, the program takes 1 argument, the integer string you want compress. It must have an even length.
* If one of the pairs in the argument is not in the dictionary, the program reverses it then translates it, after that, it puts a dot after it to denote it has been reversed.
*
* — Unlimiter
*/
#include<limits.h>
#include<stdio.h>
#include<math.h>
// arithmetical definition of "abs"
int abs(int i) {
return pow((i*i), 0.5);
}
int f1(int num)