Skip to content

Instantly share code, notes, and snippets.

View banacorn's full-sized avatar
🥺

Ting-gian LUA banacorn

🥺
View GitHub Profile

Summary of Week 3 - Goldbach's Conjecture

  • 總共有 7 位參與者
  • 檢測質數的方法大同小異,但因為生成與檢驗的次序不同,造成執行速度極大的差異
  • lazy evaluation 是個雙面刃:
    • 讓我們在 Haskell 可以用直覺且高效的方式去實作許多在其他語言看似不可能的方法(例如先將所有的質數枚舉出來)
    • 但同時也讓程式的 cost centre 非常難去分析
  • 經過不科學 benchmark,小編挑出了跑得最快的前三名,在此各頒發 emoji 一枚 🎉🎉🎉
    1. Tai An Su 🥇
    2. 洪崇凱 🥈

Summary of Week 2 - Histogram

  • 11 位參與者提供了 13 種解法
  • 主要都可以分為兩個階段:先統計數量,再畫圖
  • 統計數量可以寫成某種的 unfold,而畫圖則是某種的 fold
  • 統計每個數字數量的幾種方法:
    • sortgroup
    • filter
    • 像畫正字一樣,用某種結構(List 或函數)去累加並儲存每種數字的數量
  • 作法依畫星星的方向,主要可以分成兩種:
@banacorn
banacorn / summary-week-1.md
Last active May 2, 2018 02:43
# Summary of Week 1 - Implementing nub

Summary of Week 1 - Implementing nub

  • 14 位參與者
  • 18 種解法(外加一種使用 Prolog XD)
  • 大部分時間複雜度為 O(n²),少數運用 IntOrdHashable 性質將複雜度壓到 O(nlog n) 甚至 O(n)
  • 大部分實作是 stable 的(在這裡定義為保持輸入資料從前面往後枚舉的順序)
    • 多數利用 foldr 搭配 reverse
    • 少部分利用 zip 維護資料順序

Solutions

@banacorn
banacorn / linux.md
Last active July 7, 2016 07:22
FLOLAC'16 / Linux 安裝指南

有哪些東西要安裝?

  1. Haskell
  • ghcghci ,GHC 提供的 Haskell 編譯器與交互式直譯器
  • 建議版本為 **GHC 7.8 (較舊版本例如 **7.6 也可以接受,而更新的版本 prelude 所提供的函數型別會與教學使用的有些落差)
  1. Agda
    • agda
    • 建議版本為 Agda 2.5(較舊版本例如 2.4 也可以接受)
    • 另外需要在 Emacs 或 Atom 上安裝 agda-mode
@banacorn
banacorn / macosx.md
Last active July 7, 2016 07:22
FLOLAC'16 / OS X 安裝指南

有哪些東西要安裝?

  1. Haskell
  • ghcghci ,GHC 提供的 Haskell 編譯器與交互式直譯器
  • 建議版本為 **GHC 7.8 (較舊版本例如 **7.6 也可以接受,而更新的版本 prelude 所提供的函數型別會與教學使用的有些落差)
  1. Agda
    • agda
    • 建議版本為 Agda 2.5(較舊版本例如 2.4 也可以接受)
    • 另外需要在 Emacs 或 Atom 上安裝 agda-mode
@banacorn
banacorn / windows.md
Last active November 3, 2021 04:55
FLOLAC'16 / Windows 安裝指南

有哪些東西要安裝?

Windows 64-bit 一鍵安裝包:http://www.cs.uiowa.edu/~astump/agda/備用連結(比較快)) 本安裝檔包含 GHC 7.8、Agda 2.4 以及 Emacs

  1. Haskell
  • ghcghci ,GHC 提供的 Haskell 編譯器與交互式直譯器
  • 建議版本為 **GHC 7.8 (較舊版本例如 **7.6 也可以接受,而更新的版本 prelude 所提供的函數型別會與教學使用的有些落差)
  1. Agda
@banacorn
banacorn / winusb.sh
Created July 2, 2016 05:15
A working script of winusb for Ubuntu 15.04
#!/bin/bash
# Config
# Le script quitte en cas d'erreur d'une commande
set -o errexit
# Le script quitte en cas de variables non déclarée
set -o nounset
# Script path
{-# LANGUAGE OverloadedStrings, DataKinds, DeriveGeneric, TypeFamilies #-}
module MQ where
import Database.Edis
import Data.ByteString
import Data.Serialize hiding (Get)
import GHC.Generics
data Message = Msg ByteString Integer deriving (Show, Generic)
{-# LANGUAGE OverloadedStrings, DataKinds, DeriveGeneric #-}
module MQ where
import Database.Edis
import Data.ByteString
import Data.Serialize
import GHC.Generics
data Message = Msg ByteString Integer deriving (Show, Generic)
@banacorn
banacorn / MQ.hs
Created June 19, 2016 17:17
message queue
{-# LANGUAGE OverloadedStrings, DataKinds, DeriveGeneric #-}
module MQ where
import Database.Edis
import Data.ByteString
import Data.Serialize
import GHC.Generics
data Message = Msg ByteString Integer deriving (Show, Generic)