This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.util.*; | |
public class Substrings { | |
static boolean DEBUG = false; | |
static Set<String> substrings(String source){ | |
Set<String> substrings = new TreeSet<>(); | |
for (int i = 0; i < source.length(); i++) { | |
for (int j = i + 1; j <= source.length(); j++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
/** | |
* Construct a tree like this one: | |
* <pre> | |
* 1 | |
* / \ | |
* 2 3 | |
* / \ \ | |
* 4 5 6 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
** Visualizing Binary Trees in ASCII ** | |
1 Let's try something different. The left child goes to the right. | |
/ \ | |
2 3 <--- No room for 3.left 1 2 4 7 | |
/ \ \ 3 9 | |
4 5 6 5 <-- The oddness is here because we had to skip a row. | |
/ \ 6 But there is no ambiguity! | |
7 8 <--- Width totally determined by leaves! 8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private final static Logger LOGGER = Logger.getLogger(Main.class.getName()); | |
private static void setupLogger(){ | |
FileHandler fileTxt = null; | |
try { | |
fileTxt = new FileHandler("runtime.log"); | |
} catch (IOException ignored) {} | |
SimpleFormatter formatterTxt = new SimpleFormatter(); | |
fileTxt.setFormatter(formatterTxt); | |
LOGGER.severe("Severe Log"); | |
LOGGER.addHandler(fileTxt); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create table jemp (a json, b int); | |
drop table jemp; | |
select * from jemp; | |
-- Define a virtual index https://dev.mysql.com/doc/refman/5.7/en/create-table-secondary-indexes.html | |
create table jemp (a json, b int generated always as (a->'$.a'), index i (b)); | |
insert into jemp (a) values ('{"a":123}'); | |
-- https://dev.mysql.com/doc/refman/5.7/en/json.html MySQL 5.7.8 | |
select JSON_TYPE("1"); | |
select JSON_ARRAY(1, "", NOW()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function makeList(n){ | |
var head = {'i':0}; | |
var prev = head; | |
var current; | |
for (var i = 1; i < n; i++) { | |
current = {'i': i}; | |
prev.next = current; | |
prev = current; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%%------------------------------------------------------------------- | |
%%% @author Josh Rehman | |
%%% @copyright (C) 2017, JavaJosh Enterprises | |
%%% @doc | |
%%% | |
%%% @end | |
%%% Created : 27. Feb 2017 6:54 PM | |
%%%------------------------------------------------------------------- | |
-module(l2). | |
-author("Josh Rehman"). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%%------------------------------------------------------------------- | |
%%% @author Josh Rehman | |
%%% @copyright (C) 2017, JavaJosh Enterprises | |
%%% @doc | |
%%% | |
%%% @end | |
%%% Created : 27. Feb 2017 5:28 PM | |
%%%------------------------------------------------------------------- | |
-module(l). | |
-author("Josh Rehman"). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%%------------------------------------------------------------------- | |
%%% @author Josh Rehman | |
%%% @copyright (C) 2017, JavaJosh Enterprises, Inc. | |
%%% @doc https://www.futurelearn.com/courses/functional-programming-erlang/1/assignments/161825/submission/new | |
%%% | |
%%% @end | |
%%% Created : 26. Feb 2017 6:02 PM | |
%%%------------------------------------------------------------------- | |
-module(pattern). | |
-author("Josh Rehman"). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%%------------------------------------------------------------------- | |
%%% @author josh | |
%%% Created : 25. Feb 2017 10:44 AM | |
%%%------------------------------------------------------------------- | |
-module(tail). | |
-author("josh"). | |
-export([fib/3, fib/1, loop/1, perfect/1, lp/1]). | |
%Hmm..there seems to be a bug in this one. | |
fib(N) -> fib(N,0,1). |