Code Golf Measurer © 2019Write a hello world GUI program that closes itself after three secondsCode Golf Image DownloaderCode Golf: Gibberish Echo“Hello world” that creates a different “Hello world” programIt's Not 2015 Anymore!Double-duty quine: quine!dlroW ,olleHShortest Unique SubstringDouble rotationInterlace stringsAnimate the text in your terminal
Why do Computer Science degrees contain a high proportion of mathematics?
3-prong to 4-prong conversion - EXTRA MISLABELLED WIRES - Dryer cable upgrade and installation
Is there a push, in the United States, to use gender-neutral language and gender pronouns (when they are given)?
Can you upgrade armour from breastplate to halfplate?
Can we not simply connect a battery to a RAM to prevent data loss during power cuts?
What are the branches of statistics?
In "Avatar: The Last Airbender" can a metalbender bloodbend if there is metal in our blood?
Is it possible to unmount a partition table?
Why does Sonny say they call Michael "Giogali"?
Can digital computers understand infinity?
A fast aquatic predator with multiple eyes and pupils. Would these eyes be possible?
Dice? = Is that so?
A curious 5x5 square
Does my protagonist need to be the most important character?
Should I avoid "big words" when writing to a younger audience?
How to plot two axis bar chart side by side
How to create a vimrc macro using :sort?
How can I prove mathematically the reflection matrix has only the eigenvalues 1 or -1?
When did MCMC become commonplace?
Satellite for internet... Safe enough?
How many records can an Apex Batch process
What is "demographic engineering" and how does it differ from ethnic cleansing?
Standard cumulative distribution function with optimization model variable
Is Schrodinger's Cat itself an observer?
Code Golf Measurer © 2019
Write a hello world GUI program that closes itself after three secondsCode Golf Image DownloaderCode Golf: Gibberish Echo“Hello world” that creates a different “Hello world” programIt's Not 2015 Anymore!Double-duty quine: quine!dlroW ,olleHShortest Unique SubstringDouble rotationInterlace stringsAnimate the text in your terminal
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;
$begingroup$
Code Golf Measurer © 2019
Hexdumps used with xxd
look something like this:
00000000: 666f 6f20 6261 7220 7370 616d 2065 6767 foo bar spam egg
00000010: 730a s.
Your task is to convert a hexdump in this form in to the number of bytes used.
Rules:
- Usual loopholes forbidden.
- This is code-golf, so shortest valid answer in bytes wins.
- You may or may not include the newline at the end of text (
0a
). This means that if the hexdump ends in a newline (0a
), that input may have it's output reduced by one. - An empty input (literally nothing: empty list/string/etc.) must output 0.
- Input can be taken in any form
- Input will be valid ASCII with no control characters
- The input must contain the whole hexdump
Test cases:
00000000: 4865 6c6c 6f2c 2077 6f72 6c64 2120 4865 Hello, world! He
00000010: 6c6c 6f2c 2077 6f72 6c64 210a llo, world!.
returns 28 or 27
00000000: 0a .
returns 1 or 0
00000000: 6368 616c 6c65 6e67 650a challenge.
returns 10 or 9
00000000: 4865 6c6c 6f2c 2077 6f72 6c64 21 Hello, world!
returns 13
returns 0 (This is literally nothing: empty list/string/etc.)
Explanations would be nice for non-standard languages.
code-golf string hexadecimal
$endgroup$
add a comment
|
$begingroup$
Code Golf Measurer © 2019
Hexdumps used with xxd
look something like this:
00000000: 666f 6f20 6261 7220 7370 616d 2065 6767 foo bar spam egg
00000010: 730a s.
Your task is to convert a hexdump in this form in to the number of bytes used.
Rules:
- Usual loopholes forbidden.
- This is code-golf, so shortest valid answer in bytes wins.
- You may or may not include the newline at the end of text (
0a
). This means that if the hexdump ends in a newline (0a
), that input may have it's output reduced by one. - An empty input (literally nothing: empty list/string/etc.) must output 0.
- Input can be taken in any form
- Input will be valid ASCII with no control characters
- The input must contain the whole hexdump
Test cases:
00000000: 4865 6c6c 6f2c 2077 6f72 6c64 2120 4865 Hello, world! He
00000010: 6c6c 6f2c 2077 6f72 6c64 210a llo, world!.
returns 28 or 27
00000000: 0a .
returns 1 or 0
00000000: 6368 616c 6c65 6e67 650a challenge.
returns 10 or 9
00000000: 4865 6c6c 6f2c 2077 6f72 6c64 21 Hello, world!
returns 13
returns 0 (This is literally nothing: empty list/string/etc.)
Explanations would be nice for non-standard languages.
code-golf string hexadecimal
$endgroup$
$begingroup$
May we assume the input is ascii? Can it contain control characters? What are the input rules? Some languages can't handle input over multiple lines. Can we pad the last line so that all lines are equally long? Why include the blank input?
$endgroup$
– Stewie Griffin
9 hours ago
$begingroup$
@StewieGriffin Yes; no; yes; because ifxxd
is fed an empty string, it outputs nothing.
$endgroup$
– gadzooks02
9 hours ago
$begingroup$
@StewieGriffin You edited your comment while I was answering, so here's an expansion: Yes; No; it can be input however you want, provided the whole dump is included; See last answer; Yes; Because if xxd is fed an empty string, it outputs nothing
$endgroup$
– gadzooks02
9 hours ago
1
$begingroup$
@JonathanAllan Oh yes, well spotted.
$endgroup$
– gadzooks02
8 hours ago
add a comment
|
$begingroup$
Code Golf Measurer © 2019
Hexdumps used with xxd
look something like this:
00000000: 666f 6f20 6261 7220 7370 616d 2065 6767 foo bar spam egg
00000010: 730a s.
Your task is to convert a hexdump in this form in to the number of bytes used.
Rules:
- Usual loopholes forbidden.
- This is code-golf, so shortest valid answer in bytes wins.
- You may or may not include the newline at the end of text (
0a
). This means that if the hexdump ends in a newline (0a
), that input may have it's output reduced by one. - An empty input (literally nothing: empty list/string/etc.) must output 0.
- Input can be taken in any form
- Input will be valid ASCII with no control characters
- The input must contain the whole hexdump
Test cases:
00000000: 4865 6c6c 6f2c 2077 6f72 6c64 2120 4865 Hello, world! He
00000010: 6c6c 6f2c 2077 6f72 6c64 210a llo, world!.
returns 28 or 27
00000000: 0a .
returns 1 or 0
00000000: 6368 616c 6c65 6e67 650a challenge.
returns 10 or 9
00000000: 4865 6c6c 6f2c 2077 6f72 6c64 21 Hello, world!
returns 13
returns 0 (This is literally nothing: empty list/string/etc.)
Explanations would be nice for non-standard languages.
code-golf string hexadecimal
$endgroup$
Code Golf Measurer © 2019
Hexdumps used with xxd
look something like this:
00000000: 666f 6f20 6261 7220 7370 616d 2065 6767 foo bar spam egg
00000010: 730a s.
Your task is to convert a hexdump in this form in to the number of bytes used.
Rules:
- Usual loopholes forbidden.
- This is code-golf, so shortest valid answer in bytes wins.
- You may or may not include the newline at the end of text (
0a
). This means that if the hexdump ends in a newline (0a
), that input may have it's output reduced by one. - An empty input (literally nothing: empty list/string/etc.) must output 0.
- Input can be taken in any form
- Input will be valid ASCII with no control characters
- The input must contain the whole hexdump
Test cases:
00000000: 4865 6c6c 6f2c 2077 6f72 6c64 2120 4865 Hello, world! He
00000010: 6c6c 6f2c 2077 6f72 6c64 210a llo, world!.
returns 28 or 27
00000000: 0a .
returns 1 or 0
00000000: 6368 616c 6c65 6e67 650a challenge.
returns 10 or 9
00000000: 4865 6c6c 6f2c 2077 6f72 6c64 21 Hello, world!
returns 13
returns 0 (This is literally nothing: empty list/string/etc.)
Explanations would be nice for non-standard languages.
code-golf string hexadecimal
code-golf string hexadecimal
edited 8 hours ago
gadzooks02
asked 9 hours ago
gadzooks02gadzooks02
745 bronze badges
745 bronze badges
$begingroup$
May we assume the input is ascii? Can it contain control characters? What are the input rules? Some languages can't handle input over multiple lines. Can we pad the last line so that all lines are equally long? Why include the blank input?
$endgroup$
– Stewie Griffin
9 hours ago
$begingroup$
@StewieGriffin Yes; no; yes; because ifxxd
is fed an empty string, it outputs nothing.
$endgroup$
– gadzooks02
9 hours ago
$begingroup$
@StewieGriffin You edited your comment while I was answering, so here's an expansion: Yes; No; it can be input however you want, provided the whole dump is included; See last answer; Yes; Because if xxd is fed an empty string, it outputs nothing
$endgroup$
– gadzooks02
9 hours ago
1
$begingroup$
@JonathanAllan Oh yes, well spotted.
$endgroup$
– gadzooks02
8 hours ago
add a comment
|
$begingroup$
May we assume the input is ascii? Can it contain control characters? What are the input rules? Some languages can't handle input over multiple lines. Can we pad the last line so that all lines are equally long? Why include the blank input?
$endgroup$
– Stewie Griffin
9 hours ago
$begingroup$
@StewieGriffin Yes; no; yes; because ifxxd
is fed an empty string, it outputs nothing.
$endgroup$
– gadzooks02
9 hours ago
$begingroup$
@StewieGriffin You edited your comment while I was answering, so here's an expansion: Yes; No; it can be input however you want, provided the whole dump is included; See last answer; Yes; Because if xxd is fed an empty string, it outputs nothing
$endgroup$
– gadzooks02
9 hours ago
1
$begingroup$
@JonathanAllan Oh yes, well spotted.
$endgroup$
– gadzooks02
8 hours ago
$begingroup$
May we assume the input is ascii? Can it contain control characters? What are the input rules? Some languages can't handle input over multiple lines. Can we pad the last line so that all lines are equally long? Why include the blank input?
$endgroup$
– Stewie Griffin
9 hours ago
$begingroup$
May we assume the input is ascii? Can it contain control characters? What are the input rules? Some languages can't handle input over multiple lines. Can we pad the last line so that all lines are equally long? Why include the blank input?
$endgroup$
– Stewie Griffin
9 hours ago
$begingroup$
@StewieGriffin Yes; no; yes; because if
xxd
is fed an empty string, it outputs nothing.$endgroup$
– gadzooks02
9 hours ago
$begingroup$
@StewieGriffin Yes; no; yes; because if
xxd
is fed an empty string, it outputs nothing.$endgroup$
– gadzooks02
9 hours ago
$begingroup$
@StewieGriffin You edited your comment while I was answering, so here's an expansion: Yes; No; it can be input however you want, provided the whole dump is included; See last answer; Yes; Because if xxd is fed an empty string, it outputs nothing
$endgroup$
– gadzooks02
9 hours ago
$begingroup$
@StewieGriffin You edited your comment while I was answering, so here's an expansion: Yes; No; it can be input however you want, provided the whole dump is included; See last answer; Yes; Because if xxd is fed an empty string, it outputs nothing
$endgroup$
– gadzooks02
9 hours ago
1
1
$begingroup$
@JonathanAllan Oh yes, well spotted.
$endgroup$
– gadzooks02
8 hours ago
$begingroup$
@JonathanAllan Oh yes, well spotted.
$endgroup$
– gadzooks02
8 hours ago
add a comment
|
13 Answers
13
active
oldest
votes
$begingroup$
APL (Dyalog Extended), 18 bytes
Full program. Prompts for list of strings (i.e. of lists of characters).
2÷⍨≢∊(1↓≠⊆⊢)¨49↑¨⎕
Try it online!
⎕
prompt
49↑¨
take the first 49 characters from each
(
…)¨
apply the following tacit function to each:
⊢
the argument
⊆
chop into runs of characters that are
≠
different from the padding character (space)
1↓
drop the first "word"
∊
ϵnlist (flatten)
≢
tally
2÷⍨
divide by two
$endgroup$
add a comment
|
$begingroup$
Jelly, 5 bytes
Ẉ_51S
A monadic Link accepting a list of lines which yield the integer byte count.
Try it online!
How?
Ẉ_51S - Link: list of lists of characters, H
Ẉ - length of each (line in H)
51 - literal fifty-one
_ - subtract (vectorises)
S - sum
$endgroup$
$begingroup$
You can accept a list of lines. Also, would you care to add an explanation?
$endgroup$
– gadzooks02
9 hours ago
$begingroup$
Ah cool, so is the empty input an empty list OR a list with a single empty line? (This should be made clear in the post since it's an edge-case.)
$endgroup$
– Jonathan Allan
9 hours ago
$begingroup$
It's and empty list/string/etc. I've just clarified this.
$endgroup$
– gadzooks02
9 hours ago
$begingroup$
Thanks, explanation added now too.
$endgroup$
– Jonathan Allan
8 hours ago
add a comment
|
$begingroup$
V (vim), 10 bytes
ÎdW9WD
Øøø
Try it online!
Explanation:
Î " On every line...
dW " Delete the first WORD
9W " Move 9 WORDS forward
D " Delete everything after the cursor
Ø " Count the number of regex matches on every line...
øø " Two hexadecimal characters in a row
Hexdump:
00000000: ce64 5739 5744 0dd8 f8f8 .dW9WD....
$endgroup$
add a comment
|
$begingroup$
tcsh, 12 bytes
xxd -r|wc -c
Try it online!
$endgroup$
add a comment
|
$begingroup$
Befunge-98 (FBBI), 16 bytes
"c- cw|r- dxx"=@
Try it online!
$endgroup$
add a comment
|
$begingroup$
05AB1E, 8 bytes
|εg51-}O
Try it online!
| get all input lines
ε for each line
g51- subtract 51 from length
}
O push the sum of the resulting list
$endgroup$
1
$begingroup$
Sorry, the input must contain the whole hexdump. (Yours skips the letters at the end of each line)
$endgroup$
– gadzooks02
9 hours ago
$begingroup$
Oh, my bad. I made this on my smartphone. Didn't see there's something behind the hex codes. I made a correction.
$endgroup$
– Dorian
8 hours ago
add a comment
|
$begingroup$
Japt -x
, 5 bytes
Input as an array of lines.
®Ê-51
Try it
®Ê-51 :Implicit input of array
® :Map
Ê : Length
-51 : Subtract 51
:Implicit output of sum of resulting array
$endgroup$
$begingroup$
An explanation would be nice :)
$endgroup$
– gadzooks02
8 hours ago
$begingroup$
Coming soon, @gadzooks02. But it's the same as the Jelly solution.
$endgroup$
– Shaggy
8 hours ago
$begingroup$
@gadzooks02, explanation added.
$endgroup$
– Shaggy
7 hours ago
add a comment
|
$begingroup$
Red, 81 bytes
func[s][n: 0 try[foreach l s[n: n + length? trim/all at take/part l 49 10]]n / 2]
Try it online!
$endgroup$
add a comment
|
$begingroup$
C (gcc), 64 bytes
s[];f(r,l)r=0;while(*s=0,gets(s),l=strlen(s))r+=l-51;return r;
Try it online!
$endgroup$
$begingroup$
You could usefor
.
$endgroup$
– Jonathan Frech
5 hours ago
$begingroup$
Also,s[]
seems to me to be unstable undefined behaviour.
$endgroup$
– Jonathan Frech
5 hours ago
add a comment
|
$begingroup$
Python 3, 48 bytes
f=lambda s:(len(s)or 51)+1-52*len(s.split('n'))
Input is passed as a string to the function f
. The function increments the length of the input (including newlines), then subtracts 52 for each line.
Try it online
$endgroup$
add a comment
|
$begingroup$
JavaScript (ES6), 34 bytes
s=>(n=s.length)&&(n/68<<4)+n%68-51
Try it online!
Commented
s => // s = input string
(n = s.length) && // n = length of s; return 0 right away if n = 0 (special case)
(n / 68 << 4) + // otherwise compute the number of full lines and multiply it by 16
n % 68 - 51 // add the length of the last line minus 51
$endgroup$
add a comment
|
$begingroup$
Retina 0.8.2, 8 bytes
.51
.
Try it online! Explanation:
.51
Delete the first 51 characters of each line. (Lines can only have between 52 and 67 characters, so this always matches once per line.)
.
Count the remaining non-newline characters.
$endgroup$
add a comment
|
$begingroup$
Perl 6, 18 bytes
.join.comb-51*$_
Try it online!
Anonymous Whatever lambda that takes a list of lines and returns the sum of the number of characters, subtracting 51 for each line
$endgroup$
add a comment
|
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "200"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f194040%2fcode-golf-measurer-2019%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
13 Answers
13
active
oldest
votes
13 Answers
13
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
APL (Dyalog Extended), 18 bytes
Full program. Prompts for list of strings (i.e. of lists of characters).
2÷⍨≢∊(1↓≠⊆⊢)¨49↑¨⎕
Try it online!
⎕
prompt
49↑¨
take the first 49 characters from each
(
…)¨
apply the following tacit function to each:
⊢
the argument
⊆
chop into runs of characters that are
≠
different from the padding character (space)
1↓
drop the first "word"
∊
ϵnlist (flatten)
≢
tally
2÷⍨
divide by two
$endgroup$
add a comment
|
$begingroup$
APL (Dyalog Extended), 18 bytes
Full program. Prompts for list of strings (i.e. of lists of characters).
2÷⍨≢∊(1↓≠⊆⊢)¨49↑¨⎕
Try it online!
⎕
prompt
49↑¨
take the first 49 characters from each
(
…)¨
apply the following tacit function to each:
⊢
the argument
⊆
chop into runs of characters that are
≠
different from the padding character (space)
1↓
drop the first "word"
∊
ϵnlist (flatten)
≢
tally
2÷⍨
divide by two
$endgroup$
add a comment
|
$begingroup$
APL (Dyalog Extended), 18 bytes
Full program. Prompts for list of strings (i.e. of lists of characters).
2÷⍨≢∊(1↓≠⊆⊢)¨49↑¨⎕
Try it online!
⎕
prompt
49↑¨
take the first 49 characters from each
(
…)¨
apply the following tacit function to each:
⊢
the argument
⊆
chop into runs of characters that are
≠
different from the padding character (space)
1↓
drop the first "word"
∊
ϵnlist (flatten)
≢
tally
2÷⍨
divide by two
$endgroup$
APL (Dyalog Extended), 18 bytes
Full program. Prompts for list of strings (i.e. of lists of characters).
2÷⍨≢∊(1↓≠⊆⊢)¨49↑¨⎕
Try it online!
⎕
prompt
49↑¨
take the first 49 characters from each
(
…)¨
apply the following tacit function to each:
⊢
the argument
⊆
chop into runs of characters that are
≠
different from the padding character (space)
1↓
drop the first "word"
∊
ϵnlist (flatten)
≢
tally
2÷⍨
divide by two
answered 8 hours ago
AdámAdám
30.9k2 gold badges87 silver badges221 bronze badges
30.9k2 gold badges87 silver badges221 bronze badges
add a comment
|
add a comment
|
$begingroup$
Jelly, 5 bytes
Ẉ_51S
A monadic Link accepting a list of lines which yield the integer byte count.
Try it online!
How?
Ẉ_51S - Link: list of lists of characters, H
Ẉ - length of each (line in H)
51 - literal fifty-one
_ - subtract (vectorises)
S - sum
$endgroup$
$begingroup$
You can accept a list of lines. Also, would you care to add an explanation?
$endgroup$
– gadzooks02
9 hours ago
$begingroup$
Ah cool, so is the empty input an empty list OR a list with a single empty line? (This should be made clear in the post since it's an edge-case.)
$endgroup$
– Jonathan Allan
9 hours ago
$begingroup$
It's and empty list/string/etc. I've just clarified this.
$endgroup$
– gadzooks02
9 hours ago
$begingroup$
Thanks, explanation added now too.
$endgroup$
– Jonathan Allan
8 hours ago
add a comment
|
$begingroup$
Jelly, 5 bytes
Ẉ_51S
A monadic Link accepting a list of lines which yield the integer byte count.
Try it online!
How?
Ẉ_51S - Link: list of lists of characters, H
Ẉ - length of each (line in H)
51 - literal fifty-one
_ - subtract (vectorises)
S - sum
$endgroup$
$begingroup$
You can accept a list of lines. Also, would you care to add an explanation?
$endgroup$
– gadzooks02
9 hours ago
$begingroup$
Ah cool, so is the empty input an empty list OR a list with a single empty line? (This should be made clear in the post since it's an edge-case.)
$endgroup$
– Jonathan Allan
9 hours ago
$begingroup$
It's and empty list/string/etc. I've just clarified this.
$endgroup$
– gadzooks02
9 hours ago
$begingroup$
Thanks, explanation added now too.
$endgroup$
– Jonathan Allan
8 hours ago
add a comment
|
$begingroup$
Jelly, 5 bytes
Ẉ_51S
A monadic Link accepting a list of lines which yield the integer byte count.
Try it online!
How?
Ẉ_51S - Link: list of lists of characters, H
Ẉ - length of each (line in H)
51 - literal fifty-one
_ - subtract (vectorises)
S - sum
$endgroup$
Jelly, 5 bytes
Ẉ_51S
A monadic Link accepting a list of lines which yield the integer byte count.
Try it online!
How?
Ẉ_51S - Link: list of lists of characters, H
Ẉ - length of each (line in H)
51 - literal fifty-one
_ - subtract (vectorises)
S - sum
edited 9 hours ago
answered 9 hours ago
Jonathan AllanJonathan Allan
61.2k5 gold badges44 silver badges188 bronze badges
61.2k5 gold badges44 silver badges188 bronze badges
$begingroup$
You can accept a list of lines. Also, would you care to add an explanation?
$endgroup$
– gadzooks02
9 hours ago
$begingroup$
Ah cool, so is the empty input an empty list OR a list with a single empty line? (This should be made clear in the post since it's an edge-case.)
$endgroup$
– Jonathan Allan
9 hours ago
$begingroup$
It's and empty list/string/etc. I've just clarified this.
$endgroup$
– gadzooks02
9 hours ago
$begingroup$
Thanks, explanation added now too.
$endgroup$
– Jonathan Allan
8 hours ago
add a comment
|
$begingroup$
You can accept a list of lines. Also, would you care to add an explanation?
$endgroup$
– gadzooks02
9 hours ago
$begingroup$
Ah cool, so is the empty input an empty list OR a list with a single empty line? (This should be made clear in the post since it's an edge-case.)
$endgroup$
– Jonathan Allan
9 hours ago
$begingroup$
It's and empty list/string/etc. I've just clarified this.
$endgroup$
– gadzooks02
9 hours ago
$begingroup$
Thanks, explanation added now too.
$endgroup$
– Jonathan Allan
8 hours ago
$begingroup$
You can accept a list of lines. Also, would you care to add an explanation?
$endgroup$
– gadzooks02
9 hours ago
$begingroup$
You can accept a list of lines. Also, would you care to add an explanation?
$endgroup$
– gadzooks02
9 hours ago
$begingroup$
Ah cool, so is the empty input an empty list OR a list with a single empty line? (This should be made clear in the post since it's an edge-case.)
$endgroup$
– Jonathan Allan
9 hours ago
$begingroup$
Ah cool, so is the empty input an empty list OR a list with a single empty line? (This should be made clear in the post since it's an edge-case.)
$endgroup$
– Jonathan Allan
9 hours ago
$begingroup$
It's and empty list/string/etc. I've just clarified this.
$endgroup$
– gadzooks02
9 hours ago
$begingroup$
It's and empty list/string/etc. I've just clarified this.
$endgroup$
– gadzooks02
9 hours ago
$begingroup$
Thanks, explanation added now too.
$endgroup$
– Jonathan Allan
8 hours ago
$begingroup$
Thanks, explanation added now too.
$endgroup$
– Jonathan Allan
8 hours ago
add a comment
|
$begingroup$
V (vim), 10 bytes
ÎdW9WD
Øøø
Try it online!
Explanation:
Î " On every line...
dW " Delete the first WORD
9W " Move 9 WORDS forward
D " Delete everything after the cursor
Ø " Count the number of regex matches on every line...
øø " Two hexadecimal characters in a row
Hexdump:
00000000: ce64 5739 5744 0dd8 f8f8 .dW9WD....
$endgroup$
add a comment
|
$begingroup$
V (vim), 10 bytes
ÎdW9WD
Øøø
Try it online!
Explanation:
Î " On every line...
dW " Delete the first WORD
9W " Move 9 WORDS forward
D " Delete everything after the cursor
Ø " Count the number of regex matches on every line...
øø " Two hexadecimal characters in a row
Hexdump:
00000000: ce64 5739 5744 0dd8 f8f8 .dW9WD....
$endgroup$
add a comment
|
$begingroup$
V (vim), 10 bytes
ÎdW9WD
Øøø
Try it online!
Explanation:
Î " On every line...
dW " Delete the first WORD
9W " Move 9 WORDS forward
D " Delete everything after the cursor
Ø " Count the number of regex matches on every line...
øø " Two hexadecimal characters in a row
Hexdump:
00000000: ce64 5739 5744 0dd8 f8f8 .dW9WD....
$endgroup$
V (vim), 10 bytes
ÎdW9WD
Øøø
Try it online!
Explanation:
Î " On every line...
dW " Delete the first WORD
9W " Move 9 WORDS forward
D " Delete everything after the cursor
Ø " Count the number of regex matches on every line...
øø " Two hexadecimal characters in a row
Hexdump:
00000000: ce64 5739 5744 0dd8 f8f8 .dW9WD....
edited 7 hours ago
answered 9 hours ago
DJMcMayhem♦DJMcMayhem
42.4k12 gold badges162 silver badges330 bronze badges
42.4k12 gold badges162 silver badges330 bronze badges
add a comment
|
add a comment
|
$begingroup$
tcsh, 12 bytes
xxd -r|wc -c
Try it online!
$endgroup$
add a comment
|
$begingroup$
tcsh, 12 bytes
xxd -r|wc -c
Try it online!
$endgroup$
add a comment
|
$begingroup$
tcsh, 12 bytes
xxd -r|wc -c
Try it online!
$endgroup$
tcsh, 12 bytes
xxd -r|wc -c
Try it online!
answered 8 hours ago
Krzysztof SzewczykKrzysztof Szewczyk
3,2901 gold badge9 silver badges23 bronze badges
3,2901 gold badge9 silver badges23 bronze badges
add a comment
|
add a comment
|
$begingroup$
Befunge-98 (FBBI), 16 bytes
"c- cw|r- dxx"=@
Try it online!
$endgroup$
add a comment
|
$begingroup$
Befunge-98 (FBBI), 16 bytes
"c- cw|r- dxx"=@
Try it online!
$endgroup$
add a comment
|
$begingroup$
Befunge-98 (FBBI), 16 bytes
"c- cw|r- dxx"=@
Try it online!
$endgroup$
Befunge-98 (FBBI), 16 bytes
"c- cw|r- dxx"=@
Try it online!
answered 8 hours ago
Krzysztof SzewczykKrzysztof Szewczyk
3,2901 gold badge9 silver badges23 bronze badges
3,2901 gold badge9 silver badges23 bronze badges
add a comment
|
add a comment
|
$begingroup$
05AB1E, 8 bytes
|εg51-}O
Try it online!
| get all input lines
ε for each line
g51- subtract 51 from length
}
O push the sum of the resulting list
$endgroup$
1
$begingroup$
Sorry, the input must contain the whole hexdump. (Yours skips the letters at the end of each line)
$endgroup$
– gadzooks02
9 hours ago
$begingroup$
Oh, my bad. I made this on my smartphone. Didn't see there's something behind the hex codes. I made a correction.
$endgroup$
– Dorian
8 hours ago
add a comment
|
$begingroup$
05AB1E, 8 bytes
|εg51-}O
Try it online!
| get all input lines
ε for each line
g51- subtract 51 from length
}
O push the sum of the resulting list
$endgroup$
1
$begingroup$
Sorry, the input must contain the whole hexdump. (Yours skips the letters at the end of each line)
$endgroup$
– gadzooks02
9 hours ago
$begingroup$
Oh, my bad. I made this on my smartphone. Didn't see there's something behind the hex codes. I made a correction.
$endgroup$
– Dorian
8 hours ago
add a comment
|
$begingroup$
05AB1E, 8 bytes
|εg51-}O
Try it online!
| get all input lines
ε for each line
g51- subtract 51 from length
}
O push the sum of the resulting list
$endgroup$
05AB1E, 8 bytes
|εg51-}O
Try it online!
| get all input lines
ε for each line
g51- subtract 51 from length
}
O push the sum of the resulting list
edited 8 hours ago
answered 9 hours ago
DorianDorian
1,1664 silver badges6 bronze badges
1,1664 silver badges6 bronze badges
1
$begingroup$
Sorry, the input must contain the whole hexdump. (Yours skips the letters at the end of each line)
$endgroup$
– gadzooks02
9 hours ago
$begingroup$
Oh, my bad. I made this on my smartphone. Didn't see there's something behind the hex codes. I made a correction.
$endgroup$
– Dorian
8 hours ago
add a comment
|
1
$begingroup$
Sorry, the input must contain the whole hexdump. (Yours skips the letters at the end of each line)
$endgroup$
– gadzooks02
9 hours ago
$begingroup$
Oh, my bad. I made this on my smartphone. Didn't see there's something behind the hex codes. I made a correction.
$endgroup$
– Dorian
8 hours ago
1
1
$begingroup$
Sorry, the input must contain the whole hexdump. (Yours skips the letters at the end of each line)
$endgroup$
– gadzooks02
9 hours ago
$begingroup$
Sorry, the input must contain the whole hexdump. (Yours skips the letters at the end of each line)
$endgroup$
– gadzooks02
9 hours ago
$begingroup$
Oh, my bad. I made this on my smartphone. Didn't see there's something behind the hex codes. I made a correction.
$endgroup$
– Dorian
8 hours ago
$begingroup$
Oh, my bad. I made this on my smartphone. Didn't see there's something behind the hex codes. I made a correction.
$endgroup$
– Dorian
8 hours ago
add a comment
|
$begingroup$
Japt -x
, 5 bytes
Input as an array of lines.
®Ê-51
Try it
®Ê-51 :Implicit input of array
® :Map
Ê : Length
-51 : Subtract 51
:Implicit output of sum of resulting array
$endgroup$
$begingroup$
An explanation would be nice :)
$endgroup$
– gadzooks02
8 hours ago
$begingroup$
Coming soon, @gadzooks02. But it's the same as the Jelly solution.
$endgroup$
– Shaggy
8 hours ago
$begingroup$
@gadzooks02, explanation added.
$endgroup$
– Shaggy
7 hours ago
add a comment
|
$begingroup$
Japt -x
, 5 bytes
Input as an array of lines.
®Ê-51
Try it
®Ê-51 :Implicit input of array
® :Map
Ê : Length
-51 : Subtract 51
:Implicit output of sum of resulting array
$endgroup$
$begingroup$
An explanation would be nice :)
$endgroup$
– gadzooks02
8 hours ago
$begingroup$
Coming soon, @gadzooks02. But it's the same as the Jelly solution.
$endgroup$
– Shaggy
8 hours ago
$begingroup$
@gadzooks02, explanation added.
$endgroup$
– Shaggy
7 hours ago
add a comment
|
$begingroup$
Japt -x
, 5 bytes
Input as an array of lines.
®Ê-51
Try it
®Ê-51 :Implicit input of array
® :Map
Ê : Length
-51 : Subtract 51
:Implicit output of sum of resulting array
$endgroup$
Japt -x
, 5 bytes
Input as an array of lines.
®Ê-51
Try it
®Ê-51 :Implicit input of array
® :Map
Ê : Length
-51 : Subtract 51
:Implicit output of sum of resulting array
edited 7 hours ago
answered 8 hours ago
ShaggyShaggy
22.1k3 gold badges21 silver badges73 bronze badges
22.1k3 gold badges21 silver badges73 bronze badges
$begingroup$
An explanation would be nice :)
$endgroup$
– gadzooks02
8 hours ago
$begingroup$
Coming soon, @gadzooks02. But it's the same as the Jelly solution.
$endgroup$
– Shaggy
8 hours ago
$begingroup$
@gadzooks02, explanation added.
$endgroup$
– Shaggy
7 hours ago
add a comment
|
$begingroup$
An explanation would be nice :)
$endgroup$
– gadzooks02
8 hours ago
$begingroup$
Coming soon, @gadzooks02. But it's the same as the Jelly solution.
$endgroup$
– Shaggy
8 hours ago
$begingroup$
@gadzooks02, explanation added.
$endgroup$
– Shaggy
7 hours ago
$begingroup$
An explanation would be nice :)
$endgroup$
– gadzooks02
8 hours ago
$begingroup$
An explanation would be nice :)
$endgroup$
– gadzooks02
8 hours ago
$begingroup$
Coming soon, @gadzooks02. But it's the same as the Jelly solution.
$endgroup$
– Shaggy
8 hours ago
$begingroup$
Coming soon, @gadzooks02. But it's the same as the Jelly solution.
$endgroup$
– Shaggy
8 hours ago
$begingroup$
@gadzooks02, explanation added.
$endgroup$
– Shaggy
7 hours ago
$begingroup$
@gadzooks02, explanation added.
$endgroup$
– Shaggy
7 hours ago
add a comment
|
$begingroup$
Red, 81 bytes
func[s][n: 0 try[foreach l s[n: n + length? trim/all at take/part l 49 10]]n / 2]
Try it online!
$endgroup$
add a comment
|
$begingroup$
Red, 81 bytes
func[s][n: 0 try[foreach l s[n: n + length? trim/all at take/part l 49 10]]n / 2]
Try it online!
$endgroup$
add a comment
|
$begingroup$
Red, 81 bytes
func[s][n: 0 try[foreach l s[n: n + length? trim/all at take/part l 49 10]]n / 2]
Try it online!
$endgroup$
Red, 81 bytes
func[s][n: 0 try[foreach l s[n: n + length? trim/all at take/part l 49 10]]n / 2]
Try it online!
answered 7 hours ago
Galen IvanovGalen Ivanov
9,7571 gold badge14 silver badges41 bronze badges
9,7571 gold badge14 silver badges41 bronze badges
add a comment
|
add a comment
|
$begingroup$
C (gcc), 64 bytes
s[];f(r,l)r=0;while(*s=0,gets(s),l=strlen(s))r+=l-51;return r;
Try it online!
$endgroup$
$begingroup$
You could usefor
.
$endgroup$
– Jonathan Frech
5 hours ago
$begingroup$
Also,s[]
seems to me to be unstable undefined behaviour.
$endgroup$
– Jonathan Frech
5 hours ago
add a comment
|
$begingroup$
C (gcc), 64 bytes
s[];f(r,l)r=0;while(*s=0,gets(s),l=strlen(s))r+=l-51;return r;
Try it online!
$endgroup$
$begingroup$
You could usefor
.
$endgroup$
– Jonathan Frech
5 hours ago
$begingroup$
Also,s[]
seems to me to be unstable undefined behaviour.
$endgroup$
– Jonathan Frech
5 hours ago
add a comment
|
$begingroup$
C (gcc), 64 bytes
s[];f(r,l)r=0;while(*s=0,gets(s),l=strlen(s))r+=l-51;return r;
Try it online!
$endgroup$
C (gcc), 64 bytes
s[];f(r,l)r=0;while(*s=0,gets(s),l=strlen(s))r+=l-51;return r;
Try it online!
answered 5 hours ago
G. SliepenG. Sliepen
5202 silver badges6 bronze badges
5202 silver badges6 bronze badges
$begingroup$
You could usefor
.
$endgroup$
– Jonathan Frech
5 hours ago
$begingroup$
Also,s[]
seems to me to be unstable undefined behaviour.
$endgroup$
– Jonathan Frech
5 hours ago
add a comment
|
$begingroup$
You could usefor
.
$endgroup$
– Jonathan Frech
5 hours ago
$begingroup$
Also,s[]
seems to me to be unstable undefined behaviour.
$endgroup$
– Jonathan Frech
5 hours ago
$begingroup$
You could use
for
.$endgroup$
– Jonathan Frech
5 hours ago
$begingroup$
You could use
for
.$endgroup$
– Jonathan Frech
5 hours ago
$begingroup$
Also,
s[]
seems to me to be unstable undefined behaviour.$endgroup$
– Jonathan Frech
5 hours ago
$begingroup$
Also,
s[]
seems to me to be unstable undefined behaviour.$endgroup$
– Jonathan Frech
5 hours ago
add a comment
|
$begingroup$
Python 3, 48 bytes
f=lambda s:(len(s)or 51)+1-52*len(s.split('n'))
Input is passed as a string to the function f
. The function increments the length of the input (including newlines), then subtracts 52 for each line.
Try it online
$endgroup$
add a comment
|
$begingroup$
Python 3, 48 bytes
f=lambda s:(len(s)or 51)+1-52*len(s.split('n'))
Input is passed as a string to the function f
. The function increments the length of the input (including newlines), then subtracts 52 for each line.
Try it online
$endgroup$
add a comment
|
$begingroup$
Python 3, 48 bytes
f=lambda s:(len(s)or 51)+1-52*len(s.split('n'))
Input is passed as a string to the function f
. The function increments the length of the input (including newlines), then subtracts 52 for each line.
Try it online
$endgroup$
Python 3, 48 bytes
f=lambda s:(len(s)or 51)+1-52*len(s.split('n'))
Input is passed as a string to the function f
. The function increments the length of the input (including newlines), then subtracts 52 for each line.
Try it online
answered 4 hours ago
IFcoltransGIFcoltransG
113 bronze badges
113 bronze badges
add a comment
|
add a comment
|
$begingroup$
JavaScript (ES6), 34 bytes
s=>(n=s.length)&&(n/68<<4)+n%68-51
Try it online!
Commented
s => // s = input string
(n = s.length) && // n = length of s; return 0 right away if n = 0 (special case)
(n / 68 << 4) + // otherwise compute the number of full lines and multiply it by 16
n % 68 - 51 // add the length of the last line minus 51
$endgroup$
add a comment
|
$begingroup$
JavaScript (ES6), 34 bytes
s=>(n=s.length)&&(n/68<<4)+n%68-51
Try it online!
Commented
s => // s = input string
(n = s.length) && // n = length of s; return 0 right away if n = 0 (special case)
(n / 68 << 4) + // otherwise compute the number of full lines and multiply it by 16
n % 68 - 51 // add the length of the last line minus 51
$endgroup$
add a comment
|
$begingroup$
JavaScript (ES6), 34 bytes
s=>(n=s.length)&&(n/68<<4)+n%68-51
Try it online!
Commented
s => // s = input string
(n = s.length) && // n = length of s; return 0 right away if n = 0 (special case)
(n / 68 << 4) + // otherwise compute the number of full lines and multiply it by 16
n % 68 - 51 // add the length of the last line minus 51
$endgroup$
JavaScript (ES6), 34 bytes
s=>(n=s.length)&&(n/68<<4)+n%68-51
Try it online!
Commented
s => // s = input string
(n = s.length) && // n = length of s; return 0 right away if n = 0 (special case)
(n / 68 << 4) + // otherwise compute the number of full lines and multiply it by 16
n % 68 - 51 // add the length of the last line minus 51
edited 2 hours ago
answered 5 hours ago
ArnauldArnauld
94.6k7 gold badges111 silver badges384 bronze badges
94.6k7 gold badges111 silver badges384 bronze badges
add a comment
|
add a comment
|
$begingroup$
Retina 0.8.2, 8 bytes
.51
.
Try it online! Explanation:
.51
Delete the first 51 characters of each line. (Lines can only have between 52 and 67 characters, so this always matches once per line.)
.
Count the remaining non-newline characters.
$endgroup$
add a comment
|
$begingroup$
Retina 0.8.2, 8 bytes
.51
.
Try it online! Explanation:
.51
Delete the first 51 characters of each line. (Lines can only have between 52 and 67 characters, so this always matches once per line.)
.
Count the remaining non-newline characters.
$endgroup$
add a comment
|
$begingroup$
Retina 0.8.2, 8 bytes
.51
.
Try it online! Explanation:
.51
Delete the first 51 characters of each line. (Lines can only have between 52 and 67 characters, so this always matches once per line.)
.
Count the remaining non-newline characters.
$endgroup$
Retina 0.8.2, 8 bytes
.51
.
Try it online! Explanation:
.51
Delete the first 51 characters of each line. (Lines can only have between 52 and 67 characters, so this always matches once per line.)
.
Count the remaining non-newline characters.
answered 2 hours ago
NeilNeil
89.7k8 gold badges46 silver badges188 bronze badges
89.7k8 gold badges46 silver badges188 bronze badges
add a comment
|
add a comment
|
$begingroup$
Perl 6, 18 bytes
.join.comb-51*$_
Try it online!
Anonymous Whatever lambda that takes a list of lines and returns the sum of the number of characters, subtracting 51 for each line
$endgroup$
add a comment
|
$begingroup$
Perl 6, 18 bytes
.join.comb-51*$_
Try it online!
Anonymous Whatever lambda that takes a list of lines and returns the sum of the number of characters, subtracting 51 for each line
$endgroup$
add a comment
|
$begingroup$
Perl 6, 18 bytes
.join.comb-51*$_
Try it online!
Anonymous Whatever lambda that takes a list of lines and returns the sum of the number of characters, subtracting 51 for each line
$endgroup$
Perl 6, 18 bytes
.join.comb-51*$_
Try it online!
Anonymous Whatever lambda that takes a list of lines and returns the sum of the number of characters, subtracting 51 for each line
edited 27 mins ago
answered 34 mins ago
Jo KingJo King
32.6k4 gold badges73 silver badges142 bronze badges
32.6k4 gold badges73 silver badges142 bronze badges
add a comment
|
add a comment
|
If this is an answer to a challenge…
…Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.
…Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
Explanations of your answer make it more interesting to read and are very much encouraged.…Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.
More generally…
…Please make sure to answer the question and provide sufficient detail.
…Avoid asking for help, clarification or responding to other answers (use comments instead).
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f194040%2fcode-golf-measurer-2019%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
$begingroup$
May we assume the input is ascii? Can it contain control characters? What are the input rules? Some languages can't handle input over multiple lines. Can we pad the last line so that all lines are equally long? Why include the blank input?
$endgroup$
– Stewie Griffin
9 hours ago
$begingroup$
@StewieGriffin Yes; no; yes; because if
xxd
is fed an empty string, it outputs nothing.$endgroup$
– gadzooks02
9 hours ago
$begingroup$
@StewieGriffin You edited your comment while I was answering, so here's an expansion: Yes; No; it can be input however you want, provided the whole dump is included; See last answer; Yes; Because if xxd is fed an empty string, it outputs nothing
$endgroup$
– gadzooks02
9 hours ago
1
$begingroup$
@JonathanAllan Oh yes, well spotted.
$endgroup$
– gadzooks02
8 hours ago