Skip to main content
deleted 653 characters in body
Source Link
undefined
  • 221
  • 1
  • 3

PHP - 187 182182 163 bytes

<?php $s;function i($v){return strtr($v,[1,0]);}function m($f,$a){return array_map($f,$a);}echo$s=$_GET["s"];$m="array_map";echo implodejoin(m$m("chr",m$m("bindec",m("i",m("strrev",m("decbin",m("ord",str_split$m($s))))))));?>

Ungolfed:

<?php
$s;

function i($v)
 {
    return strtr($v,[1,0]); // Replaces every occurrence of 1 by 0 and 0 by 1 on $v
}

function m($f, $a)
{
    return array_map($f, $a);
 }

echo implode(
        m("chr", // Get the ASCII character from a decimal value
            m("bindec", // Convert from binary to decimal
                m("i", // Invert the binary value
                    m$m("strrev", // Reverse the string
                        m$m("decbin", // Convert from decimal to binary
                            m$m("ord",str_split($s)) // Get the decimal ASCII value
                        )
                    )
                )
            )
        )
    );
 ?>

SetPass the value toas $sGET["s"].

array_map returns an array with all the elements of the second parameter (an array) after applying the callback function (first parameter) to all of them.

Not sure if I should take the 15% off, since echo doesn't output unprintable characters, but I didn't remove them.

Just glad I finished, since this is the first challenge I take part.

PHP - 187 182 bytes

<?php $s;function i($v){return strtr($v,[1,0]);}function m($f,$a){return array_map($f,$a);}echo implode(m("chr",m("bindec",m("i",m("strrev",m("decbin",m("ord",str_split($s))))))));?>

Ungolfed:

<?php
$s;

function i($v)
 {
    return strtr($v,[1,0]); // Replaces every occurrence of 1 by 0 and 0 by 1 on $v
}

function m($f, $a)
{
    return array_map($f, $a);
 }

echo implode(
        m("chr", // Get the ASCII character from a decimal value
            m("bindec", // Convert from binary to decimal
                m("i", // Invert the binary value
                    m("strrev", // Reverse the string
                        m("decbin", // Convert from decimal to binary
                            m("ord",str_split($s)) // Get the decimal ASCII value
                        )
                    )
                )
            )
        )
    );
 ?>

Set the value to $s.

array_map returns an array with all the elements of the second parameter (an array) after applying the callback function (first parameter) to all of them.

Not sure if I should take the 15% off, since echo doesn't output unprintable characters, but I didn't remove them.

Just glad I finished, since this is the first challenge I take part.

PHP - 187 182 163 bytes

<?php $s=$_GET["s"];$m="array_map";echo join($m("chr",$m("bindec",$m(function($v){return strtr($v,[1,0]);},$m("strrev",$m("decbin",$m("ord",str_split($s))))))));?>

Pass the value as GET["s"].

array_map returns an array with all the elements of the second parameter (an array) after applying the callback function (first parameter) to all of them.

Not sure if I should take the 15% off, since echo doesn't output unprintable characters, but I didn't remove them.

Just glad I finished, since this is the first challenge I take part.

added 31 characters in body
Source Link
undefined
  • 221
  • 1
  • 3

PHP - 187187 182 bytes

<?php $s;function i($v){return strtr($v,[1,0]);}function m($f,$a){return array_map($f,$a);}echo implode(array_mapm("chr",array_mapm("bindec",array_mapm("i",array_mapm("strrev",array_mapm("decbin",array_mapm("ord",str_split($s))))))));?>

Ungolfed:

<?php
$s;

function i($v)
{
    return strtr($v,[1,0]); // Replaces every occurrence of 1 by 0 and 0 by 1 on $v
}

function m($f, $a)
{
    return array_map($f, $a);
}

echo implode(
        array_mapm("chr", // Get the ASCII character from a decimal value
            array_mapm("bindec", // Convert from binary to decimal
                array_mapm("i", // Invert the binary value
                    array_mapm("strrev", // Reverse the string
                        array_mapm("decbin", // Convert from decimal to binary
                            array_mapm("ord",str_split($s)) // Get the decimal ASCII value
                        )
                    )
                )
            )
        )
    );
?>

Set the value to $s.

array_map returns an array with all the elements of the second parameter (an array) after applying the callback function (first parameter) to all of them.

Not sure if I should take the 15% off, since echo doesn't output unprintable characters, but I didn't remove them.

Just glad I finished, since this is the first challenge I take part.

PHP - 187 bytes

<?php $s;function i($v){return strtr($v,[1,0]);}echo implode(array_map("chr",array_map("bindec",array_map("i",array_map("strrev",array_map("decbin",array_map("ord",str_split($s))))))));?>

Ungolfed:

<?php
$s;

function i($v)
{
    return strtr($v,[1,0]); // Replaces every occurrence of 1 by 0 and 0 by 1 on $v
}

echo implode(
        array_map("chr", // Get the ASCII character from a decimal value
            array_map("bindec", // Convert from binary to decimal
                array_map("i", // Invert the binary value
                    array_map("strrev", // Reverse the string
                        array_map("decbin", // Convert from decimal to binary
                            array_map("ord",str_split($s)) // Get the decimal ASCII value
                        )
                    )
                )
            )
        )
    );
?>

Set the value to $s.

array_map returns an array with all the elements of the second parameter (an array) after applying the callback function (first parameter) to all of them.

Not sure if I should take the 15% off, since echo doesn't output unprintable characters, but I didn't remove them.

Just glad I finished, since this is the first challenge I take part.

PHP - 187 182 bytes

<?php $s;function i($v){return strtr($v,[1,0]);}function m($f,$a){return array_map($f,$a);}echo implode(m("chr",m("bindec",m("i",m("strrev",m("decbin",m("ord",str_split($s))))))));?>

Ungolfed:

<?php
$s;

function i($v)
{
    return strtr($v,[1,0]); // Replaces every occurrence of 1 by 0 and 0 by 1 on $v
}

function m($f, $a)
{
    return array_map($f, $a);
}

echo implode(
        m("chr", // Get the ASCII character from a decimal value
            m("bindec", // Convert from binary to decimal
                m("i", // Invert the binary value
                    m("strrev", // Reverse the string
                        m("decbin", // Convert from decimal to binary
                            m("ord",str_split($s)) // Get the decimal ASCII value
                        )
                    )
                )
            )
        )
    );
?>

Set the value to $s.

array_map returns an array with all the elements of the second parameter (an array) after applying the callback function (first parameter) to all of them.

Not sure if I should take the 15% off, since echo doesn't output unprintable characters, but I didn't remove them.

Just glad I finished, since this is the first challenge I take part.

Source Link
undefined
  • 221
  • 1
  • 3

PHP - 187 bytes

<?php $s;function i($v){return strtr($v,[1,0]);}echo implode(array_map("chr",array_map("bindec",array_map("i",array_map("strrev",array_map("decbin",array_map("ord",str_split($s))))))));?>

Ungolfed:

<?php
$s;

function i($v)
{
    return strtr($v,[1,0]); // Replaces every occurrence of 1 by 0 and 0 by 1 on $v
}

echo implode(
        array_map("chr", // Get the ASCII character from a decimal value
            array_map("bindec", // Convert from binary to decimal
                array_map("i", // Invert the binary value
                    array_map("strrev", // Reverse the string
                        array_map("decbin", // Convert from decimal to binary
                            array_map("ord",str_split($s)) // Get the decimal ASCII value
                        )
                    )
                )
            )
        )
    );
?>

Set the value to $s.

array_map returns an array with all the elements of the second parameter (an array) after applying the callback function (first parameter) to all of them.

Not sure if I should take the 15% off, since echo doesn't output unprintable characters, but I didn't remove them.

Just glad I finished, since this is the first challenge I take part.