Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python
# -*- coding: UTF-8 -*-
# battleship game
import sys
import random
def is_valid_int(integer):
"""
checks to see if number represents a valid integer
# play the game of connect 4
def make_board():
"""
create the blank connect game board
It's a list of list 6 X 7
@returns: the board created(list)
"""
board = []
# play the battleship game
import sys
import random
def is_valid_int(integer):
"""
checks to see if number represents a valid integer
@number: a string that might represent an integer
@returns: true if the string represents an integer
/*
* reverse_int.c
*
*
* Read an integer from stdin, reverse it,
* and print if back to the user.
*/
#include <ctype.h>
#include <stdlib.h>
/*
* sort_lines.c
*
*
* Read in an array of lines from stdin, sort them ,
* and print the sorted strings back.
*/
#include <ctype.h>
#include <stdlib.h>
/*
* get_string.c
*
*
* Read a string from stdin,
* store it in an array,
* and print it back to the user.
*/
#include <ctype.h>
@X140Yu
X140Yu / Monokai.style
Created April 11, 2017 01:49
A Monokai color theme for MWeb
editor
foreground: F5F5F5
background: 1B1E1C
caret: AF5F00
editor-selection
foreground: FFFFFF
background: 3E3E3E
H1
@X140Yu
X140Yu / cal.sh
Last active September 16, 2017 16:36
A shell script which helps you calculate a specific person's contribution
#!/bin/sh
if [ "$#" -ne 1 ]; then
echo "Usage: $0 Author-Name"
exit 1
fi
echo Total Commit: $(git log --author=$1 --pretty=tformat: --oneline | wc -l)
git log --author=$1 --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "Added lines: %s, Removed lines: %s, Total lines: %s\n", add, subs, loc }'
/*
* is_palindrome.c
*
*
* Read an input from stdin, print it back to the user and
* report if it is a palindrome.
*/
#include <stdio.h>
#include <stdlib.h>
# 需要检查的 gem 以及对应的版本
requireGems = {
'psych' => '>= 2.1',
}
# cocoapods & psych
requireGems.each do |gem_name, gem_ver_reqs|
gdep = Gem::Dependency.new(gem_name, *gem_ver_reqs)
found_gspec = gdep.matching_specs.max_by(&:version)
if found_gspec