Skip to content

Instantly share code, notes, and snippets.

View y0n1's full-sized avatar
:octocat:
...

y0n1 y0n1

:octocat:
...
View GitHub Profile
@y0n1
y0n1 / Solution.java
Last active March 24, 2024 13:31
Given a string of an arithmetic expression; which includes only two operators: '+', '*' , write a function that evaluates the expression and returns its result.Input: A (possible) very long string of an arithmetic expression: "1*2*3+1+20".Output: 27
public class Solution {
public static void main(String[] args) {
String[] input = { "5", "4+20*3", "20*3+4", "20+20+20+4", "4*4*4" };
for (String test : input)
System.out.printf("%s = %d%n", test, eval(test));
}
private static int eval(String input) {
int sum = 0;
@y0n1
y0n1 / RemoveVSCodeFileExtRegistrations.py
Last active March 24, 2024 13:32
Removes file extension registration made by Visual Studio Code installer.
#! /usr/bin/python
import sys, subprocess
def main(argv=None):
try:
query = [item.replace('REG_SZ', '').strip() for item in subprocess.check_output("reg query HKCR /v VSCode.* /s").splitlines() if len(item) > 0][0: -1]
queryItems = [(query[i],query[i+1]) for i in range(0, len(query), 2)]
for item in queryItems:
print("Deleting {0} from {1}".format(item[0], item[1]))