Skip to content

Instantly share code, notes, and snippets.

View ebanisadr's full-sized avatar

Eric Banisadr ebanisadr

View GitHub Profile
/*
* Copyright 2016 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@ebanisadr
ebanisadr / KarelDriver.java
Last active June 6, 2017 16:45
Karel KeyListener
//Add these lines to the top of your main method to make the key listener work
//implement the variable listener however you want, this anonymous one is just a sample
KeyListener listener = new KeyListener() {
@Override
public void keyPressed(KeyEvent e) {
//using e.getChar() is not always a reliable way to find out what key is pressed
//I think you're supposed to use e.getKeyCode which will return an int representing a VK_ (virtual key) value
System.out.println("pressed " + e.getKeyChar());
}
import java.util.Scanner;
public class DeletionsEasy {
public static void main(String[] args) {
String in = parseLine();
int count = deletionGame(in);
System.out.println(count);
}
static String parseLine() {
public class LongestPalindrome {
public static String getLongestPalindrome(final String input) {
int rightIndex = 0, leftIndex = 0;
String currentPalindrome = "", longestPalindrome = "";
for (int centerIndex = 1; centerIndex < input.length() - 1; centerIndex++) {
leftIndex = centerIndex - 1; rightIndex = centerIndex + 1;
while (leftIndex >= 0 && rightIndex < input.length()) {
if (input.charAt(leftIndex) != input.charAt(rightIndex)) {
break;
}
@ebanisadr
ebanisadr / build-site.js
Created May 25, 2020 00:31
Simple Javascript SSG
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const compile = require('./compiler');
const inputDir = 'content';
const outputDir = 'stage';