輸入一個包含大小寫的句子,例如 HelloEveryOne
會將所有大寫擺於前:HEOelloveryne
再刪重複的字母(區分大小寫):HEOeloveryn
要不是python很好上手,我都快要把python忘光了
Python 已經算很好上手了...(看向 C++ , Java....
說到這個,有人想玩我寫的聊天室機器人嗎?剛剛用Edge測試註冊功能,結果死當十秒後被強迫刷新😆
什麼手機阿
Sony的邊充邊玩也沒聽過過熱重開的(x
ap = set()
s = ''
for i in range(2):
for c in s_in:
if c in ap:
continue
cmp = c.upper() if i == 0 else c.lower()
if cmp == c:
s += c
ap.add(s)
print(s)
pwdgen :: [Char] -> [Char]
pwdgen x = nub ((filter isUpper x) ++ (filter (not . isUpper) x ))
不過應該是沒辦法
[pan93412@Arch-PC Python]$ python3 pwdgen.py -h
密碼產生器 OwO
版本:v1.0.0
作者:pan93412
用法:python3 (Windows: python) pwdgen.py [原文] ([-h]|[--help])
[原文]: 包含大小寫的句子,例如:HelloEveryOne
<非必須>
[-h] [--help]: 顯示說明訊息
若不指定原文,開啟程式則會互動式詢問原文。
將會把輸出結果輸出於 STDOUT 標準輸出。
雖然我的東西一般都是 Unlicense 的 Public Domain
[...new Set("HelloEveryOne".split(""))].sort()
耶
[pan93412@Arch-PC pwd_gen]$ bash UnitTest.sh Python_2/pwdgen.py
程式測試通過! :)
Array(10) [ "E", "H", "O", "e", "l", "n", "o", "r", "v", "y" ]
# 用法 `bash UnitTest.sh [程式檔名]`
# 將會呼叫 `[程式檔名] (測試內容)`,所以請確保程式會收第二參數。
if same_case(a, b) return false;
return a > b;
return true when it need to be swap
輸入一個包含大小寫的句子,例如 HelloEveryOne
會將所有大寫擺於前:HEOelloveryne
再刪重複的字母(區分大小寫):HEOelovryn
[...new Set("HelloEveryOne".split(""))].sort(x=>x.charCodeAt()>90).sort(x=>x.charCodeAt()>90).toString().replace(/,/g,'')笑死我不知道為什麼要 sort 兩次
> [...new Set("ChiNeSEAcOQckmAKOfAK".split(""))].sort(x=>x.charCodeAt()>90).sort(x=>x.charCodeAt()>90).toString().replace(/,/g,'') === "CNSEAOQKhieckmf"
true
要IO的話 後面加個
main = interact pwdgen
[2019-02-03 16:38:05] INFO: Server Rate Time
[2019-02-03 16:38:05] INFO: http://ftp.tku.edu.tw/Linux/ArchLinux/ 96.57 KiB/s 1.40 s
[2019-02-03 16:38:05] INFO: http://shadow.ind.ntou.edu.tw/archlinux/ 86.98 KiB/s 1.55 s
[2019-02-03 16:38:05] INFO: http://archlinux.cs.nctu.edu.tw/ 78.01 KiB/s 1.73 s
[2019-02-03 16:38:05] INFO: https://shadow.ind.ntou.edu.tw/archlinux/ 54.91 KiB/s 2.46 s
[2019-02-03 16:38:05] INFO: rsync://ftp.tku.edu.tw/archlinux/ 32.80 KiB/s 4.12 s
[2019-02-03 16:38:05] INFO: rsync://archlinux.cs.nctu.edu.tw/archlinux/ 28.46 KiB/s 4.74 s
[2019-02-03 16:38:05] INFO: http://ftp.yzu.edu.tw/Linux/archlinux/ 37.74 KiB/s 3.58 s
[2019-02-03 16:38:05] INFO: rsync://ftp.yzu.edu.tw/Linux/archlinux/ 27.42 KiB/s 4.92 s
以前都能到的 2.xMB/s 現在連 300KB/s 都不到
我覺得 你搞錯sort func的return value了🤔
🤔
[...new Set("ChiNeSEAcOQckmAKOfAK".split(""))].sort((x,y)=>x.charCodeAt()>90&&y.charCodeAt()<90).toString().replace(/,/g,'')
[...new Set("ChiNeSEAcOQckmAKOfAK".split(""))].sort((x,y)=>x.charCodeAt()>90&&y.charCodeAt()<90).join('')
js 的 sort 裡面吃的應該是 a -> a -> Num ㄅ
所以說sort要的是1/0/-1不是true/false啊
你是不知道比大小有大/等/小嗎 😕
所以理由很簡單 因為你的比較只有大/等 沒有小 自然排序有問題(
你先加 argc 和 argv,並從 argv[1] 讀取文字內容
echo "MingTsay\nFooBar" | .
/a.out
因為有 !== 的部分 compare 是 == 的狀態,會造成 non-stable 的結果
Set的hash全撞的情況下,O(n^2),所以worst
奇怪為啥 node js 好像沒有什麼正常的 time profiling 工具
100 1k 10k 100k 1m 10m 100m測資
cat /dev/urandom | tr -dc ]' | head -c 100000000
cat /dev/urandom | tr -dc '[a-z][A-Z]' | head -c 100000000
用異步迴圈會有差ㄇ 還是會卡在 set 效率所以沒差
Sun Feb 03 17:59 2019 Time and Allocation Profiling Report (Final)
20190203.exe +RTS -p -RTS
total time = 0.05 secs (54 ticks @ 1000 us, 1 processor)
total alloc = 24,853,744 bytes (excludes profiling overheads)
COST CENTRE MODULE SRC %time %alloc
pwdgen Main 20190203.hs:5:1-62 90.7 41.9
CAF Main <entire-module> 9.3 57.9
我找不到 clang 的 profiling :(
[pan93412@Arch-PC pwd_gen]$ bash UnitTest.sh C++_im2/pwd_gen.out --stdin
共 5 項單元測試。程序開始!
正在進行編號為 5 的單元測試……
正在進行編號為 4 的單元測試……
正在進行編號為 3 的單元測試……
正在進行編號為 2 的單元測試……
正在進行編號為 1 的單元測試……
程式測試通過! :)
還是不懂要什麼 😕
我寫過的是都有留下來啦,但幾百個檔案是我也懶得整理
用 5+ 次 for 的 Code
大概 40 個
你自己處理一下吧 🤔
可不可以給 1+(含) 次的
感覺到 5+ 次的用途都有點單一(?
好哦
總共 430 個檔案中,有 260 個含有 for
我現在打包給你 🤔
我懷疑 你真的有時間每個打開嗎
那很多 Code 是我都認不得欸 😰
剛剛看到 sort(A, A+n); 沒有意會到是什麼概念
#include <iostream>
#include <string>
using namespace std;
int main() {
string str;
while (cin >> str) {
string upper_str, lower_str;
unsigned long has_char[4] = {};
for (char ch : str) {
if (has_char[ch % 4] & 1 << (ch / 4)) continue;
has_char[ch % 4] |= 1 << (ch / 4);
if ('a' <= ch && ch <= 'z') {
lower_str += ch;
} else {
upper_str += ch;
}
}
cout << upper_str << lower_str << endl;
}
return 0;
}
喔幹該不會是 bit operation 加上 assignment ㄅ
我的研究目標就是把 for 轉成 map/filter/fold