NHÓM STEAM
Kickass Programmers quprogs
NHÓM STEAM
Kickass Programmers quprogs
0
ĐANG CHƠI
7
TRÊN MẠNG
Thành lập
6 Tháng 11, 2015
Ngôn ngữ
Tiếng Anh
Tất cả thảo luận > General Discussion > Chi tiết chủ đề
makka 25 Thg03, 2016 @ 9:02pm
Code Golf -- Don't Google "Google"
Code Golf link here[codegolf.stackexchange.com]

Your task is to create a function that accepts 1 string and returns its length, in as few amount of Unicode characters as possible.

Discuss/post solutions in thread
< >
Đang hiển thị 1-7 trong 7 bình luận
makka 25 Thg03, 2016 @ 9:04pm 
TI 89 BASIC, 34 bytes
I did this in TI 89 for fun. I believe this is the most optimized solution one can get from TI 89 BASIC but there may be even more clever solutions.

f(x) getNum(x/"google")&""0+dim(x)

Basically abuses the fact that a string divided by itself becomes 1.
Lần sửa cuối bởi makka; 25 Thg03, 2016 @ 9:26pm
makka 25 Thg03, 2016 @ 9:05pm 
C++14, 42 chars

For giggles, here's my C++14 solution:

[](auto s){return s.size()/(s!="google");}

To call it, one would do [](auto s){ ... }(std::string("INS"));
birb 25 Thg03, 2016 @ 9:07pm 
Rust, 46 45 42 33 chars

|x|{assert!(x!="google");x.len()}

old:
|x:&str|{if x=="google"{panic!();}x.len()}
|x|{match x{"google"=>Err(x),_=>Ok(x.len())}}
|x|{match x{"google"=>Err(""),_=>Ok(x.len())}}
Lần sửa cuối bởi birb; 22 Thg05, 2016 @ 2:58am
makka 1 Thg04, 2016 @ 4:52pm 
Rust can't even beat C++14 solution, get good punk :evilidk:
birb 22 Thg05, 2016 @ 2:53am 
get destroyed u cunt
mingmingrr 4 Thg06, 2016 @ 2:07pm 
VBA, 58 chars
"Excel isn't real programming."
Sub l(s As String) MsgBox IIf(s="Google",s,Len(s)) End Sub
Lần sửa cuối bởi mingmingrr; 4 Thg06, 2016 @ 2:07pm
makka 2 Thg02, 2017 @ 6:40pm 
Nguyên văn bởi Spunky Sam:
I tried in python...
a=raw_input() print len(a)
First off, welcome to the community!
And secondly, your answer is not quite correct. You're supposed to crash if the user inputted "Google" otherwise print the length. Read the original link I posted for more information.

On that note, here's one for DLang
D, 26 chars
n=>n.length/(n!="Google");
Lần sửa cuối bởi makka; 2 Thg02, 2017 @ 6:52pm
< >
Đang hiển thị 1-7 trong 7 bình luận
Mỗi trang: 1530 50

Tất cả thảo luận > General Discussion > Chi tiết chủ đề