Skip to content

Instantly share code, notes, and snippets.

View sophiebits's full-sized avatar

Sophie Alpert sophiebits

View GitHub Profile

Recover the Sequence

Merge sort is one of the classic sorting algorithms. It divides the input array into two halves, recursively sorts each half, then merges the two sorted halves.

In this problem merge sort is used to sort an array of integers in ascending order. The exact behavior is given by the following pseudo-code:

function merge_sort(arr):
    n = arr.length()
    if n <= 1:
signature Stuff =
sig
type pizza
val x : 7
end
let val x = 5
val y = 7
in
\documentclass[11pt]{article}
\usepackage{enumerate}
\usepackage{fullpage}
\usepackage{fancyhdr}
\usepackage{amsmath, amsfonts, amsthm, amssymb}
\setlength{\parindent}{0pt}
\setlength{\parskip}{5pt plus 1pt}
\pagestyle{empty}
\def\indented#1{\list{}{}\item[]}
$ hg st
$ touch hello
$ hg st
$ rm hello
$ hg st
/* This class is used to create the /topic/projectfeedback page,
* which shows expandable lists of feedback requests that need answering.
*/
var ProjectFeedbackPage = React.createClass({
propTypes: {
topic: React.PropTypes.string.isRequired
},
render: function() {
var helpCollection = new DiscussionItemCollection([], {
topic: this.props.topic,
<!doctype html>
<html>
<head>
<script src="http://cdnjs.cloudflare.com/ajax/libs/es5-shim/2.2.0/es5-shim.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/es5-shim/2.2.0/es5-sham.js"></script>
<script src="http://fb.me/react-0.8.0.min.js"></script>
<script src="http://fb.me/JSXTransformer-0.8.0.js"></script>
<script type="text/jsx">
/** @jsx React.DOM */
var InputBox = React.createClass({
const {useCallback, useEffect, useReducer, useRef} = require('react');
let effectCapture = null;
exports.useReducerWithEmitEffect = function(reducer, initialArg, init) {
let updateCounter = useRef(0);
let wrappedReducer = useCallback(function(oldWrappedState, action) {
effectCapture = [];
try {
let newState = reducer(oldWrappedState.state, action.action);
@sophiebits
sophiebits / reducer-with-effects.js
Last active July 29, 2020 12:10 — forked from davidkpiano/reducer-with-effects.js
An idea for actor-model-based effects with reducers
import {
useReducerWithEffects,
emitEffect,
} from 'react';
// In a component
const UserComponent = () => {
function fetchUserEffect(id, parentRef) {
const controller = new AbortController();