작업
1을 반환하는 함수 / 서브 루틴을 만듭니다. 1을 반환하는 한 원하는대로 정교하게 만들 수 있습니다.
규칙
가장 인기가 높은 출품작은 모든 인기 대회와 마찬가지로 승리합니다. 행운을 빕니다!
:)
작업
1을 반환하는 함수 / 서브 루틴을 만듭니다. 1을 반환하는 한 원하는대로 정교하게 만들 수 있습니다.
규칙
가장 인기가 높은 출품작은 모든 인기 대회와 마찬가지로 승리합니다. 행운을 빕니다!
:)
답변:
골프 스크립트
1
이 코드를 가장 순수하게 최적화하는 데 오랜 시간이 걸렸으며 감히 아름답습니다. 이러한 언어의 우아함은 수년간의 헌신적 인 연습 없이는 이루어지지 않습니다. Zero-Instruction-Set-Computer가 없으면 더 이상 압축 할 수없는 프로그램입니다. 내 코드 골프 경력 전체가이 순간에 이르렀습니다.
나는 자유 다. 나는 살아있다.
우주의 기초가되는 코드가 보입니다.
without a Zero-Instruction-Set-Computer can literally never be compressed any further. 우리의 현재 컴퓨터는 0 개의 명령어 프로그램을 쉽게 처리 할 수 있습니다. 사양에 "빈 프로그램은 1을 반환합니다."
"strong return"( return!) 및 "approaches"연산자 ( -->) 와 같이 모호한 언어 기능을 사용하는 두 가지 예 :
int foo(void) {
return! 0;
}
int bar(void) {
int i=7;
while (i --> 0);
return-i;
}
return-i키워드 : P
+++++++
+++++++
+++
+++
+++
+++
+++
++++++++++
++++++++++.
또는 파티에서 재미 있지 않은 경우 :
+++++++[->+++++++<]>.
l보다 소문자처럼 보입니다 1.
one ← {⍴⍴⍴⍵}
⍴벡터의 크기를 알려줍니다. 의 차원 그래서 그 치수는 항상 하나의 차원이다 즉 항상 하나입니다. 또는:
"X의 Rho, rho, rho는
항상 1과 같습니다.
Rho는 치수입니다. rho rho, rank
APL은 재미 있습니다!"
(나는 그 구절을 쓰지 않았다, 그것은 Stallman의 것이다.)
# @: # @: #(공백은 선택 사항)
public static int funWithOne() {
try {
try {
return funWithOne();
} finally {
return funWithOne();
}
} catch (Throwable _) {
return 1;
}
}
마지막으로을 반환하기 전에 2,1024 번 (이 숫자는 플랫폼에 따라 다름)을 호출합니다 1. 그러나 숨을 참지 마십시오. 우주의 나이보다 훨씬 오래 걸릴 것 입니다.
물고기
x는 프로그램 카운터를 임의의 방향으로 보냅니다. #은 프로그램 카운터가 "튀는"벽입니다. "^"를 찾을 때까지 말 그대로 목적없이 돌아 다니다가 1을 인쇄하고 마칩니다.
xxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxx###xxxxxxxxxxxxxx
xxxxxxxxxx#;#xxxxxxxxxxxxxx
xxxxxxxxxx#n#xxxxxxxxxxxxxx
xxxxxxxxxx#1#xxxxxxxxxxxxxx
xxxxxxxxxx#^#xxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxx
x로 ?, 모든를 #로 r, n로 .와 ;로 @. 그러나이> <> 프로그램은 동등한 Befunge보다 낫습니다. 여기에 표시되는 번역 : ideone.com/ZyuSKk
?에 x모든을 #에 !(도 같은 떠날 때 잘 작동합니다)와 (물론) .에 n과 @에 ;. ideone.com/gfApjT
expr 0
이것은 0을 출력 하지만 1을 반환 하는데, 이는 다른 언어에 익숙한 프로그래머에게는 놀라운 일이 될 수 있습니다. 를 실행하여 인쇄 된 출력을 끄고 리턴 코드를 볼 수 있습니다 expr 0 >/dev/null; echo $?.
$(pidof progname) < 1
이것은 내가 가장 좋아하는 Java 관련 질문 중 하나입니다.
public static int ret1() {
try {
return 0;
} finally {
return 1;
}
}
try블록으로 돌아 가려고 finally하면 다른 return명령문이 실행 되기 전에 즉시 1을 리턴 합니다.
function getOne() {
return -~![];
}
설명:
![]평가됩니다 false.~false해진다 -1때문에 false처음에 주조된다 0하고 ~0 == -1.--1평가됩니다 1.번갈아 하는:
return +!([][~~{}])
미친 대안 (각 줄의 길이는 정확히 80 자입니다) :
this[693741..toString(36)]('acnuftiao nobcbdaterbaurn +abeba!!be'.replace(/b./g,
function(b){return '{}()'.split('')['aecd'.split('').indexOf(b.charAt(1))]})[''+
'replace'](new RegExp('a'+Array(5).join('(.)'),'g'),(a='$')+'4321'.split([]+[]).
join(a)))
// we all know that OOP == good
function OneManager() {
// constants == good too
this.values = {
ERROR: -1, // value on error
ONE: 1 // desired value
}
this.value = this.values.ERROR // set the value to ERROR
this.setValue = function(num) {
if (typeof num !== "number") throw new Error('cannot set value to non-number')
if (!this.value) this.value = this.values.ERROR // oh noes
else this.value = num
}
}
// initialize the one
OneManager.prototype.initializeOne = function() {
this.setValue(this.values.ONE) // set the value to ONE
return true // return true for success
}
// get the value
OneManager.prototype.getValue = function() {
if (this.value == this.values.ERROR) { // if the value is ERROR
throw new Error('value not initialized')
} else return this.value // return the value
}
function getOne() {
var m = new OneManager() // make a OneManager
var success = m.initializeOne() // initialize the value
if (success) return m.getValue() // return the value
else {
// there was an error in the initialization
var retVal = m.values.ERROR // we will return an error
delete m // maybe it's corrupted
return retVal // return an error
}
}
alert(getOne())
OO == good또는 OO === good?
data One = One deriving (Eq, Ord, Bounded, Enum, Show, Read)
이것은 정의하는 하나의 사실 One. 이것은 OnenessOne 를 나타내는 유형 과 생성자입니다. 생성자 자체는 하나의 true 를 리턴하는 널 (null) 함수 이며 type의 하나의 값 ( behold,) 만 리턴합니다 .OneOneOne
ghciREPL 에서의 사용법 :
λ: One -- One returns the one true One
One
λ: One == One -- One is equal to itself, as no others are
True
λ: One < One -- One is no less than itself
False
λ: minBound :: One -- One is the least One there is, yet it is all you need
One
λ: maxBound :: One -- One is as big as the universe of One, it is omnipotent
One
λ: [ One .. One ] -- One is the beginning, and ending, of all that is One
[One]
λ: show One -- The textual gospel of One
"One"
λ: read "One" :: One -- To read the word of One, is to become one with One
One
하나 의 전체 책 은 이제 온라인입니다. 그것을로드하면 계산과 산술 두 가지 증거를 얻을 수 있습니다. 이를 통해 더 많은 진실을 탐구 할 수 있습니다.
λ: One + One -- One can only add to its magnificence
One
λ: negate One
*** Exception: One cannot be negated, mortal fool!
λ: One `div` One -- One is indivisible
One
λ: One `mod` One
*** Exception: Nothing can modulate the power of One
λ: toRational One -- Ye shall know One as both Numerator and Denominator
1 % 1
λ: toInteger One * 42 -- One multiplies all to wholeness
42
λ: toRational One / 2 -- Even divided, One is on top
1 % 2
float one(void)
{
const int n = 24; // magic number
float x = 0.5f;
float y = x;
int i;
for (i = 0; i < n; ++i)
{
x *= 0.5f;
y += x;
}
return y;
}
정수 1이어야한다고 말하지 않았습니다.
float one_F(){
return FloatFactoryFactory.getInstance(FloatFactoryFactory.
defaultInstanceDescriptionString).getFactory(Locale.getLocale
("en-US")).createBuilder().setString("1.0").getResult();
}
function one() { return Number.length; }
스펙 포르노를위한 시간.
섹션 15.7.3length 은 Number생성자 의 속성 이 1(그리고 우리는 생성자가 4.3.4 에서 언급 된 함수 객체라는 것을 알고 있습니다 ), 그리고 섹션 15.3.5.1 은 다음 과 같이 말하고 있습니다 :
length 속성 값은 함수가 예상하는 "일반적인"인수 수를 나타내는 정수입니다. 그러나 언어는 다른 수의 인수로 함수를 호출 할 수 있습니다.
… Number생성자의 일반적인 인수 수는 1이므로 lengthof of Number는 1입니다. 그래서 자바 스크립트에서 숫자의 길이는 1이라고 말할 수 있습니다.
sub one{ $a[@a{@a[%a=map{@$a[@a{$a++=>$a}]+++$#$a+$a=>$a}$a]++}+$a] }
넓게 열고 말합니다 aaaaa.
여전히 원하는 결과를 반환하고, 단지 "하나"변수를 사용하여 (동안 창조적 인 개념으로 깊이 가능한 ... 괄호 안에 괄호 안의 둥지 괄호로했다 $a, @a, %a, @$a그리고 $#$a물론 모든 다른 변수입니다).
이렇게하면 환경이 크게 수정되지만 1후속 호출에서는 항상 반환 됩니다. 수행중인 작업을 파악하려면이 코드를 실행하는 것이 좋습니다.
use Data::Dump qw(dump);
for (1..8) {
one();
dump(@a);
dump(%a);
dump(@$a);
}
public class print {
public static char getNum() throws Exception{
String method = print.class.getSimpleName()+Splitter.class.getDeclaredMethods().length;
return (char)Splitter.class.getMethod(method).invoke(null);
}
}
class Splitter{
public static char print1(){
return P.getNum();
}
}
class P{
public static char getNum(){
String s = Thread.currentThread().getStackTrace()[P.class.getDeclaredMethods().length].getMethodName();
return s.charAt(s.length()-P.class.getSimpleName().length());
}
public void doNothing(){}
}
1에서 n까지 n의 방법 printX을 XSplitter 에 추가하여 다른 양수를 반환하도록 조정할 수 있습니다 . 예를 들어, 수정 Splitter을
class Splitter{
public static char print1(){
return P.getNum();
}
public static char print2(){
return P.getNum();
}
}
다른 변경없이 '2'를 반환합니다. 추가 된 메소드는 이름을 제외하고와 정확히 중복되어야합니다 print1. 리플렉션을 사용하여 스플리터의 메소드 수를 가져오고 해당 이름의 함수를 호출하십시오.P.getNum그런 다음 호출하면 스택 추적을 읽고 호출 메소드의 마지막 문자를 구문 분석하여 표시합니다.
호출 print.getNum()하면 문자 '1'이 반환됩니다.
편집-String / integer / etc 리터럴을 사용하지 않도록 수정되었습니다.
기음#
하드웨어 아키텍처에 따라 달라집니다.
return IntPtr.Size / (Environment.Is64BitOperatingSystem ? 8 : 4);
와우!
이 (논쟁의) 하나를 이웃 (논쟁의) Collatz 추측 과 병합 :
public int CollatzOne()
{
var current = new BigInteger(new Random().Next(1, Int32.MaxValue));
var history = new[] { new BigInteger(-1), new BigInteger(-1), new BigInteger(-1) };
do
{
history[0] = history[1];
history[1] = history[2];
history[2] = current;
if (current.IsEven)
current /= 2;
else
current = current * 3 + 1;
} while (current != history[0]);
return (int)history.Min();
}
이것만으로도 충분합니까?
(+!~~{})
매개 변수에 대한 설명서도 포함되어 있습니다.
int
return_1
(x) int
x;{
/*x
can
be:
any
val
ue.
***/ return
!x?1:x /x;}