Skip to content

Instantly share code, notes, and snippets.

@games
games / gist:02c5b1771e63bb8ac12a
Last active August 29, 2015 14:17
机器人 Robot
create a robot, it can handle commands as below;
"L" -> turn left
"R" -> turn right
"M" -> forward
"B" -> back
place it on a 2D map(x*y), and pass commands "LLRRLLMMBRL" to this robot, then the robot will move to the target place
example:
@games
games / gist:1a3e677637c799195db4
Last active August 29, 2015 14:16
give me the answer
题目一:
给你一个数学表达式,字符串形式的,只有简单的+-*/操作符,你计算出这个数学表达式的结果
input> "10*2-(2+5)"
output> 10
题目二:
把上面的程序改成可以支持S表达式
input> (- (* 10 2) (+ 2 5))
output> 10
@games
games / gist:3c1dbd9315403373c480
Last active August 29, 2015 14:16
how to refactor
module M4 =
type Result<'Success, 'Failure> =
| Success of 'Success
| Failure of 'Failure
type Request = {Name: string; Password: string; NewName: string}
let Process request =
match request with
| {Name = ""} -> Failure "Name must not be blank"
@games
games / math_expression_csharp.cs
Last active August 29, 2015 14:16
Math expression
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
namespace mathexpression {
interface Term {
@games
games / manipulate2d.dart
Last active December 20, 2015 02:59
A example of manipulate 2d in webgl
class Manipulate2d {
CanvasElement _canvas;
RenderingContext _gl;
int _positionAttri, _translationAttri, _rotationAttri, _scaleAttri;
Buffer _vertexBuffer, _translationBuffer, _rotationBuffer, _scaleBuffer, _indicesBuffer;
UniformLocation _resolutionUniform;
Manipulate2d(c) {
_canvas = c;
_gl = _canvas.getContext3d(preserveDrawingBuffer: true);