Skip to content

Instantly share code, notes, and snippets.

View inxanedev's full-sized avatar

inxanedev

View GitHub Profile
@inxanedev
inxanedev / inxbf.cpp
Created February 6, 2022 09:54
Brainfuck intepreter in C++
#include <vector>
#include <iostream>
#include <string>
#include <fstream>
#include <unordered_map>
class Interpreter {
public:
using SourceType = std::vector<char>;
@inxanedev
inxanedev / seven-segment-display-longest-word-finder.cpp
Created February 26, 2021 17:57
C++ program to find the longest word that's displayable on a seven segment display.
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
int main(int argc, char** argv) {
if (argc == 1) {
std::cout << "Usage: " << argv[0] << " <word list path>" << std::endl;
return -1;
}
#include <iostream>
#include <ncurses.h> // curses library
#include <vector>
#include <cstdlib> // rand()
#include <ctime> // for initializing random
#include <unistd.h> // usleep()
// Amount of drops to create on the screen
const unsigned int DROP_AMOUNT = 50;
#include <iostream>
#include <thread>
#include <chrono>
double benchmark(void (*f)()) {
auto start = std::chrono::high_resolution_clock::now();
// Call the function
(*f)();
auto end = std::chrono::high_resolution_clock::now();
// Subtract times and return result as a double
#include <iostream>
#include <string>
#include <sstream>
class FizzBuzz {
private:
int m_Current;
std::ostringstream m_Stream;
public:
FizzBuzz() {
@inxanedev
inxanedev / numpy.linspace.cpp
Created August 29, 2020 20:27
numpy.linspace from Python made in C++ - returns a list of x amount of evenly spaced numbers within a range
#include <iostream>
#include <vector>
std::vector<double> linearSpace(double a, double b, int amount) {
std::vector<double> result;
double step = (std::max(a, b) - std::min(a, b)) / amount;
for (double i = a; i <= b; i += step) {
result.push_back(i);
}
return result;
@inxanedev
inxanedev / interpreter.py
Created July 11, 2020 16:01
DIY Interpreter
import sys
def error(linenumber, clause):
print("Error at line \#" + str(linenumber) + ": " + clause)
sys.exit()
with open("code.diy") as f:
data = [line.lstrip("\t") for line in f.read().splitlines()]
labels = {}
for linenum, line in enumerate(data):
if line.endswith(":"):
labels[line.rstrip(":")] = linenum + 1
@inxanedev
inxanedev / TicTacToe.cs
Created April 5, 2020 20:14
TicTacToe by inxane (C#)
using System;
using System.Text;
namespace TicTacToe
{
class Program
{
static void Main(string[] args)
{
Random rand = new Random();