New answers tagged parsing
2
votes
What's the character limit of this text field?
Python 3, 55 bytes
lambda s:"".join(map(str,range(1,1001))).find(s)+len(s)
This is a rather simple solution, but it works.
1
vote
3
votes
What's the character limit of this text field?
Charcoal, 10 bytes
I⁺Lθ⌕⭆φ⊕ιθ
Try it online! Link is to verbose version of code. Explanation:
...
2
votes
What's the character limit of this text field?
APL (Dyalog Classic), 22 bytes
≢-1-(⊃∘⍸⍷∘(⊃,/⍕¨⍳1E3))
Try it online!
...
2
votes
What's the character limit of this text field?
Pip, 10 bytes
Semi-port of lyxal's Vyxal answer
J1,a~:Xa$)
Attempt This Online!
...
3
votes
What's the character limit of this text field?
APL+WIN, 35 33 bytes
Two bytes saved thanks to Tbw
Prompts for string of digits:
↑(¯1+⍴s)+((s←,⎕)⍷n)/⍳⍴n←⊃,/⍕¨⍳1E3
Try it online! Thanks to Dyalog Classic
4
votes
What's the character limit of this text field?
Haskell, 65 63 bytes
-2 bytes thanks to @AZTECCO
n%h|l<-length n,n==take l h=l
n%(_:h)=1+n%h
f=(%([1..]>>=show))
Try it online!
4
votes
What's the character limit of this text field?
Perl 5 (-p), 27 bytes
(join"",1..1e3)=~$_;$_="@+"
Try it online!
6
votes
What's the character limit of this text field?
Excel (ms365)
1) Recursion with LAMBDA(), 74 bytes:
Formula in B1:
...
3
votes
What's the character limit of this text field?
Retina 0.8.2, 38 bytes
^
1001$*1¶
\G1
$.`
r`\B\1.*¶(.*)
$1
\B
Try it online! Link includes test cases. Explanation:
...
5
votes
What's the character limit of this text field?
Ruby, 34 30 bytes
->i{[*1..1e3]*''=~/(?<=#{i})/}
Try it online!
Thanks to @Neil for saving 1 Byte by removing useless + in regexp
Regexp /(?<=#{i})+/ ...
5
votes
What's the character limit of this text field?
05AB1E, 7 bytes
LJIkIg+
Times out for larger inputs. Add a leading ₄ (push 1000) to speed it up.
Try it online or verify all ...
5
votes
What's the character limit of this text field?
JavaScript (Node.js), 43 bytes
x=>~(g=s=>~s.indexOf(x,1)||g(s+i++))(x,i=1)
Try it online!
Using range, fail 11 (expect ...
5
votes
What's the character limit of this text field?
Vyxal, 50 bitsv2, 6.25 bytes
⌊ɾṅḟ?L+
Try it Online!
Bitstring:
11001011010011010000000111000101111000110100000010
Times out ...
3
votes
Parse nested absolute values
05AB1E, 13 bytes
ε'|Qižu®dèëy©
Port of @Neil's Charcoal answer, so make sure to upvote that answer as well!
Outputs as a list of characters.
Try it online or ...
3
votes
Parse nested absolute values
JavaScript (Node.js), 44 bytes
s=>s.replace(d=/./g,c=>c>{}?++d?')':'(':d=c)
Try it online!
Look last non-pipe character before each pipe. Converting pipe ...
3
votes
Parse nested absolute values
Charcoal, 16 bytes
FS≡ι|§)(‹ψ0«ι≔ιψ
Try it online! Link is to verbose version of code. Explanation:
FS≡ι
Loop over the input ...
5
votes
Parse nested absolute values
K (ngn/k), 27 22 bytes
Based on Arnauld's answer, but without regex.
{`c$(84-0=\"0|"'x)!'x}
Try it online!
Any closing parenthesis in the output directly ...
1
vote
Parse nested absolute values 2
JavaScript (ES6), 52 bytes
I believe my answer to the other version also works for this one... ¯\_(ツ)_/¯
...
Community wiki
7
votes
Parse nested absolute values
Retina 0.8.2, 22 16 bytes
T`|`)`\d\|+
\|
(
Try it online! Link includes test cases. Explanation:
T`|`)`\d\|+
Replace all ...
9
votes
Parse nested absolute values
JavaScript (ES6), 52 bytes
f=s=>s>(s=s.replace(/\|(.*?[\d)])\|/,"($1)"))?f(s):s
Try it online!
Method
At each iteration, we look for the first ...
2
votes
Ungolf the Wind
Perl 5 -n, 59 bytes
/ (...)(..)G?(..)?KT/;say for$1eq VRB?-1:$1*1,$2*1,$3*1||-1
Try it online!
3
votes
Ungolf the Wind
05AB1E, 13 bytes
#3è3ô3£εþ®s‚à
Try it online or verify all test cases.
Explanation:
...
1
vote
Ungolf the Wind
sclin, 33 bytes
w<>3:3/`3tk"\D"""\ /#1_.||# map N
Try it on scline!
Explanation
Prettified code:
...
2
votes
Ungolf the Wind
Python3, 104 bytes
lambda s:((-1 if'VRB'in(s:=s.split()[3])else s[:3]),s[3:5],s[(i:=s.index('G'))+1:i+3]if'G'in s else -1)
Try it online!
Another approach (much ...
3
votes
Ungolf the Wind
sed -E, 81 75 bytes
-6 bytes thanks to @Jordan
s/.{19}(...)(..)(G(..))?.*/ \1 \2 \4/;s/ VRB| $/ -1/g;s/ 0*(\w)/ \1/g;s/ //
Attempt This Online!
4
votes
Ungolf the Wind
JavaScript, 54 45 bytes
s=>[19,22,25].map(x=>~(-1-s.substr(x,x/7^1)))
Try it online!
−9 by using indices directly in the input string and the (deprecated) <...
5
votes
Ungolf the Wind
Charcoal, 17 16 15 bytes
…IE⪪ε³⁻Σ⁺ψι›ια³
Try it online! Link is to verbose version of code. Explanation:
...
5
votes
Ungolf the Wind
Jelly, 18 15 bytes
Ḳ4ịs3ḣ3f€ØDȯ€-V
Try it online!
A monadic link taking a METAR-formatted string and returning a list of integers. (Has the side effect of ...
4
votes
Ungolf the Wind
Retina 0.8.2, 39 bytes
4=M!`\w+
3M!`.{1,3}
%(`\D
^0+\B
^$
-1
Try it online! Outputs the values on separate lines but link is to test suite that joins on commas ...
2
votes
Ungolf the Wind
Uiua 0.4.1, 80 bytes
⊐∵parse≡(⊂⊂∩□⊃((∘|"¯1")≍"VRB"⊔.↙3|⊃↙(□↘+1)⊗@G.(⊂:"G¯1"|∘)∊@G.↙-2⧻.↘3)⊔⊡3⊜□≠@ .⊔)
See it in action
5
votes
Ungolf the Wind
Google Sheets, 80 bytes
={iferror(--mid(A1,20,3),-1),mid(A1,23,2),ifna(--regexextract(A1,"G(\d\d)"),-1)}
Put the input in cell ...
Top 50 recent answers are included
Related Tags
parsing × 255code-golf × 237
string × 116
decision-problem × 19
ascii-art × 17
math × 14
number × 14
internet × 13
balanced-string × 13
arithmetic × 10
natural-language × 8
code-challenge × 7
regular-expression × 7
syntax × 6
sequence × 5
conversion × 5
c × 5
apl × 5
popularity-contest × 4
interpreter × 4
rational-numbers × 4
unicode × 4
classification × 4
array × 4
integer × 3