Skip to content

Instantly share code, notes, and snippets.

@kahless62003
kahless62003 / tlhIngan.l
Created January 13, 2020 01:17
Computerphile yoda parsing examples converted to Klingon.
%%
"the" {yylval=1; return(ARTICLE);}
"a" {yylval=2; return(ARTICLE);}
"dog" {yylval=3; return(NOUN);}
"cat" {yylval=4; return(NOUN);}
"man" {yylval=5; return(NOUN);}
"woman" {yylval=6; return(NOUN);}
"robot" {yylval=7; return(NOUN);}
"bit" {yylval=8; return(VERB);}
@kahless62003
kahless62003 / BellaCiao.txt
Last active March 21, 2024 01:14
Various Klingon Translations
jImej bang
wIDanlu'taHvIS, 'op po jIvempu',
'o jImej bang, jImej bang, jImej bang, bang, bang!
wIDanlu'taHvIS, 'op po jIvempu',
muDech yotwI'pu' 'e' vItu'.
'o lotlhbogh SuvwI', qatlhej vIneHbej
'o jImej bang, jImej bang, jImej bang, bang, bang!
'o lotlhbogh SuvwI', qatlhej vIneHbej
@kahless62003
kahless62003 / cups_stacker_stdin.c
Created April 26, 2018 14:27
Cup Stacking exercise from Kattis
/*
*
Stacking Cups
You are programming a cup stacking module for your robot. This robot is equiped with several sensors that can accurately determine the radius and color of a cup. The problem is that there is a glitch in the robot’s core routine that processess sensor inputs so the radius is doubled, if the result of the color sensor arrives to the routine after the radius.
For instance, for a red cup with a radius of 5 units, your module will receive either "red 5" or "10 red" message.
Given a list of messages from the core routine, each describing a different cup, can you put the cups in order of the smallest to the largest?
@kahless62003
kahless62003 / LoL_Razzer_prob_editj.c
Last active September 30, 2016 00:07
Modified program for repeated input and transfer of chars between arrays
#include <stdio.h>
#include <string.h>
//moved the fixed sizes to defines and have 2. 1 for the main buffer, and one for the name fields
#define maxinput 256
#define maxname 16
int main()
{
char input[maxinput];//large buffer to accept more input than name fields allow - note that too can overflow as the value is fixed
@kahless62003
kahless62003 / hash_square.c
Created April 25, 2016 20:21
Basic user input loop for numbers in range, modified to work with non numeric input and clear rubbish from stdin one of two ways.
#include <stdio.h>
int clean_stdin()
{
while (getchar()!='\n');
return 1;
}
int main(void)
{
/*
* keep_the_change_ya_filthy_animal.c
* low tech variable based approach
*/
#include <stdio.h>
#include <string.h>
@kahless62003
kahless62003 / readfromfile_reallybasic.c
Last active January 9, 2016 21:52
Basic file reading code with many comments
/*This program will read characters from a file, and for each line:
* print it, followed by the count of the characters in that line.*/
#include <stdio.h>
int main(void)
{
char filename[]="testinputfile.txt";
/*This is a pointer that will point to the file (a single point in the file, not a whole line).
@kahless62003
kahless62003 / asciihouse.c
Last active September 23, 2015 14:49
Daily Programmer Challenge #233 [Easy] The house that ASCII built
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
/*Processes the input file*/
int process_file(void)
{
@kahless62003
kahless62003 / grannyshouse_dnc.c
Last active September 23, 2015 13:13
r dailyprogrammer challenge 232 intermediate Grandma's House
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <time.h>
/*Finds length of longest line in file*/
int charcount(char *filename)
@kahless62003
kahless62003 / palindrome.c
Last active September 17, 2015 08:10
r dailyprogrammer 20150914 Challenge 232 Easy
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
/*Finds length of longest line in file*/
int charcount(char *filename)
{