Skip to content

Instantly share code, notes, and snippets.

View pinglunliao's full-sized avatar

pinglunliao pinglunliao

View GitHub Profile
@pinglunliao
pinglunliao / PyNumGuess.py
Created May 22, 2018 01:16
Python 猜數字遊戲
#!/usr/bin/python
# ?A?B猜數字遊戲
# 可選擇一到九位數來進行猜數字,數字可重複
from tkinter import Tk, Label, Entry, Spinbox, Button, messagebox, StringVar
from random import randint
answer = ""
playerGuess = ""
nOfDigits = 1
@pinglunliao
pinglunliao / SerialPlotterExample.ino
Created March 23, 2018 09:14
Arduino Serial Plotter Example
#include "Math.h"
void setup() {
Serial.begin(9600);
}
void loop() {
float angle = 0;
float sineData;
float cosineData;
-----------------------------------------------------------------------------------------
--
-- main.lua
--
-----------------------------------------------------------------------------------------
local score = 0
local background = display.newImageRect( "background.png", 360, 570 )
background.x = display.contentCenterX
background.y = display.contentCenterY
#!/usr/bin/python
# 步驟一:匯入 tkinter 模組。
from tkinter import Tk, Label, Entry, Radiobutton, IntVar
# 步驟二:建立主視窗。
mainWin = Tk()
var = IntVar()
operation = [ '+', '-', '*', '/']
# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
# 產生x座標的資料,從 -PI 到 PI
X = np.linspace(-np.pi, np.pi, 260, endpoint=True)
# Y座標
Cos_y, Sin_y = np.cos(X), np.sin(X)
Tan_y = np.tan(X)
// set pin numbers joystick axes
const int xAxis = A0; // joystick X axis
const int yAxis = A1; // joystick Y axis
int responseDelay = 50; // response delay of the mouse, in ms
const int centerValue = 512;
const int range = 200;
const int upperBond = centerValue + range;
const int lowerBond = centerValue - range;
import math;
def eratosthenes(n):
P = [i for i in range(2, (int)(math.sqrt(n)+1))]
p = 0
while True:
for i in P[p + 1:]:
if i % P[p] == 0:
P.remove(i)
if P[p]**2 >= P[-1]:
def prime_factoring(n):
divisor = 2
factors = []
while divisor * divisor <= n:
if n % divisor:
divisor += 1
else:
n //= divisor
factors.append(divisor)
def eratosthenes(n):
P = [i for i in range(2, n+1)]
p = 0
while True:
for i in P[p + 1:]:
if i % P[p] == 0:
P.remove(i)
if P[p]**2 >= P[-1]:
break
p += 1
import random
from collections import deque
unsortData = random.sample(range(100), 10)
def merge_sort(lst):
if len(lst) <= 1:
return lst
def merge(left, right):