Skip to main content
deleted 242 characters in body
Source Link
FireFly
  • 7.3k
  • 29
  • 41

Befunge-98 - 26 22 21

Befunge-98 - 26 22 21 19

~:d3*''-d2*/1-!"' "*+*+,#@

Basically, it does putchar((c = getc()) + (c > '@' && !(c > 'Z'))*' '), pretending for a moment that the assignment to c is guranteed to happen first and that I got the nesting of parentheses right...

Now, instead it reliesRelies on the fact that (c-39)/26 is 1 only for character codes of uppercase ASCII characters (assuming integer division). So instead For each character c, I print out c + (((c-39)/26)==1)*' ' for each character c.

Sample session:

% cfunge lower.b98
hello WORLD!
hello world!
This is a TEST!!11 az AZ @[`{
this is a test!!11 az az @[`{

Befunge-98 - 26 22 21

~:d3*-d2*/1-!" "*+,#@

Basically, it does putchar((c = getc()) + (c > '@' && !(c > 'Z'))*' '), pretending for a moment that the assignment to c is guranteed to happen first and that I got the nesting of parentheses right...

Now, instead it relies on the fact that (c-39)/26 is 1 only for character codes of uppercase ASCII characters (assuming integer division). So instead, I print out c + (((c-39)/26)==1)*' ' for each character c.

Sample session:

% cfunge lower.b98
hello WORLD!
hello world!
This is a TEST!!11 az AZ @[`{
this is a test!!11 az az @[`{

Befunge-98 - 26 22 21 19

~:''-d2*/1-!' *+,#@

Relies on the fact that (c-39)/26 is 1 only for character codes of uppercase ASCII characters (assuming integer division). For each character c, print out c + (((c-39)/26)==1)*' '.

Sample session:

% cfunge lower.b98
hello WORLD!
hello world!
This is a TEST!!11 az AZ @[`{
this is a test!!11 az az @[`{
Saved a char!
Source Link
FireFly
  • 7.3k
  • 29
  • 41

Befunge-98 - 26 22

Befunge-98 - 26 22 21

~::"@"`\"Z"`d3*-d2*/1-!*"" "*+,#@

BasicallyBasically, it does putchar((c = getc()) + (c > '@' && !(c > 'Z'))*' '), pretending for a moment that the assignment to c is guranteed to happen first and that I got the nesting of parentheses right...

Now, instead it doesrelies on the fact that putchar((c = getc()-39)/26 is 1 only for character codes of uppercase ASCII characters (assuming integer division). So instead, I print out c + (c > '@' && !((c > 'Z'-39)/26)==1)*' '), pretending for a moment that the assignment toeach character c is guranteed to happen first and that I got the nesting of parentheses right...

ExampleSample session:

% cfunge lower.b98
hello WORLD!
hello world!
This is a TEST!!11 az AZ @[`{
this is a test!!11 az az @[`{

Edit: compare with both '@' and 'Z' in turn to shave off a few chars.

Befunge-98 - 26 22

~::"@"`\"Z"`!*" "*+,#@

Basically, it does putchar((c = getc()) + (c > '@' && !(c > 'Z'))*' '), pretending for a moment that the assignment to c is guranteed to happen first and that I got the nesting of parentheses right...

Example session:

% cfunge lower.b98
hello WORLD!
hello world!
This is a TEST!!11 az AZ @[`{
this is a test!!11 az az @[`{

Edit: compare with both '@' and 'Z' in turn to shave off a few chars.

Befunge-98 - 26 22 21

~:d3*-d2*/1-!" "*+,#@

Basically, it does putchar((c = getc()) + (c > '@' && !(c > 'Z'))*' '), pretending for a moment that the assignment to c is guranteed to happen first and that I got the nesting of parentheses right...

Now, instead it relies on the fact that (c-39)/26 is 1 only for character codes of uppercase ASCII characters (assuming integer division). So instead, I print out c + (((c-39)/26)==1)*' ' for each character c.

Sample session:

% cfunge lower.b98
hello WORLD!
hello world!
This is a TEST!!11 az AZ @[`{
this is a test!!11 az az @[`{
Refactor comparison code.
Source Link
FireFly
  • 7.3k
  • 29
  • 41

Befunge-98 - 2626 22

~:"@"-:0`\55*1+`"@"`\"Z"`!*" "*+,#@

Basically, it does putchar((c = getc()) + ((c-'@') > 0'@' && !((c-'@') > 26'Z'))*' '), pretending for a moment that the assignment to c is guranteed to happen first and that I got the nesting of parentheses right...

Example session:

% cfunge lower.b98
hello WORLD!
hello world!
This is a TEST!!11 az AZ @[`{
this is a test!!11 az az @[`{

Edit: compare with both '@' and 'Z' in turn to shave off a few chars.

Befunge-98 - 26

~:"@"-:0`\55*1+`!*" "*+,#@

Basically, it does putchar((c = getc()) + ((c-'@') > 0 && !((c-'@') > 26))*' '), pretending for a moment that the assignment to c is guranteed to happen first and that I got the nesting of parentheses right...

Example session:

% cfunge lower.b98
hello WORLD!
hello world!
This is a TEST!!11 az AZ @[`{
this is a test!!11 az az @[`{

Befunge-98 - 26 22

~::"@"`\"Z"`!*" "*+,#@

Basically, it does putchar((c = getc()) + (c > '@' && !(c > 'Z'))*' '), pretending for a moment that the assignment to c is guranteed to happen first and that I got the nesting of parentheses right...

Example session:

% cfunge lower.b98
hello WORLD!
hello world!
This is a TEST!!11 az AZ @[`{
this is a test!!11 az az @[`{

Edit: compare with both '@' and 'Z' in turn to shave off a few chars.

Source Link
FireFly
  • 7.3k
  • 29
  • 41
Loading