STEAM 그룹
Kickass Programmers quprogs
STEAM 그룹
Kickass Programmers quprogs
1
게임 중
10
온라인
설립
2015년 11월 6일
언어
영어
모든 토론 > General Discussion > 제목 정보
makka 2016년 3월 25일 오후 9시 02분
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
< >
전체 댓글 7개 중 1~7개 표시 중
makka 2016년 3월 25일 오후 9시 04분 
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.
makka 님이 마지막으로 수정; 2016년 3월 25일 오후 9시 26분
makka 2016년 3월 25일 오후 9시 05분 
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 2016년 3월 25일 오후 9시 07분 
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())}}
birb 님이 마지막으로 수정; 2016년 5월 22일 오전 2시 58분
makka 2016년 4월 1일 오후 4시 52분 
Rust can't even beat C++14 solution, get good punk :evilidk:
birb 2016년 5월 22일 오전 2시 53분 
get destroyed u cunt
mingmingrr 2016년 6월 4일 오후 2시 07분 
VBA, 58 chars
"Excel isn't real programming."
Sub l(s As String) MsgBox IIf(s="Google",s,Len(s)) End Sub
mingmingrr 님이 마지막으로 수정; 2016년 6월 4일 오후 2시 07분
makka 2017년 2월 2일 오후 6시 40분 
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");
makka 님이 마지막으로 수정; 2017년 2월 2일 오후 6시 52분
< >
전체 댓글 7개 중 1~7개 표시 중
페이지당 표시 개수: 1530 50

모든 토론 > General Discussion > 제목 정보