C# ,147个 136 129字节
数据
- 输入
Char
c
版本名称的首字母
- 输出
String
版本的全名
打高尔夫球
// Requires the input to be uppercase.
// This is the one counting for the challange
c=>c+"upcake,onut,clair,royo,ingerbread,oneycomb,ce Cream Sandwich,ellybean,itkat,ollipop,arshmallow,ougat,reo".Split(',')[c-67];
// Optional. Requires the input to be lowercase.
c=>c+"upcake,onut,clair,royo,ingerbread,oneycomb,ce Cream Sandwich,ellybean,itkat,ollipop,arshmallow,ougat,reo".Split(',')[c-99];
// Optional. Works with both uppercase and lowercase with the additional cost of 10 bytes.
c=>c+"upcake,onut,clair,royo,ingerbread,oneycomb,ce Cream Sandwich,ellybean,itkat,ollipop,arshmallow,ougat,reo".Split(',')[c-(c<99?67:99)];
不打高尔夫球
c =>
c + "upcake,onut,clair,royo,ingerbread,oneycomb,ce Cream Sandwich,ellybean,itkat,ollipop,arshmallow,ougat,reo"
.Split( ',' )[ c - 67 ];
非高尔夫可读
// Takes a char
c =>
// Appends the input letter to...
c +
// ... the name in the resulting index of the subtraction of the char with 67 ('C'), or with 99 ('c') for the lowercase version
"upcake,onut,clair,royo,ingerbread,oneycomb,ce Cream Sandwich,ellybean,itkat,ollipop,arshmallow,ougat,reo"
.Split( ',' )[ c - 67 ];
// Takes a char
c =>
// Appends the input letter to...
c +
// ... the name in the resulting index of the subtraction of the char with 67 ('C') if the char is uppercase ( 'C' == 67, 'O' == 79 )
// or with 99 ('c') if the char is lowercase ( 'c' == 99, 'o' == 111 )
"upcake,onut,clair,royo,ingerbread,oneycomb,ce Cream Sandwich,ellybean,itkat,ollipop,arshmallow,ougat,reo"
.Split( ',' )[ c - ( c < 99 ? 67 : 99 ) ];
完整代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TestBench {
public static class Program {
private static Func<Char, String> f = c =>
c + "upcake,onut,clair,royo,ingerbread,oneycomb,ce Cream Sandwich,ellybean,itkat,ollipop,arshmallow,ougat,reo"
.Split( ',' )[ c - 67 ];
static void Main( string[] args ) {
List<Char>
testCases = new List<Char>() {
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
};
foreach(Char testCase in testCases) {
Console.WriteLine($" Input: {testCase}\nOutput: {f(testCase)}\n");
}
Console.ReadLine();
}
}
}
发布
- 1.0 -
147 bytes
-初始溶液。
- V1.1 -
-11 bytes
- 借用 奥利弗格雷的想法。
- V1.2 -
- 7 bytes
-改变了功能,输入从显性到隐性。
笔记