Mystery

From Esolang
Jump to navigation Jump to search

Mystery is an Esolang designed by PSTF, inspired from Guess.

How will it work?

First, I write the program. Once I've written at least 5 programs, I'll open the guessing channels. At that point, you can guess the command table as much as you like. When a command is guessed incorrectly by three times in a row, I will show the correct usage of the command.

Why my edit got reverted?

  • Modify on other's command table
  • Delete programs
  • Insert craps
  • Credit(except credit to yourself)

If you do any of these things, your edit will be reverted.

1: Hello, world!

→『Hello, world!』

Input: None

Output:

Hello, world!

2: Collatz sequence

#x①;#y①;$x$←@;ò($x$≠1){→$x$;$x$м2=0?{$x$←$x$÷2;→『÷2=』,$x$;}:{$x$←$x$×3+1;→『×3+1=』,$x$;};$y$++;}→『\nSteps: 』,$y$;

Input:

12

Output:

12 6 3 10 5 16 8 4 2 1
Steps: 10

3: Quine

→$ѽҁᵷ$;

Input: None

Output:

→$ѽҁᵷ$;

4: Factorial function

ƒ(fac, [$x$①]){®($x$≤0)?1:($x$×ř(fac, [$x$ - 1]))};ř(fac, [@])

Input:

10

Output:

3628800

5: Count from 0 to infinity

#x←0;ò(@=$x$){$x$++;→『Correct, what about the next one?』};→『Wrong, you bastard! You lose!!』

Input:

0
1
2
3
4
1145141919810

Output:

Correct, what about the next one?
Correct, what about the next one?
Correct, what about the next one?
Correct, what about the next one?
Correct, what about the next one?
Wrong, you bastard! You lose!!

6: sgn(x)

#x①;$x$←@;($x$>0)?{→1}:($x$<0)?{→-1}:{→0};

7: Turing-completeness proof(requested by islptng)

ƒ(肏, [$str$字, $inp$字, $EOF$①]){
  #memoryリ;$memory$←[0]×30000;
  #ptr①;#index①;#zkh集;#m①;#pc①;
  #brackets栈;Ю(($i$①, $cmd$字), ř(ѣ, $str$)){
    ($cmd$=『[』)?{$brackets$.ř(↓, [$i$])}
    :($cmd$=『]』)?{$brackets$.空?
      {Ϣ(Ђ, f『Unmatched closing bracket at position {$i$}』)}:{};
      $m$←$brackets$.ř(↑);$zkh$[$m$]=$i$;$zkh$[$i$]=$im$;}
  };¬$brackets$.空?{Ϣ(Ђ, f『Unmatched opening bracket at position {$i$}』)}:{}
  ò($pc$ < $str$.長){
    #cmd←$str$[$pc$];
    전(cmd){
      경『>』{$ptr$++;$ptr$←$ptr$м30000;}
      경『<』{$ptr$--;$ptr$←$ptr$м30000;}
      경『+』{$memory$[$ptr$]++;} 《Unshackled value!》
      경『-』{$memory$[$ptr$]--;}
      경『,』{$inp$?{$memory$[$ptr$]←$inp$[$index$];}:{$memory$[$ptr$]←0;};$index$++;}
      경『.』{→($memory$[$ptr$]м1114112)} 《Unicode have 1,114,112 characters.》
      경『[』{$memory$[$ptr$]=0?{$pc$←$brackets$[$pc$]}:{}}
      경『]』{$memory$[$ptr$]≠0?{$pc$←$brackets$[$pc$]}:{}}
    }
  }; $pc$++;
}
ř(肏, [『,[.,]』, 『You are an idiot lol』, 0])

8: Object-oriented paradigm proof(A virtual kid)

Ц(人){
  #name字;
  #age①;
  #gender?;
  ƒ(⿻, []){
    →f『Hello, I'm {$name$}, I'm {$age$} years old, and I'm a {$gender$?『girl』:『boy』}.』
  }
}
#Ṁ人(『Raymond』, 14, ☒); $Ṁ$.⿻();

9: Truth-machine

#x←@;x≠0?{ò(☑){→x;};}:{→x;}

Guesses

Guess 1(by User:Helpeesl)

『X』X is a string literal with some string commands
\n Newline
#X① Defines var X as an integer
$X$ A reference to X
← Sets the left to the right
@ Input
; Command separator 
ò(C){P} Does P while C is true
X≠Y A comparison for if X is different from Y
→X Prints X
XмY X modulo Y
X=Y A comparison for if X is the same as Y
C?{A}:{B} Does A if C is true and B if not
X÷Y X divided by Y
X×Y X multiplied by Y
X+Y Y added to X
X,Y Y with X
X++ 1 is added to X
ƒ(A, [B]){C} Defines function A with arguments B and code C
ř(A, [B]) Calls function A and has the arguments B
® Allows recursivity
X≤Y A comparison for if X is atmost Y
.. Redo #1 ..
® Same as ? but for functions
X-Y Subtracts Y from X
X>Y A comparison for if X is greater than Y
X<Y A comparison for if X is less than Y
\0 Null character
\t Tab 
\\ \
X-- 1 is subtracted from X
.. Redo #2 ..
® Starts the function code

Degree of compliance:

『X』: Absolutely correct.
\n: Correct, but there are many escaping like this.
#X①: Correct. Also, 字 is string, ? is boolean...
All arithmetic calculations are correct.
X,Y: Somewhat correct.
All comparisions are correct.
ƒ(A, [B]){C}: Correct.
ř(A, [B]): Correct.
®: Wrong!
→X: Correct.
ò(C){P}: Correct.
@: Correct.
←: Correct.
$X$: Correct.
C?{A}:{B}: Correct.
;: Correct, and reserved.
X-Y: Missing.
-- 2nd --
X-Y: Correct.
All escaping are correct.
X--: Correct.
> and <: Correct.
®: Still wrong, but a bit of correct that this command is related to function.
-- 3rd --
®: Still wrong. Correct answer: Return a specified value.

Guess 2 (by User:I am islptng)

『』	: String literal. Can has escaped letters.
#xy	: Define a variable x typed y. Y could be ①(Number), 字(String), ?(boolean)
$x$	: Get a variable's value.
;	: Command sepearator.
y←x	: Assign x to y.
→x	: Print x.
{}	: Command block.
®x	: Return.
$ѽҁᵷ$	: The program itself.
x++	: Increment x.
a?b:c	: If-else
ò	: While
@	: Input
≠/</>/=/≤/≥	: Compare operator
÷/×/-/+	: Arithmetic operator
ƒ(name,arg){}	: Define a function.
ř(name,arg)	: Function call

Degree of compliance:

Good job! All of your guessings are right!

Round 2

Just check this translation:

ƒ(肏, [$str$字, $inp$字, $EOF$①]){
function 肏(string str, string inp, num EOF) {
  #memoryリ;$memory$←[0]×30000;
  list memory = [0] * 3000;
  #ptr①;#index①;#zkh集;
  num ptr; num index; dict zkh;
  #brackets栈;Ю(($i$①, $cmd$字), ř(ѣ, $str$)){
  stack brackets; for i,cmd in evaluate(str) {
    ($cmd$=『[』)?{$brackets$.ř(↓, [$i$])}
    if(cmd == "[") { brackets.push(i); }
    :($cmd$=『]』)?{$brackets$.空?
    else if(cmd == "]") { if(brackets.empty)
      {Ϣ(Ђ, f『Unmatched closing bracket at position {$i$}』)}:{};
      { raise f"Unmatched closing bracket at position {i}"; }
      $m$←$brackets$.ř(↑);$zkh$[$m$]=$i$;$zkh$[$i$]=$im$;}  m is undefined! 
      { m = brackets.pop(); zkh[m] = i; zkh[i] = m; }
  };¬$brackets$.空?{Ϣ(Ђ, f『Unmatched opening bracket at position {$i$}』)}:{}
  } if(not bracket.empty) { raise f"Unmatched opening bracket at position {i}"; }
  ò(#pc① < $str$.長){
  while(num pc < str.length) {
    #cmd←$str$[$pc$];
    cmd = str[pc];
    전(cmd){
    switch(cmd) {
      경『>』{$ptr$++;$ptr$←$ptr$м30000;}
      case ">" { ptr++; ptr %= 30000; }
      경『<』{$ptr$--;$ptr$←$ptr$м30000;}
      case "<" { ptr--; ptr %= 30000; }
      경『+』{$memory$[$ptr$]++;} 《Unshackled value!》
      case "+" { memory[ptr]++; } /* Unshackled value! */
      경『-』{$memory$[$ptr$]--;}
      case "-" { memory[ptr]--; }
      경『,』{$inp$?{$memory$[$ptr$]←$inp$[$index$];}:{$memory$[$ptr$]←0;};} Where is "$index$++"?
      case "," { if(inp) {memory[ptr] = inp[index]; } else { memory[ptr] = 0; } }
      경『.』{→($memory$[$ptr$]м1114112)} 《Unicode have 1,114,112 characters.》
      case "." { print(memory[ptr] % 1114112); } /* Unicode have 1,114,112 characters. */
      경『[』{$memory$[$ptr$]=0?{$pc$←$brackets$[$pc$]}:{}}
      case "[" { if(memory[ptr] == 0) { pc = brackets[pc]; } }
      경『]』{$memory$[$ptr$]≠0?{$pc$←$brackets$[$pc$]}:{}}
      case "]" { if(memory[ptr] != 0) { pc = brackets[pc]; } }
}}}

I suppose you did the last line wrong????

Degree of compliance:

"ISLPTNG" compiler, you deserve to have (
Also, I've fixed the errors.

Categories and References