Skip to content

Instantly share code, notes, and snippets.

@Nick0603
Nick0603 / Tinker_BMI
Last active July 17, 2017 13:02
pythonDemo tinker with BMI
from tkinter import *
def calBMI():
height = float(EntryHeight.get())
weight = float(EntryWeight.get())
BMI = weight / (height**2)
LabelBMI['text'] = BMI
if BMI < 18.5:
LabelResult['text'] = "體重過輕"
def fibonacci(n):
if n == 1:
return 1
elif n == 2:
return 2
else:
return fibonacci(n-2) + fibonacci(n-1)
ans = fibonacci(50)
print("十階總共有 %d 種可能的走法"%ans)
@Nick0603
Nick0603 / mineSweeperAI
Last active August 8, 2017 12:29
看到FB朋友po自製的 網頁版採地雷遊戲,真的太懷念了,玩玩幾次之後突發奇想寫寫AI
function getSize(){
var rows = 0;
while(true){
var nextRowGrid = document.getElementById("position-1-" + (rows+1));
if(nextRowGrid){
rows++
}else{
break;
}
}
var arr= [];
var filterArr= [];
var thresholdNum = 70;
arr.push([250,000,000,000,000,000,000,000]);
arr.push([000,250,000,000,000,000,000,000]);
arr.push([000,000,250,000,000,000,000,000]);
arr.push([000,000,000,250,000,000,000,000]);
arr.push([000,000,000,000,250,000,000,000]);
arr.push([000,000,000,000,000,250,000,000]);
@Nick0603
Nick0603 / update.js
Last active October 13, 2017 11:53
update
swal({
title: '更新資料',
html:
'名字:'+
'<input id="swal-input1" class="swal2-input" >' +
'年齡:'+
'<input id="swal-input2" class="swal2-input" >'
,
preConfirm: function () {
return new Promise(function (resolve) {
{
"name":"Nick",
"age":22
}
var nums = [2,7,4,6,3];
console.log("排序前:");
console.log(nums);
console.log("排序過程:");
for(var i=0;i<nums.length;i++){
for(var j=1;j<nums.length;j++){
if( nums[j-1] > nums[j]){
var temp = nums[j];
nums[j ] = nums[j-1];
@Nick0603
Nick0603 / search.js
Created October 13, 2017 12:56
收尋排序
var nums = [2,7,4,6,3];
var sort_nums = [];
console.log("排序前:");
console.log(nums);
console.log("排序過程:");
while( nums.length>0){
var min = Infinity;
var index = -1;
function hanoi(n,A,B,C){
if(n == 1){
console.log("從塔" + A + "移動至" + C)
}else{
hanoi(n-1,A,C,B);
hanoi(1,A,B,C);
hanoi(n-1,B,A,C);
}
}
@Nick0603
Nick0603 / face
Last active October 15, 2017 02:07
// 創造角色
var face = createSprite( ["bear.png","cat.png","cow.png"] );
// 重複執行
forever(function() {
// 如果 角色 碰觸到 滑鼠
if(face.touched(cursor)) {
// 角色 切換下一個 造型
face.nextCostume();
}