JavaScript (148145)
(削除) 148 (削除ここまで) 145
Since JavaScript doesn’t really have standard input/output, this is written as a function that takes a string and returns the output as a string.
function r(n){for(i=o="",b=" |_ |"|_\n|",L=n.length;i<3*L;)o+=b[(c="ǪĠòƲĸƚǚĢǺƺ".charCodeAt(n[i%L])>>(i++/L|0)*3)&1]+b[c&2]+b[c&4]+(i%L&1]+b[c&2]+b[c&4]+b[i%L?" "0:"\n");return3];return o}
Spaced out:
function r(n)
{
for (i = o = "", b = " |_ |"|_\n|", L = n.length; i < 3*L; )
o += b [ (c = "ǪĠòƲĸƚǚĢǺƺ".charCodeAt(n[i%L]) >> (i++/L|0)*3) & 1]1 ] +
b [ c&2 ] +
b [ c&4 ] +
(b [ i%L ? " "0 : "\n");3 ]; // space or newline
return o
}
Here’s how it works:
Every digit shape is encoded in a Unicode character consisting of 9 bits.
The first three bits are for the first row, etc.
In each group of three bits, the first specifies whether the first character is
|or space, the second whether it’s_or space, and the third again|or space.These three bits are retrieved as
c&1,c&2andc&4, which are then used as indexes into the stringb.At each iteration,
i%Lis the "x-coordinate", i.e. the digit within the inputnAt each iteration,
i/Lis the "y-coordinate", i.e. the row, but we need|0to make it an integerFinally, the spaces between the digits and the newlines between the lines are also retrieved by indexing into
b, re-using the space character and the otherwise unused position 3 in that string! :)
JavaScript (148)
Since JavaScript doesn’t really have standard input/output, this is written as a function that takes a string and returns the output as a string.
function r(n){for(i=o="",b=" |_ |",L=n.length;i<3*L;)o+=b[(c="ǪĠòƲĸƚǚĢǺƺ".charCodeAt(n[i%L])>>(i++/L|0)*3)&1]+b[c&2]+b[c&4]+(i%L?" ":"\n");return o}
Spaced out:
function r(n)
{
for (i = o = "", b = " |_ |", L = n.length; i < 3*L; )
o += b [ (c = "ǪĠòƲĸƚǚĢǺƺ".charCodeAt(n[i%L]) >> (i++/L|0)*3) & 1] +
b [ c&2 ] +
b [ c&4 ] +
(i%L ? " " : "\n");
return o
}
Here’s how it works:
Every digit shape is encoded in a Unicode character consisting of 9 bits.
The first three bits are for the first row, etc.
In each group of three bits, the first specifies whether the first character is
|or space, the second whether it’s_or space, and the third again|or space.These three bits are retrieved as
c&1,c&2andc&4, which are then used as indexes into the stringb.At each iteration,
i%Lis the "x-coordinate", i.e. the digit within the inputnAt each iteration,
i/Lis the "y-coordinate", i.e. the row, but we need|0to make it an integer
JavaScript (145)
(削除) 148 (削除ここまで) 145
Since JavaScript doesn’t really have standard input/output, this is written as a function that takes a string and returns the output as a string.
function r(n){for(i=o="",b=" |_\n|",L=n.length;i<3*L;)o+=b[(c="ǪĠòƲĸƚǚĢǺƺ".charCodeAt(n[i%L])>>(i++/L|0)*3)&1]+b[c&2]+b[c&4]+b[i%L?0:3];return o}
Spaced out:
function r(n)
{
for (i = o = "", b = " |_\n|", L = n.length; i < 3*L; )
o += b [ (c = "ǪĠòƲĸƚǚĢǺƺ".charCodeAt(n[i%L]) >> (i++/L|0)*3) & 1 ] +
b [ c&2 ] +
b [ c&4 ] +
b [ i%L ? 0 : 3 ]; // space or newline
return o
}
Here’s how it works:
Every digit shape is encoded in a Unicode character consisting of 9 bits.
The first three bits are for the first row, etc.
In each group of three bits, the first specifies whether the first character is
|or space, the second whether it’s_or space, and the third again|or space.These three bits are retrieved as
c&1,c&2andc&4, which are then used as indexes into the stringb.At each iteration,
i%Lis the "x-coordinate", i.e. the digit within the inputnAt each iteration,
i/Lis the "y-coordinate", i.e. the row, but we need|0to make it an integerFinally, the spaces between the digits and the newlines between the lines are also retrieved by indexing into
b, re-using the space character and the otherwise unused position 3 in that string! :)
JavaScript (148)
Since JavaScript doesn’t really have standard input/output, this is written as a function that takes a string and returns the output as a string.
function r(n){for(i=o="",b=" |_ |",L=n.length;i<3*L;)o+=b[(c="ǪĠòƲĸƚǚĢǺƺ".charCodeAt(n[i%L])>>(i++/L|0)*3)&1]+b[c&2]+b[c&4]+(i%L?" ":"\n");return o}
Spaced out:
function r(n)
{
for (i = o = "", b = " |_ |", L = n.length; i<3*L;i < 3*L; )
o += b [ (c = "ǪĠòƲĸƚǚĢǺƺ".charCodeAt(n[i%L]) >> (i++/L|0)*3) & 1] +
b [ c&2 ] +
b [ c&4 ] +
(i%L ? " " : "\n");
return o
}
Here’s how it works:
Every digit shape is encoded in a Unicode character consisting of 9 bits.
The first three bits are for the first row, etc.
In each group of three bits, the first specifies whether the first character is
|or space, the second whether it’s_or space, and the third again|or space.These three bits are retrieved as
c&1,c&2andc&4, which are then used as indexes into the stringb.At each iteration,
i%Lis the "x-coordinate", i.e. the digit within the inputnAt each iteration,
i/Lis the "y-coordinate", i.e. the row, but we need|0to make it an integer
JavaScript (148)
Since JavaScript doesn’t really have standard input/output, this is written as a function that takes a string and returns the output as a string.
function r(n){for(i=o="",b=" |_ |",L=n.length;i<3*L;)o+=b[(c="ǪĠòƲĸƚǚĢǺƺ".charCodeAt(n[i%L])>>(i++/L|0)*3)&1]+b[c&2]+b[c&4]+(i%L?" ":"\n");return o}
Spaced out:
function r(n)
{
for (i = o = "", b = " |_ |", L = n.length; i<3*L; )
o += b [ (c = "ǪĠòƲĸƚǚĢǺƺ".charCodeAt(n[i%L]) >> (i++/L|0)*3) & 1] +
b [ c&2 ] +
b [ c&4 ] +
(i%L ? " " : "\n");
return o
}
Here’s how it works:
Every digit shape is encoded in a Unicode character consisting of 9 bits.
The first three bits are for the first row, etc.
In each group of three bits, the first specifies whether the first character is
|or space, the second whether it’s_or space, and the third again|or space.These three bits are retrieved as
c&1,c&2andc&4, which are then used as indexes into the stringb.At each iteration,
i%Lis the "x-coordinate", i.e. the digit within the inputnAt each iteration,
i/Lis the "y-coordinate", i.e. the row, but we need|0to make it an integer
JavaScript (148)
Since JavaScript doesn’t really have standard input/output, this is written as a function that takes a string and returns the output as a string.
function r(n){for(i=o="",b=" |_ |",L=n.length;i<3*L;)o+=b[(c="ǪĠòƲĸƚǚĢǺƺ".charCodeAt(n[i%L])>>(i++/L|0)*3)&1]+b[c&2]+b[c&4]+(i%L?" ":"\n");return o}
Spaced out:
function r(n)
{
for (i = o = "", b = " |_ |", L = n.length; i < 3*L; )
o += b [ (c = "ǪĠòƲĸƚǚĢǺƺ".charCodeAt(n[i%L]) >> (i++/L|0)*3) & 1] +
b [ c&2 ] +
b [ c&4 ] +
(i%L ? " " : "\n");
return o
}
Here’s how it works:
Every digit shape is encoded in a Unicode character consisting of 9 bits.
The first three bits are for the first row, etc.
In each group of three bits, the first specifies whether the first character is
|or space, the second whether it’s_or space, and the third again|or space.These three bits are retrieved as
c&1,c&2andc&4, which are then used as indexes into the stringb.At each iteration,
i%Lis the "x-coordinate", i.e. the digit within the inputnAt each iteration,
i/Lis the "y-coordinate", i.e. the row, but we need|0to make it an integer
JavaScript (148)
Since JavaScript doesn’t really have standard input/output, this is written as a function that takes a string and returns the output as a string.
function r(n){for(i=o="",b=" |_ |",L=n.length;i<3*L;)o+=b[(c="ǪĠòƲĸƚǚĢǺƺ".charCodeAt(n[i%L])>>(i++/L|0)*3)&1]+b[c&2]+b[c&4]+(i%L?" ":"\n");return o}
Spaced out:
function r(n)
{
for (i = o = "", b = " |_ |", L = n.length; i<3*L; )
o += b [ (c = "ǪĠòƲĸƚǚĢǺƺ".charCodeAt(n[i%L]) >> (i++/L|0)*3) & 1] +
b [ c&2 ] +
b [ c&4 ] +
(i%L ? " " : "\n");
return o
}
Here’s how it works:
Every digit shape is encoded in a Unicode character consisting of 9 bits.
The first three bits are for the first row, etc.
In each group of three bits, the first specifies whether the first character is
|or space, the second whether it’s_or space, and the third again|or space.These three bits are retrieved as
c&1,c&2andc&4, which are then used as indexes into the stringb.At each iteration,
i%Lis the "x-coordinate", i.e. the digit within the inputnAt each iteration,
i/Lis the "y-coordinate", i.e. the row, but we need|0to make it an integer