Back to the basics! You're in you comp sci class again, except wiser and golfier. You have the tools, you have the power… but do you have the skill? Probably.
Crash Course for the non-Computer Scientist (skip if you don't need it)
A string is symbolically represented by an arbitrary letter (usually, for our purposes, will be etc. Of course, we know a string as something like "Hello, World!"
or 'Hello, World!'
, or, if you're the snarky Python user, """Hello, World!"""
.
An alphabet can be thought of as a set (i.e. no repeating characters) of symbols, of which strings can be made. For example, ; this is the binary alphabet, of which contains strings like and . These strings can said to be strings over , or, alternatively, .
The length of any string is denoted . For example, .
There is the empty or null string , which is equivalent to ""
. It is a valid string in over any alphabet. In other words, is the unique string satisfying the property .
The set is the set of all strings over for which .
The set is called the Kleene closure of , and is the set of all strings over . This can be considered the language of .
The concatenation of two strings and is denoted , and is the string containing the characters of followed by the characters of .
is said to be a prefix of if there is some string that satisfies the equality . (If , then is said to be a proper prefix of .)
The alphabet of a string is denoted , and is the minimal alphabet so that is a string over
The projection of a string relative to an alphabet is defined as
and is essentially the removal of all characters in not in .
TL;DR
Objective Write a program, series of functions, series of programs etc. that can calculate as many of the following tasks as possible:
- (1) Calculate, given a string
s
, its length. - (2) Arrive at, given a string
s
and an alphabetΣ
, whether or not (output a truthy/falsy value) that string is over said alphabet. - (1) Given an alphabet, arrive at whether or not (output a truthy/falsy value) the alphabet is valid (a valid alphabet can have no repeating characters, but is otherwise valid).
- (4) Given an alphabet
Σ
and a positive integern
, display . - (6) Given an alphabet
Σ
and an integern
, display the firstn
entries in (Remember thatε ∈ Σ
!) - (1) Given a string
s
and a stringt
, outputst
. - (3) Given a string
s
, outputAl(s)
. - (5) Given a string
s
and an alphabetΣ
, outputπΣ(s)
.
Input is given by a string or your language's closest equivalent for a string input, an array, tuple, or n-ordinate of characters for an alphabet (your language's closest equivalent), and a number for a number (or your language's closest equivalent, heaven forbid your language does not support numbers!).
Each task has a score (the number in parenthesis). Your submission's score is calculated as follows:
sum points scored
score = —————————————————
length of bytes
Highest score wins.
Bonuses
- ×4 final score iff you output (with the correct symbols!) the input query. E.g., outputting
\pi_{\{0,1\}}(012345678910111213)=01101111
for an input ofΣ = [0,1]; s = 012345678910111213
. (You may choose to do this in either HTML or (La)TeX. Either counts.) - (I'm open to suggestions.)
points/length
for each problem, and then sum the scores for each problem completed. Most points wins. \$\endgroup\$s1
before, which was lower than scores2
, the new scores are now1 / s1
and1 / s2
, where the first score is higher. \$\endgroup\$