Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Sandbox

Comments on Code bowling using unique characters

Post

Code bowling using unique characters

+1
−0

The aim of the challenge is to write as long a source code as possible (code bowling), every character typed gives 1 point, using the following rules:

  • No symbol typed in the source may be re-used twice. That is, only one a, only one 1, only one + and so on.
  • Whitespace characters do not count and may be used multiple times (space, line feed, cr, tab etc).
  • Other non-printable characters may be present but do not count.
  • A standard American keyboard layout/locale is assumed, see wikipedia.
  • No symbols may be present inside string literals. Empty string literals are accepted (if you can manage to type one without using " twice).
  • No comments may be present.
  • The program must compile for the given language and run without crashing.
  • No special behavior or input/output is required.

Looking for feedback:

  • Is this challenge at all feasible? Too restrictive in too many languages?
  • Should special exceptions be made for very common symbols like () and ;? As in allowing them but they do not count towards the total score?
  • Should function-only solutions be allowed? Or maybe it should only ask for function-only solutions?

EDIT:

I suppose the only allowed characters should be the old school 7 bit ASCII, not counting whitespace characters):

 !"#$%&'()*+,-./0123456789:;=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
`abcdefghijklmnopqrstuvwxyz{|}~

Meaning that the highest possible score is 93.


Example solution (purposely naive) in the C language:

main()
{
  double cfghjkpqrstvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ = !-1234/5+6*78|90;
}

Score: 74.


Simple test tool, paste source below "Code" in TIO then check output.

(Hopefully bug-free, proof-reading is welcomed!)

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

3 comment threads

Possible variation to allow character exeptions (1 comment)
Feedback (1 comment)
C is trivial (2 comments)
Possible variation to allow character exeptions
trichoplax‭ wrote over 2 years ago · edited over 2 years ago

I agree it's impractical to make exceptions for some characters, as they will differ between languages. Instead, the scoring mechanism could be used to allow arbitrary exceptions at a cost.

For example, the score could be 1 point for each unique character, with any non-unique characters scoring 0. This allows an answerer to choose which characters to duplicate, knowing they will be sacrificing the ability to use them for scoring.

ABC would score 3
AABCC would score 1 (only the B counts towards the score)
AAAABCCCC would also score 1

Alternatively the cost of duplication could be more lenient (maybe a character used N times only scores a total of 1/N)

ABC would score 3
AABCC would score 2 (0.5 + 1 + 0.5)
AAAABCCCC would score 1.5 (0.25 + 1 + 0.25)

The cost of duplication could be more harsh (maybe a character used more than once scores -1 for each additional usage)

ABC would score 3
AABCC would score 1 (1-1 + 1 + 1-1)
AAAABCCCC would score -3 (1-1-1-1 + 1 + 1-1-1-1)