« first day (3089 days earlier)      last day (63 days later) » 

12:43 AM
0
Q: Output Ordinal Numbers up to n

BDM ...Ordinal numbers (or ordinal numerals) are words representing position or rank in a sequential order. From Wikipedia. Your task is, using 2 separate programs, to output the ordinal sequence from first to nth. You will be outputting the full word second as opposed to 2nd. The challenge ...

 
1:16 AM
@EriktheOutgolfer Pinging NewMainPosts won't notify the challenge author
@JohnDvorak No CGCCLang. Only PPCGLang
 
 
6 hours later…
7:16 AM
@MilkyWay90 yeah I don't really intend to, especially if I'm about to sleep... ;P
 
 
1 hour later…
8:42 AM
0
Q: Symbolic solver

he77789First time poster here. Feel free to suggest edits. Challenge: make a symbolic solver for equations. Required symbols to be recognized are: + - * / = ^ ( ) single-letter variables and numbers The program should take the equation(s) with standard input, 1 line for each equation. A lone = signifie...

 
9:42 AM
-1
Q: Java.. write file size 4 KB. Actual file size is 942 MB. Read/Write binary files

Nitesh RathiI'm reading a file and writing it. but file is not proper read and write it's contents. File read/write size is 942 MB. and it's read and write 4 KB. Why it's happening? Here is my read and write function. static void readfile() throws Exception { String filepath = "C:\\Users\\Nitesh Rathi\\...

 
10:20 AM
@NewMainPosts Our "Ask Question" and "Post Your Question" buttons should say "Create Competition" and "Launch Competition".
 
10:43 AM
@Adám What about
 
@ExpiredData I know, but those that know about them know about them.
 
11:22 AM
0
Q: making nested arrays flat

bvdbThis challenge is about merging arrays, creating one big flat array. However, the input arrays are nested inside an object with child objects. Here is what the input looks like: const o = { element1: { arr: ['a']} element2: { arr: ['b']} element33: { arr: ['c1', 'c2', 3]} }; And the oup...

 
11:37 AM
@NewMainPosts CMC for languages with objects/locales/namespaces/dictionaries… like JSON's objects: Given such a thing, return a flat list of all data contained therein, in any order. E.g.{"a":"abc","b":[1,2,3],"c":{"d":[],"e":["def",[4,5,6]]}}["abc",1,2,3,"def",4,5,6] or if your language treats strings as character arrays: ['a','b','c',1,2,3,'d','e','f',4,5,6]
Alternative CMC to the above: Given an object, recursively replace all objects with a list of their member values: {"a":"abc","b":[1,2,3],"c":{"d":[],"e":["def",[4,5,6]]}}["abc",[1,2,3],[[],["def",[4,5,6]]]]
 
@Adám tfw APL is out of luck
 
11:52 AM
@EriktheOutgolfer Not at all. I've got 29.
 
@Adám oof? :D what input format are you using?
 
@EriktheOutgolfer a namespace.
 
@Adám yeah... not sure where in ⎕SE there's a way to dump a namespace's contents :D
 
28 now
@EriktheOutgolfer What?
 
@Adám fancy way to say "where in the world"
 
11:57 AM
@EriktheOutgolfer Just take the JSON and feed it to ⎕JSON. The result is a scalar. That's the argument for the solution function.
 
f=->a{case a when Array;a.map(&f)when Hash; f[a.values]else a end}
flat_map for the first version
when String;f[a.chars] to decompose strings
 
Ruby got some nice built-ins over there...
 
12:17 PM
@EriktheOutgolfer Any luck with APL? Want to see mine?
 
@Adám hm, maybe, because, AFAIK, ⎕JSON creates a namespace :D
that is, unless you put an ⍠'M' to it, in which case it creates a matrix instead
 
@EriktheOutgolfer Sure, then when you have a namespace, just unpack its members' contents.
 
@Adám yeah, the "its members" part isn't that obvious
 
@EriktheOutgolfer ⎕NL (Name List)
 
@Adám oh so I have to do something like ⍵.⎕NL 2?
 
12:30 PM
@EriktheOutgolfer Yes. And don't forget 9.
 
@Adám oh yeah otherwise my solution would slack off lol
 
@EriktheOutgolfer I'm down to 22/21 now for 1st and 2nd CMC.
 
damn can't ⎕CS in dfn nonce error
 
@EriktheOutgolfer You don't need to. Just dot into the ns.
 
12:54 PM
@Adám was away for a bit, but... that would eat bytes...
like, ⍵.⍎¨⍵.⎕NL 2 9 vs. ⍎¨⎕NL 2 9
 
1:09 PM
@Adám hm, do you have {0::⍵⋄∊∇¨⍵.⍎¨⍵.⎕NL 2 9}?
 
 
2 hours later…
3:03 PM
0
A: Sandbox for Proposed Challenges

bigyihsuanAlphanumeric Line and Curve Counting Given an input string, output the number of lines and curves it has. The Challenge Take input from STDIN. Output to STDOUT the number of lines and curves contained in the string, based on the below table. Any non-alphanumeric characters should be ignored. ...

 
3:23 PM
0
A: Sandbox for Proposed Challenges

JordanComplete the grid-filling meander code-golf grid A grid-filling meander is a closed path that visits every cell of a square 𝑁×𝑁 grid at least once, never crosses any edge between adjacent cells more than once, and never crosses itself. For example: We can also think of this as an arrange...

 
4:01 PM
1
Q: A scene of Jimmy diversity

connectyourchargerAs you probably know, there have been multiple lovely Jimmy challenges recently popping up. In these challenges, you were challenged with our beloved friend's acrobatics skills. Now we've got a different challenge for you. Today you will be identifying different types of Jimmys! Explanation T...

 
4:27 PM
1
Q: The Jimmydex: an index of all Jimmy questions

connectyourchargerI present to you the Jimmydex, an index of all Jimmy questions on CodeGolf.SE. A Jimmy question is a question about Jimmy (/o\) or his varieties. Usually, Jimmy questions are related to either ASCII parsing or about Jimmy's acrobatics skills. If you post a new Jimmy question, you are encouraged...

 
4:41 PM
0
Q: MQTT subscription topic match

PatrickBackground MQTT (Message Queuing Telemetry Transport) is an ISO standard publish-subscribe-based messaging protocol (Wikipedia). Each message has a topic, such as the following examples: myhome/groundfloor/livingroom/temperature USA/California/San Francisco/Silicon Valley 5ff4a2ce-e485-40f4-8...

posted on July 15, 2019 by Dhrumil Gada

There are two text files on the server which contatin list like salary.txt and bonus.txt. You have to merge both file data and output like name + total(Salary+Bonus).

 
 
1 hour later…
5:56 PM
@NewMetaPosts As someone whose IRL name is Jimmy, reading this post feels very strange.
 
6:10 PM
CMC Given a sorted array of numbers and a query value, return the index of the value in the array closest to the query in absolute value
2
 
@Anush so [1,2,9,3] and 8 gives 2 (0-indexed)? What if there are multiple such indexes?
 
@dzaima yes. If there are multiple, any of them will be correct
I should really insist it runs in O(log n) time :)
 
@Anush aw, i was just about to answer with 9 bytes (and completely forgot about sortedness). i wonder at what array size does an O(log n) algorithm become faster than O(n) in Dyalog APL
 
@dzaima great question
!
 
6:25 PM
oh wait no, that doesn't find closest but just which interval
 
yes that's why it's a little fiddly
hence why I asked :)
[1,3,4,9] and 11 should return 3 and [1,2,4,9] with question 0 should return 0
 
also currently isn't O(log n) for no particular reason (but that should change in the next Dyalog version as I've heard)
 
6:38 PM
@EriktheOutgolfer Almost. ⎕NL 2 9 won't work, as it returns a matrix. You need at least one negative number. -⍳9 works. Less eachy: {0::⍵⋄∊⍵.(∇∘⍎¨⎕NL)-⍳9} I actually had outside the braces, so you only apply it once.
 
@Adám huh? how did it work for me then...?
 
@EriktheOutgolfer Because you only used 1-letter names.
 
@Adám oh yeah lol
 
@EriktheOutgolfer I didn't think of it when I posted the challenge (I hadn't solved it myself). I hope you had fun.
 
@Adám because natural behavior would be for ⎕NL to only return vectors, never matrices :D
unless there's some backwards compatibility issue relating to ancient times
 
6:43 PM
@EriktheOutgolfer Exactly. There were no nested arrays.
 
if eventTimes is a list of lists, is there a more succinct way to write bpaste.net/show/1E8z ?
 
@Anush Do we have to handle one-element lists?
 
@wastl yes!
 
7:02 PM
@Anush here's an awful 63 bytes implementing binary search and doing that little modification. recursion would probably help but ¯\_(ツ)_/¯
 
@dzaima Yikes. OK, now I have to try that.
 
@dzaima It's almost as long as bpaste.net/show/yawy :)
 
@Anush but that uses a search built-in (or at least it looks like so) :p
 
it does!
 
@Anush In C, would it be OK to return the pointer to the element (list + index)?
 
7:08 PM
why not
 
In C, array + 1 is still an array, unless that array was empty, in which case the compiler sets your PC on fire.
 
pointer != array
 
I don't think C has arrays as such
 
It has, but they quickly decay into pointers
 
In C, `sizeof(ary)` produces:
a) the number of elements in the array
b) the number of elements in the array multiplied by the size of each element
c) just the size of the first element of the array
d) always 4
 
7:17 PM
b
 
@Anush Hold on, so the sorted array could be [-2,0,1] and the number 3 and then we have to return the index of -2?
 
@JohnDvorak worth noting you've left the definition of the array out of the question
stack vs heap yields different answers
 
O_o
 
cause malloc returns a pointer to an array on the heap
 
No, pointer vs array gives different answers
 
7:20 PM
so sizeof is going to act differently
 
And yet they look the same in code
 
typically in C you pass the length of an array around as a separate parameter
 
results are in - at around 40000 items (just 0..39999, searching for 20000) is the point when binary search becomes better than linear..
https://tio.run/##zZLNSsNAEMfvPsVQEFJqNpuvWi/FHswj9CI9hGLBQ3rwI5c0J6VobEQE0XO9eOuh9NJjfZN5kTi7bpDUIgQh7bIw7M7kn5nff/v@MPQvswzkGuD4ScNkiukcJ4lRx7u3kb73nfMoF/kQUsB0AfhwC5rWNkRJqEd0dYrpshfT2a9jckMq9SgQxZOEM/fztWHknwXHWtgOqEYU0r8WMabvkdXWRUXMDzD9WM3MBt5P/ZiEl@JWNaFCRzYxNznnUrFLZ5dzle1dXA@vzoMz0PtQ68AAujURPYqq4l@LNKQo4PgZTGafrGZNGMkU3wd8fKFdRspTUhZrkZRLUg2LJsulqt@ird@gC6SrQV0g7Uo8ivRGOmWB2@wwB@46u8e7CLwS4mtP2yQ8jgS@ZTo/njnMUZ7pTbN8U39NvsmCNQ@2YYJ49fZumeAynptw1J
 
@Adám No. It should return the index of 1
 
array declaration: `int a[5];`
pointer declaration: `int *a;`
 
7:22 PM
@Anush But -2 is closer to 3 in absolute value.
 
@Adám absolute of the difference
 
@Adám sorry my English use was poor. I meant |x-y|
as @dzaima said
 
@JohnDvorak e) sizeof(type)*len(ary) for stack-allocated arrays, and sizeof(ptr) for heap-allocated arrays.
 
I rest my case
 
@dzaima Isn't {i+>/|⍵-⍺[1⌈(≢⍺)⌊0 1+i←+/⍺<⍵]} then an O(n) solution?
 
7:25 PM
Sonofagun. Was wondering why field wasn't matching. I was matching against UpdateTime instead of UpdateType
Never skim auto-suggest
 
@Veskah Let me guess: stringly-typed codebase?
 
SNMP trap fields actually. So technically not my fault
 
So it's b) for stack-allocated arrays, and sort-of-d) for heap-allocated (assuming sizeof(void*) == 4, which is the norm for 32-bit)
 
@Adám fails for (,4) f 6, but otherwise, probably
 
@dzaima Uh, in what way does it fail? I get the index of 4, which is correct.
 
7:28 PM
@Mego who is on a 32bit machine anymore
 
@Adám sorry, got indexing wrong, (,4) f 0 is the wrong one
 
I think even when I was on XP SP3 it was 64bit
 
@Poke You don't need a 32-bit machine; just a 32-bit toolset or targetting a 32-bit arch
 
@Mego fair enough
 
@dzaima or (1 2 4 9) f 0
 
7:29 PM
Also: governments
 
/shudder
 
Hey, pay 30 million to update or pay 20 million to put off updating for another year
ez choice
 
@dzaima {i+>/|⍵-⍺[(≢⍺)⌊0 1+i←1⌈+/⍺<⍵]}
I suppose we can assume the array will have at least one element.
 
Anything funded by taxpayers that doesn't involve shooting rockets into space or at other countries will be using tech that is at least 7 years old (if you're using 7-yr-old tech, be grateful).
Also sometimes the tech used by people who do deal with shooting rockets is that old
 
@Adám yeah, but now the challenge is to make that O(log n)
 
7:31 PM
I am pleased my CMC has been so challenging :)
 
@dzaima That should be possible just by optimising as you said.
 
hmm, now to come up with a cmc requiring O(log n) that isn't solvable by an optimized
 
I'm using hardware whose manual has last been updated 2000 years ago
 
@Mego Actually, I think most tech used for rockets is more than 7 years old.
@JohnDvorak The world?
 
yep
 
7:35 PM
@JohnDvorak I can't imagine your pain. Two years ago I had to use a java library that had a very extensive and comprehensive documentation. The docs were last updated in 2001, while the library had been updated like two weeks before I started using it.
 
HOOD = hopelessly out of date?
 
@JohnDvorak Reading it in translation?
 
yep. At least I get to cross-check the results of several translations if one version is unclear.
 
@Adám I mean the computers that the people are using to shoot the rockets
 
@Mego Yeah, those are generally quite old.
 
7:37 PM
Although I do suspect I'll have to learn ancient Hebrew one day in any case...
 
@JohnDvorak I can highly recommend the original.
 
Sure, but sometimes you can get lucky and get newer stuff
 
@Mego … which turns to rocket the wrong way. ;-)
 
... I suppose this isn't the place to complain about the complete lack of vowels in the entire book, is it?
 
@JohnDvorak Oh the vowels are well-known. All prints have them.
 
7:40 PM
All the vowels are known. Except for the single most important word of the whole thing.
 
@JohnDvorak The vowels usually are not meaning bearing, and even if they are, the meaning is also clear from context. The meaning of that particular word is crystal clear without vowels.
 
true
 
And the lord doth spake print "hello world"
 
@Veskah More like: And the LORD said: "Hello, World!" and the world hello'd.
 
7:44 PM
@wastl cool :)
I am confused by some code I am trying to write in python. Would anyone be so kind as to help please? I have two lists. A = [5.804935579035303, 6.598872027092228, 7.699655014544808, 13.535884265996081, 18.103902543082636, 25.73045224653407, 26.443008779598518, 30.770890079462873, 30.945138002962352, 33.68521510274317, 38.68960990841763, 38.86934051984918, 39.233620264959455] say and B = [9.066903081818452, 13.549475014698913, 22.545810608250004, 32.39993986570819, 40.6584075641021, 43.28976745379393, 47.974499655592616, 54.271100532622064, 60.33079623100712, 63.080277524869594]
I want to make a list of lists from A using B. Every list should end with a different value from B and include all the values in A between that B value and the one before
it is making my head hurt!
 
[[*a, b] for b, a in itertools.groupby(A, lambda x: next(filter(lambda y: y >= x, B)))]
@Anush using itertools
assuming B is sorted
 
@wastl oh wow! Let me try that
 
Alternatively, no imports: [*filter(None,[[x for x in A if y<=x<B[i+1]]+B[i:i+1]for i,y in enumerate([0,*B[:-1]])])]
 
that is completely brilliant. Just one small thing. Take:
A = [5.8, 6.5, 7.6, 14.5, 18.1, 25.7, 26.4, 30.7, 30.9, 33.6, 38.6, 38.8, 39.2]
B = [9.0, 13.5, 22.5, 32.3, 40.6, 43.2, 47.9, 54.2, 60.3, 63.0]
 
But this smells like homework
 
7:57 PM
@wastl it gives the output [[5.8, 6.5, 7.6, 9.0],
[14.5, 18.1, 22.5],
[25.7, 26.4, 30.7, 30.9, 32.3],
[33.6, 38.6, 38.8, 39.2, 40.6]]
it is missing all the singleton lists
@Mego not homework! :)
 
Since you didn't specify, I'm assuming the conditions are B[i]<=x<B[i+1]
 
the output should be
[[5.8, 6.5, 7.6, 9.0], [13.5], [14.5, 18.1, 22.5], [25.7, 26.4, 30.7. 30.9, 32.3]....]
 
I always forget that chained comparisons are a thing in python
 
@Mego your code gives the wrong answer currently
[[5.8, 6.5, 7.6, 9.0],
[14.5, 18.1, 13.5],
[14.5, 18.1, 25.7, 26.4, 30.7, 30.9, 22.5],
[25.7, 26.4, 30.7, 30.9, 33.6, 38.6, 38.8, 39.2, 32.3],
[33.6, 38.6, 38.8, 39.2, 40.6],
[43.2],
[47.9],
[54.2],
[60.3],
[63.0]]
 
Getting even more inefficient: [[*a] for b, a in itertools.groupby(sorted(A + B), lambda x: next(filter(lambda y: y >= x, B)))]
 
8:02 PM
@wastl gives the right answer! I actually want to use the code
so faster is better .. but this is a great start. Thank you
 
8:16 PM
@wastl how about if I want to subtract the biggest number in the last list from the subsequent list?
 
You mean something like result[i][-1] - result[i-1][-1]?
 
@AdmBorkBork only now noticed this, but Canvas, 6 bytes
 
@Anush I'm not sure I understand you correctly
 
@wastl let me be clearer. The second list should be [4.5]. The third list should be [1, 4.6, 9.0]
 
@Anush for what input?
 
8:21 PM
A = [5.8, 6.5, 7.6, 14.5, 18.1, 25.7, 26.4, 30.7, 30.9, 33.6, 38.6, 38.8, 39.2]

B = [9.0, 13.5, 22.5, 32.3 40.6, 43.2, 47.9, 54.2, 60.3, 63.0]
the output should be [[5.8, 6.5, 7.6, 9.0], [4.5], [1, 4.6, 9.0]....]
 
@Anush [[*(a - x for a in A if x <= a < y), y - x] for x, y in zip([0, *B], B)]
 
@wastl is that to do the whole thing?
 
I think so
 
wow..let me see
 
However I'm getting floating point inaccuracies
 
8:30 PM
me too!
how weird
it's a lot simpler than your first solution!
 
yes, sometimes I'm thinking a bit overcomplicated
 
I wonder where the inaccuracies come from
 
also 0.1 + 0.2 = 0.30000000000000004
floating point is weird ...
@Anush If you want it exact, use fractions.Fraction
 
In Ruby, that's just 0.1r + 0.2r
or 1/10r + 2/10r
 
Ruby has builtin rational support?
That's awesome!
 
8:41 PM
It has built-in support for complex numbers as well
irb(main):039:0> (3r/5 + 4ri/5) * (3r/5 - 4ri/5)
=> ((1/1)+(0/1)*i)
 
Python has builtin complex support, too.
>>> (1 + 2j)*(4 - 7j)
(18+1j)
 
9:03 PM
@wastl thanks
 
9:21 PM
what is the complexity of [[*(a - x for a in A if x <= a < y), y - x] for x, y in zip([0, *B], B)] ?
in terms of the lengths of A and B
is it running in len(A)*len(B) time?
or something worse?
 
@Anush O(|A|*|B|)
 
9:52 PM
CMC: Given a non-integer and a selector value (within reason — don't abuse it to hide code) round the non-integer up, down, away from zero, or towards zero, depending on the selector value.
CMP: … or should I Main it?
 
10:25 PM
@Adám I liked this one. I got 36 bytes with a pretty naive approach.
Pretty sure that's still very golfable
 
@J.Sallé If nothing else, at least train the possibilities.
 
@Adám Yeah, that makes it 34 bytes hahahah
 
@J.Sallé Nah: ⊃∘(⌈,⌊,××⌈∘|,⌊∘|)
 
wait I can do that?
I thought the possibilities had to be strings
 
@J.Sallé Why? Sure, it does way too much calculation, but it is code golf, so…
 
10:30 PM
@Adám for , because I only use it to convert strings to ints usually
 
@J.Sallé There's no
 
Yeah, that's why
 
@J.Sallé Amazingly enough, {(⍎⍺⊃'⌈' '⌊' '××⌈∘|' '××⌊∘|')⍵} is actually allowed!
 
@Adám 'I was using it because I was using strings because I was using it because...'⍣ad_infinitum
 
@J.Sallé ⍣ad_infinitum is simply ⍣{0} ;-)
 
10:34 PM
@Adám hah, can't golf even when pulling a joke
 
sadly trains are too good to allow this to be competitive
-3 but still too long
⌊⍢| would be fun, but we've had that conversation before
 
@dzaima WHile not short, ⌊⍢((×⍵)∘×) should work, though.
 
11:04 PM
another -1, now parenthesis-less!
 

« first day (3089 days earlier)      last day (63 days later) »