Skip to content

Instantly share code, notes, and snippets.

View jamby77's full-sized avatar

Petar Dzhambazov jamby77

View GitHub Profile
@jamby77
jamby77 / wesbos-array-problem.js
Created December 16, 2020 15:19
Given the input data in shape of arr1, arr2, arr3, produce array in desired format
// input
const arr1 = [
["name", "id", "age", "weight", "Cool"],
["Susan", "3", "20", "120", true],
["John", "1", "21", "150", true],
["Bob", "2", "23", "90", false],
["Ben", "4", "20", "100", true],
];
const arr2 = [
@jamby77
jamby77 / matrix_multipl_pointer.cpp
Last active November 26, 2018 15:22
Умножение на матрици via pointers
#include <iostream>
using namespace std;
const int MAX = 100;
void printMatrix(int *m, int N)
{
int i = 1;
for (int *ptr1 = m; ptr1 < m + N * N; ++ptr1, ++i)
{
std::cout << *ptr1 << ' ';
// Zad 2
const num = 14; // input
let w = n * 2; // for width we need double of N
let h = 2 * n + 2; // height in problem description
for (let i = 0; i < h; i++) {
let row = '';
// iterate each level
for (var j = 0; j < w; j++) {
// iterate width
if (i < n) {
#include <string>
#include <iostream>
using namespace std;
struct Student
{
string name;
string school;
double grade;
#include <iostream>
#include <fstream> // std::ifstream, std::ofstream
using namespace std;
int main()
{
int N, num, res;
streampos size;
ofstream outfile("new.txt", ios::out | ios::binary);
if (!outfile.is_open())
{
#include <iostream>
#include <string>
using namespace std;
void toBin(int n)
{
if (n == 0 || n == 1)
{
cout << n;
return;
void minMax(int arr[],int size) {
int min, max, minIdx, maxIdx;
for (int i = 0; i < size; i++)
{
if (i == 0) {
// при първото завъртане, слагаме стойността на мин и макс като стойността на
// първия елемент на масива и прескачаме на следващото завъртане
min = max = arr[i];
minIdx = maxIdx = 0;
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
string decimalToBinary(unsigned int a)
{
string b = "";
if (a == 0)
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
int N, t, a,b,c;
int Nmax = 1000000; // po uslovie N ne moje da e poveche ot tova chislo
int tMax = 10000; // vs chislo sled N ne moje da e poveche ot tova
cin >> N;
cout << "N is: " << N << "\n";
@jamby77
jamby77 / Main.java
Created October 27, 2016 20:37
loop with 'modulo'
public static void main(String[] args) {
int noOfRows = 1234;
for (int i = 0; i < noOfRows; i++) {
if (i > 0 && i % 18 == 0) {
System.out.println(1);
}
}
}