Skip to content

Instantly share code, notes, and snippets.

View gudnm's full-sized avatar

Ivan Vashchenko gudnm

View GitHub Profile
@gudnm
gudnm / pomodoro.html
Last active April 8, 2018 02:27
Simple pomodoro timer (written in vanilla JS)
<div>
<div id="history">
<ul id="completed_tasks">
</ul>
</div>
<div id="working">
Working on <span id="current_task">current task</span>, <span id="task_countdown">25:00</span> left.
</div>
<div id="break">
Completed <span id="finished_task">a task</span>. On break, <span id="break_countdown">5:00</span> left.
@gudnm
gudnm / cube.py
Created June 30, 2017 00:29
The dumbest solution for eraser cube puzzle
from itertools import permutations
pieces = [[0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0],
[0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0],
[0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1],
[1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1],
[0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0],
[0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1]]
def rotations(piece):
@gudnm
gudnm / objectsEqual.js
Created June 26, 2017 15:53
JavaScript function for checking if two objects are equal by value
var objectsEqual = (a, b) => {
const aProps = Object.getOwnPropertyNames(a),
bProps = Object.getOwnPropertyNames(b);
if (aProps.length != bProps.length) {
return false;
}
for (var i=0; i<aProps.length; i++) {
const propName = aProps[i];
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#include <iostream>
using namespace std;
int main() {
int count = 0, foo = 0, i = 0, j = 0, m = 0, n = 0;
const int LEN = 10;
int a[LEN][LEN];
int b[LEN][LEN];
for (i = 0; i < LEN; i++) {
for (j = 0; j < LEN; j++) {
@gudnm
gudnm / reverse_mn.ipynb
Created October 12, 2016 16:39
Reverse part of linked list
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gudnm
gudnm / sherlock.lc
Created September 5, 2016 22:19
Sherlock and the Beast problem from Hackerrank, in LOLCODE
HAI 1.1
I HAS A t ITZ A YARN
GIMMEH t
MAEK t A NUMBR
VISIBLE t
BTW I HAS A count ITZ 0
IM IN YR mainloop UPPIN YR count TIL BOTH SAEM count AN t
I HAS A n ITZ A NUMBR
GIMMEH n
VISIBLE n
import collections
class TrieNode(object):
def __init__(self, letter=None):
self.letter = letter
self.freq = 1
self.suffixes = collections.OrderedDict()
def add(self, word):
node = self
for letter in word:
# Definition for a binary tree node
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
# @param A : root node of tree
# @return an integer