Skip to main content
edited tags
Link
The Fifth Marshal
  • 6.3k
  • 1
  • 25
  • 44
edited body; edited tags
Source Link

The goal is to write a program that encodes an other program (input) with the fewest character possible.

Scoring

  • The score is equal to the different number of characters needed for the output.
  • Lower score is better.

Rules

  • No target languages with a limited set of commands. (No Brainf**k, Whitespace etc)
    Edit: I mean at least 26 significant characters, A doesn't change the way a brainf**k program operates, so you can't count this character. Same applies to whitespace.
  • The target language must exist at the time where this question is written.
  • You have to include a small explanation how you archiveachieve your score.
  • The input program is valid.
  • The encoded program must be a valid program in the same language as the input.
  • The encoded program must do the same job as the original program.
  • Your encoder must work for every valid program in that language.
  • Include some sample input and output.

Notes

  • The encoder might be written in any language, not only in the language it targets.
  • This is not , readable programs are encouraged.
  • The great goal is to see how many different characters are needed to write anything in that language. I disallowed BF etc because there would be no challenge.
  • This was inspired by Print a string in as few distinct characters as possible, you could take it as for that question.

Example

In Java, you can use \uXXXX instead other characters. A valid entry encodes every character from the input this way. This would have a score of 18. (\ 0-9a-f)

Code in Tcl, encodes a Java program:

set res {}
foreach char [split [read stdin] {}] {
    append res [format \\u%04x [scan $char %c]]
}
puts $res

The goal is to write a program that encodes an other program (input) with the fewest character possible.

Scoring

  • The score is equal to the different number of characters needed for the output.
  • Lower score is better.

Rules

  • No target languages with a limited set of commands. (No Brainf**k, Whitespace etc)
    Edit: I mean at least 26 significant characters, A doesn't change the way a brainf**k program operates, so you can't count this character. Same applies to whitespace.
  • The target language must exist at the time where this question is written.
  • You have to include a small explanation how you archive your score.
  • The input program is valid.
  • The encoded program must be a valid program in the same language as the input.
  • The encoded program must do the same job as the original program.
  • Your encoder must work for every valid program in that language.
  • Include some sample input and output.

Notes

  • The encoder might be written in any language, not only in the language it targets.
  • This is not , readable programs are encouraged.
  • The great goal is to see how many different characters are needed to write anything in that language. I disallowed BF etc because there would be no challenge.
  • This was inspired by Print a string in as few distinct characters as possible, you could take it as for that question.

Example

In Java, you can use \uXXXX instead other characters. A valid entry encodes every character from the input this way. This would have a score of 18. (\ 0-9a-f)

Code in Tcl, encodes a Java program:

set res {}
foreach char [split [read stdin] {}] {
    append res [format \\u%04x [scan $char %c]]
}
puts $res

The goal is to write a program that encodes an other program (input) with the fewest character possible.

Scoring

  • The score is equal to the different number of characters needed for the output.
  • Lower score is better.

Rules

  • No target languages with a limited set of commands. (No Brainf**k, Whitespace etc)
    Edit: I mean at least 26 significant characters, A doesn't change the way a brainf**k program operates, so you can't count this character. Same applies to whitespace.
  • The target language must exist at the time where this question is written.
  • You have to include a small explanation how you achieve your score.
  • The input program is valid.
  • The encoded program must be a valid program in the same language as the input.
  • The encoded program must do the same job as the original program.
  • Your encoder must work for every valid program in that language.
  • Include some sample input and output.

Notes

  • The encoder might be written in any language, not only in the language it targets.
  • This is not , readable programs are encouraged.
  • The great goal is to see how many different characters are needed to write anything in that language. I disallowed BF etc because there would be no challenge.
  • This was inspired by Print a string in as few distinct characters as possible, you could take it as for that question.

Example

In Java, you can use \uXXXX instead other characters. A valid entry encodes every character from the input this way. This would have a score of 18. (\ 0-9a-f)

Code in Tcl, encodes a Java program:

set res {}
foreach char [split [read stdin] {}] {
    append res [format \\u%04x [scan $char %c]]
}
puts $res

Encode a program with the fewest distinct characters possible,

Encode a program with the fewest distinct characters possible,

The goal is to write a program that encodes an other program (input) with the fewest character possible.

Scoring

  • The score is equal to the different number of characters needed for the output.
  • Lower score is better.

Rules

  • No target languages with a limited set of commands. (No Brainf**k, Whitespace etc)
    Edit: I mean at least 26 significant characters, A doesn't change the way a brainf**k program operates, so you can't count this character. Same applies to whitespace.
  • The target language must exist at the time where this question is written.
  • You have to include a small explanation how you archive your score.
  • The input program is valid.
  • The encoded program must be a valid program in the same language as the input.
  • The encoded program must do the same job as the original program.
  • Your encoder must work for every valid program in that language.
  • Include some sample input and output.

Notes

  • The encoder might be written in any language, not only in the language it targets.
  • This is not , readable programs are encouraged.
  • The great goal is to see how many different characters are needed to write anything in that language. I disallowed BF etc because there would be no challenge.
  • This was inspired by Print a string in as few distinct characters as possible, you could take it as for that question.

Example

In Java, you can use \uXXXX instead other characters. A valid entry encodes every character from the input this way. This would have a score of 18. (\ 0-9a-f)

Code in Tcl, encodes a Java program:

set res {}
foreach char [split [read stdin] {}] {
    append res [format \\u%04x [scan $char %c]]
}
puts $res

Encode a program with the fewest distinct characters possible,

The goal is to write a program that encodes an other program (input) with the fewest character possible.

Scoring

  • The score is equal to the different number of characters needed for the output.
  • Lower score is better.

Rules

  • No target languages with a limited set of commands. (No Brainf**k, Whitespace etc)
    Edit: I mean at least 26 significant characters, A doesn't change the way a brainf**k program operates, so you can't count this character. Same applies to whitespace.
  • The target language must exist at the time where this question is written.
  • You have to include a small explanation how you archive your score.
  • The input program is valid.
  • The encoded program must be a valid program in the same language as the input.
  • The encoded program must do the same job as the original program.
  • Your encoder must work for every valid program in that language.
  • Include some sample input and output.

Notes

  • The encoder might be written in any language, not only in the language it targets.
  • This is not , readable programs are encouraged.
  • The great goal is to see how many different characters are needed to write anything in that language. I disallowed BF etc because there would be no challenge.
  • This was inspired by Print a string in as few distinct characters as possible, you could take it as for that question.

Example

In Java, you can use \uXXXX instead other characters. A valid entry encodes every character from the input this way. This would have a score of 18. (\ 0-9a-f)

Code in Tcl, encodes a Java program:

set res {}
foreach char [split [read stdin] {}] {
    append res [format \\u%04x [scan $char %c]]
}
puts $res

Encode a program with the fewest distinct characters possible

The goal is to write a program that encodes an other program (input) with the fewest character possible.

Scoring

  • The score is equal to the different number of characters needed for the output.
  • Lower score is better.

Rules

  • No target languages with a limited set of commands. (No Brainf**k, Whitespace etc)
    Edit: I mean at least 26 significant characters, A doesn't change the way a brainf**k program operates, so you can't count this character. Same applies to whitespace.
  • The target language must exist at the time where this question is written.
  • You have to include a small explanation how you archive your score.
  • The input program is valid.
  • The encoded program must be a valid program in the same language as the input.
  • The encoded program must do the same job as the original program.
  • Your encoder must work for every valid program in that language.
  • Include some sample input and output.

Notes

  • The encoder might be written in any language, not only in the language it targets.
  • This is not , readable programs are encouraged.
  • The great goal is to see how many different characters are needed to write anything in that language. I disallowed BF etc because there would be no challenge.
  • This was inspired by Print a string in as few distinct characters as possible, you could take it as for that question.

Example

In Java, you can use \uXXXX instead other characters. A valid entry encodes every character from the input this way. This would have a score of 18. (\ 0-9a-f)

Code in Tcl, encodes a Java program:

set res {}
foreach char [split [read stdin] {}] {
    append res [format \\u%04x [scan $char %c]]
}
puts $res
Commonmark migration
Source Link
Loading
replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link
Loading
added 14 characters in body
Source Link
Johannes Kuhn
  • 7.5k
  • 5
  • 32
  • 44
Loading
Post Reopened by Johannes Kuhn, Timtech, jimmy23013, Pavel, Riker
Stupid Rule Police
Source Link
Johannes Kuhn
  • 7.5k
  • 5
  • 32
  • 44
Loading
Post Closed as "Needs details or clarity" by user62131, Blue, mbomb007, Wheat Wizard, xenia
deleted 71 characters in body
Source Link
mbomb007
  • 23.5k
  • 7
  • 63
  • 135
Loading
Tweeted twitter.com/#!/StackCodeGolf/status/340938506497056768
edited body
Source Link
Johannes Kuhn
  • 7.5k
  • 5
  • 32
  • 44
Loading
Source Link
Johannes Kuhn
  • 7.5k
  • 5
  • 32
  • 44
Loading