现在是另一个中美洲日历的时候了!阿兹特克人(更恰当地说,是墨西哥人)用虎耳子来命名他们的年龄。每年都有一个数字和一个符号。下面是循环的一部分:
Input; Output
1089; 13 Calli
1090; 1 Tochtli
1091; 2 Acatl
1092; 3 Tecpatl
1093; 4 Calli
1094; 5 Tochtli
1095; 6 Acatl
1096; 7 Tecpatl
1097; 8 Calli
1098; 9 Tochtli
1099; 10 Acatl
1100; 11 Tecpatl
1101; 12 Calli
1102; 13 Tochtli
1103; 1 Acatl
1104; 2 Tecpatl
1105; 3 Calli
1106; 4 Tochtli
1107; 5 Acatl
1108; 6 Tecpatl
1109; 7 Calli
1110; 8 Tochtli
1111; 9 Acatl
1112; 10 Tecpatl
1113; 11 Calli
1114; 12 Tochtli
1115; 13 Acatl
1116; 1 Tecpatl
1117; 2 Calli
1118; 3 Tochtli
1119; 4 Acatl
1120; 5 Tecpatl
1121; 6 Calli
1122; 7 Tochtli
1123; 8 Acatl
1124; 9 Tecpatl
1125; 10 Calli
1126; 11 Tochtli
1127; 12 Acatl
1128; 13 Tecpatl
1129; 1 Calli
1130; 2 Tochtli
1131; 3 Acatl
1132; 4 Tecpatl
1133; 5 Calli
1134; 6 Tochtli
1135; 7 Acatl
1136; 8 Tecpatl
1137; 9 Calli
1138; 10 Tochtli
1139; 11 Acatl
1140; 12 Tecpatl
1141; 13 Calli
1142; 1 Tochtli模式应该足够清楚:数字正在数到13,标志是Tochtli,Acatl,Tecpatl,Calli。52年后,这种模式又重演了。
该程序将以1064 (墨西哥人离开神话中的家乡Aztlan)和1521年(特诺奇蒂特兰陷落给西班牙人)之间的整数作为输入,包括在内,并输出相应的年份名称。它可以是单个字符串(在这种情况下,数字和符号之间需要一个空格),也可以是您首选格式的元组(例如["2", "Calli"])。符号名总是大写的。
没有必要处理指定范围以外的年份。这是密码-高尔夫,所以最短的代码就赢了!
上面的整个示例列表加上:
Input; Output
1064; 1 Tecpatl
1521; 3 Calli发布于 2020-06-08 11:56:49
Ì13%>.•19ŠSBÿ®Ï¿¾Ñλ1Ï7qι•#™Iè‚Ì # Increase the (implicit) input by 2
13% # Take modulo-13 on that
> # And increase it by 1
.•19ŠSBÿ®Ï¿¾Ñλ1Ï7qι•
# Push compressed string "tecpatl calli tochtli acatl"
# # Split it on spaces: ["tecpatl","calli","tochtli","acatl"]
™ # Titlecase each: ["Tecpatl","Calli","Tochtli","Acatl"]
Iè # Index the input into it (0-based and with automatic wraparound)
‚ # Pair the two together
# (after which the result is output implicitly)看这个05AB1E我的尖端(部分)如何压缩字符串而不是字典的一部分?)来理解为什么.•19ŠSBÿ®Ï¿¾Ñλ1Ï7qι•是"tecpatl calli tochtli acatl"。
发布于 2020-06-08 12:50:59
[S S S N
_Push_0][S N
S _Duplicate_0][T N
T T _Read_STDIN_as_integer][T T T _Retrieve][S N
S _Duplicate_input][S S S T S N
_Push_2][T S S S _Add][S S S T T S T N
_Push_13][T S T T _Modulo][S S S T N
_Push_1][T S S S _Add][T N
S T _Print_as_integer][S S S T S S T N
_Push_9_tab][T N
S S _Print_as_character][S S S T S S N
_Push_4][T S T T _Modulo][S N
S _Duplicate][N
T S S N
_If_0_Jump_to_Label_0][S S S T N
_Push_1][T S S T _Subtract][S N
S _Duplicate][N
T S T N
_If_0_Jump_to_Label_1][S S S T N
_Push_1][T S S T _Subtract][N
T s S S N
_If_0_Jump_to_Label_2][S S S T T N
_Push_3_l][S S S T S T T N
_Push_11_t][S S T T S S S N
_Push_-8_a][S S T T T S N
_Push_-6_c][S S T T S T S S S N
_Push_-40_A][N
S S N
_Create_Label_PRINT_LOOP][S S S T T S T S S T N
_Push_105][T S S S _Add][T N
S S _Print_as_character][N
S N
N
_Jump_to_Label_PRINT_LOOP][N
S S S N
_Create_Label_0][S N
N
_Discard][S S S T T N
_Push_3_l][S S S T S T T N
_Push_11_t][S S T T S S S N
_Push_-8_a][S S S T T T N
_Push_7_p][S S T T T S N
_Push_-6_c][S S T T S S N
_Push_-4_e][S S T T S T S T N
_Push_-21_T][N
S N
N
_Jump_to_Label_PRINT_LOOP][N
S S T N
_Create_Label_1][S N
N
_Discard][S S S N
_Push_0_i][S S S T T N
_Push_3_l][S N
S _Duplicate_3_l][S S T T S S S N
_Push_-8_a][S S T T S S T T S N
_Push_-38_C][N
S N
N
_Jump_to_Label_PRINT_LOOP][N
S S S S N
_Create_Label_2][S S S N
_Push_0_i][S S S T T N
_Push_3_l][S S S T S T T N
_Push_11_t][S S T T N
_Push_-1_h][S S T T T S N
_Push_-6_c][S S S T T S N
_Push_6_o][S S T T S T S T N
_Push_-21_T][N
S N
N
_Jump_to_Label_PRINT_LOOP]字母S (空格)、T (制表符)和N (新行)仅作为突出显示添加。
[..._some_action]仅作为解释添加。
在网上试试 (只包含原始空格、制表符和新行)。
Integer year = STDIN as integer
Print (year+2) modulo-13 + 1 as integer to STDOUT
Print '\t' as character to STDOUT
Integer temp = year modulo-4
If(temp == 0):
Push the codepoints of "ltapceT" minus 105 to the stack
If(temp-1 == 0):
Push the codepoints of "illaC" minus 105 to the stack
If(temp-2 == 0):
Push the codepoints of "ilthcoT" minus 105 to the stack
Else:
Push the codepoints of "ltacA" minus 105 to the stack
Start PRINT_LOOP:
Add 105 to the top integer on the stack
Print this integer as character with this codepoint to STDOUT
Go to the next iteration of PRINT_LOOP使用这是我在太空中的一角打印输出,一旦打印完成并且堆栈为空,输出就会出现错误退出程序。最优常数105由这个Java程序生成。
发布于 2020-06-08 14:10:53
-r开关),57个字符"\((.+2)%13+1) "+("Tecpatl Calli Tochtli Acatl"/" ")[.%4]样本运行:
bash-5.0$ jq -r '"\((.+2)%13+1) "+("Tecpatl Calli Tochtli Acatl"/" ")[.%4]' <<< 1111
9 Acatlhttps://codegolf.stackexchange.com/questions/205773
复制相似问题