Skip to content

Instantly share code, notes, and snippets.

h = 0
while True:
try:
h = int(input("Height: "))
except ValueError:
continue
if int(h) < 1 or int(h) > 64:
continue
else:
break
let multiply = function(num1, num2) {
if(isNaN(num1) || isNaN(num2)) return ''
let len1 = num1.length,
len2 = num2.length
let ans = []
for (let i = len1 - 1; i >= 0; i--) {
for (let j = len2 - 1; j >= 0; j--) {
let index1 = i + j,
@nuoxoxo
nuoxoxo / scanf_regex.md
Last active October 10, 2021 12:28
scanf regex + rounding float to 1 decimal place
input as output
12
4.0
Hello, World!
#include <stdio.h>

int main(void)
@nuoxoxo
nuoxoxo / get_num.cpp
Created October 22, 2021 22:53
c++ : get numbers from a string
while (getline(std::cin, s))
{
stringstream ss(s);
while (!ss.eof())
{
ss >> temp;
if (stringstream(temp) >> n)
cout << n << " ";
}
cout << endl;
@nuoxoxo
nuoxoxo / game_of_life.cpp
Created December 27, 2021 13:09
Conway's Game of Life - C++/Terminal
#include <iostream>
#include <sstream>
#include <vector>
#include <ctime>
using namespace std;
using vvi = vector<vector<int>>;
// DRIVE
@nuoxoxo
nuoxoxo / helloworld.md
Created December 28, 2021 22:47
Hello, World_
 _          _ _                            _     _ _
| |__   ___| | | ___   __      _____  _ __| | __| | |
| '_ \ / _ \ | |/ _ \  \ \ /\ / / _ \| '__| |/ _` | |
| | | |  __/ | | (_) |  \ V  V / (_) | |  | | (_| |_|
|_| |_|\___|_|_|\___/    \_/\_/ \___/|_|  |_|\__,_(_)
@nuoxoxo
nuoxoxo / deque.h
Last active July 4, 2022 20:40
Deque Implementation in C
#ifndef DEQUE_H
# define DEQUE_H
# include "stdlib.h"
# include "stdio.h"
typedef struct s_deque
{
struct s_deque_node *head;
struct s_deque_node *tail;
int len;
@nuoxoxo
nuoxoxo / philo.h
Last active July 17, 2022 21:50
Philosophers - Sim without soln
#include "stdlib.h"
#include "string.h"
#include "unistd.h" // time
#include "pthread.h"
#include "stdio.h"
typedef struct s_philo
{
int how_many_people;
int id; /* The philosopher's id: 0 to 5 */
@nuoxoxo
nuoxoxo / quantum_spoons.md
Last active July 17, 2022 18:57
Quantum Spoons - The _NO_ Solution

Quantum Spoons - The NO Solution

malloc

pthread_mutex_t	*block_monitor;
block_monitor = (pthread_mutex_t *) malloc( sizeof(pthread_mutex_t) );

t_philo		*persons;
persons = (t_philo *) malloc( sizeof(t_philo) * 5 );
@nuoxoxo
nuoxoxo / Makefile
Created August 11, 2022 23:40
Party
party :
@printf "\033c"
@echo "\n\033[35m♪┏(・o・)┛♪"
@sleep 1
@printf "\033c"
@echo "\033[1;33m♪┗(・o・)┓♪"
@sleep 1
@printf "\033c"
@echo "\n\033[36m♪┏(・o・)┛♪"
@sleep 1