« first day (3065 days earlier)      last day (1785 days later) » 

12:08 AM
-1
Q: How can I change following function not to use flag?

Vishal JadhavI am trying to see how to improve following code....need to somehow not use the flag and still return null in case not dirty. function MyObject doSomething(someOject) { boolean isDirty = false; MyObject myobject = new MyObject(); if (someOject.getProperty() != null) { isDirty = true m...

 
 
5 hours later…
4:50 AM
@NewMainPosts Maybe people don't know what "code golf" means. Maybe we should be called "Shortest Code Competitions"…
 
5:31 AM
0
A: Sandbox for Proposed Challenges

BarrankaProposed title: Golf the smallest circle! code-golf The problem: Given a non-empty set of points in the cartesian plane, find the smallest circle that encloses them all (wikipedia link). This problem is trivial if the number of points is three or less (if there's one point, the circle has a ra...

 
5:51 AM
0
A: Sandbox for Proposed Challenges

guifaGPA calculator A GPA is sort of weighted average based on the grades obtained in certain courses. There are a number of different systems, but for this challenge we'll use the following grades and their numeric values: A: 4 B: 3 C: 2 D: 1 F: 0 P: — The grade is P is a special case. For some...

 
 
2 hours later…
8:11 AM
0
A: Sandbox for Proposed Challenges

scfIntroduction When dealing with data in two dimensions, data scientists looove to see straight lines emerge, as they can use a simple linear regression to model it - meaning we assume it is in the form of y=mx+b, and all that's left is to find the best m and b to describe the data. There are sev...

 
 
1 hour later…
9:37 AM
CMC: Given a list of data D and a list of non-zero partition lengths P such that the sum of P equals the length of D, answer with a list consisting of sub-lists of D of lengths P. E.g. D=[0,8,4,3,2,7,7,3,9,3,3,9,0,0,7,8,1,1,7,2,3,6,5,2,1,9] and P=10 5 6 5 gives [[0,8,4,3,2,7,7,3,9,3],[3,9,0,0,7],[8,1,1,7,2,3],[6,5,2,1,9]].
 
Ruby: ->d,p{p.map{|n|d.shift n}}
I believe ->d,p{p.map d.:shift} will work in 2.7
 
9:55 AM
@Adám APL, 17 bytes
 
@dzaima 10 please! (And much less if you use Extended)
 
ngn
@Adám that's almost exactly k's "cut": (+\0,-1_P)_D
only it uses slice start indices instead of lengths
@Adám D⊂⍨0=∊⍳¨P ⊣⎕io←0
or better: D⊂⍨∊P↑¨1
 
How many different ways are there to indicate partitioning?
1. List of lengths: [3,2]
2. Bin numbers: [1,1,1,2,2]
3. Boolean mask indicating beginnings: [1,0,0,1,0]
4. Boolean mask indicating ends: [0,0,1,0,1]
5. Indices of beginnings: [0,3] or[1,4]
6. Indices of ends: [2,4] or [3,5]
7. Alternating mask: [0,0,0,1,1] or [1,1,1,0,0]
more?
 
boolean masks (3,4,7) packed into integers
 
@JohnDvorak That'd be [4,2] for the above example?
@ngn That's 10. Good job. Now do it in Extended.
 
ngn
10:08 AM
@Adám some of these are more powerful than others, e.g. "cut" can drop the part before the first slice, list of lengths can't
 
I mean, [1,0,0,1,0] => 9, [0,0,1,0,1] => 20, [0,0,0,1,1] =>24, [1,1,1,0,0] => 7
 
@JohnDvorak Oh, but that'd give potentially huge ints.
 
sure. Why not?
 
@JohnDvorak Actually, with packed bit Boolean arrays, it is the same. Just a different way to print the data.
 
How about prime-packed boolean arrays? [1,0,0,1,0] => 2*7 = 21
 
10:13 AM
@Adám mask indicating separation, i.e. [0,0,1,0]
 
That's just #2 or #3 with the first/last element omitted
 
or [0,0,0,1,0,0] if you want to allow for potential empty partitions at either end which should allow for any partitioning
@JohnDvorak because that first/last element is completely useless, and it is a very different encoding practically
 
You could take a predicate instead of a partition list
 
@ngn Yes, that one is very good. Dyalog's would also be if only we allowed non-Booleans left argument. Essentially, K's _ uses the &/ of APL's .
@JohnDvorak What?
 
@ngn for me that's a bad thing about a design, but sure, it does bring up a point that different ones have different abilities
 
10:21 AM
cut before/after elements for which a provided function is false/true
 
@JohnDvorak That doesn't solve the problem of specifying a fixed partitioning.
 
(speaking of which, complements for #3 and #4 are also way to indicate partitioning)
 
@dzaima Good point. #2 () is the only one that can leave elements out.
Actually, may make for a good main challenge.
@dzaima #1, #3, #5, #6 allow insertion of empty elements.
 
@Adám hmm, would it make sense for the "bin numbers" to place empty partitions if the difference between numbers is >1? i.e. 1 1 3 4 7 on "abcde"["ab","","c","d","","","e"]
 
@dzaima I guess so. That's actually very powerful. Then you can also insert at the front by not beginning with 1. And at the end by adding an additional element indicating how many empties you want there.
 
10:30 AM
0
Q: Alphabet completion rate

Teleporting GoatIntroduction How much of the English alphabet does a given string use? The previous sentence uses 77%. It has 20 unique letters (howmucftenglisapbdvr), and 20/26 ≃ 0.77. Challenge For an input string, return the percentage of letters of the English alphabet present in the string. The answer ...

 
an alternation of that would be a list of the deltas of that, but for the above to stay possible, you'd also need to store the 1st item
 
Another way of representing partitions would be a list of bin masks
[[1,1,0,0,0],[0,0,1,1,0],[0,0,0,0,1]]
 
@H.PWiz the two argument iteration is clever, i've managed to reduce it to 44
 
@dzaima actually then it pretty much becomes my 1st suggestion
 
@primo Nice, does it improve on m/.**1002/?
 
10:34 AM
yes
 
@dzaima another option would be bin numbers, but zeroes indicate empty partitions, so that'd be 1 1 0 1 2 0 0 1, but i don't think that's very practical
 
@Adám Yes, plenty.
 
 
1 hour later…
11:52 AM
0
A: Sandbox for Proposed Challenges

negative sevenMeta command-line flag parsing code-golf The challenge Write a program, function or snippet which determines whether or not a chosen command-line flag has been passed into the compiler or interpreter, but without accessing command-line parameters directly. Details You must take in no input. ...

0
A: Sandbox for Proposed Challenges

User AConversion Assume that there is a number a. In every conversion of that number, the number can either convert itself to its value plus the value of one of its digits, or convert itself to its value minus the value of one of its digits. In this situation, find the minimum number of conversions o...

 
12:12 PM
0
A: Sandbox for Proposed Challenges

User AMaximum amount There are integers in an array to be chosen. The chooser can at most choose two adjacent integers in the array. Choose a few integers from the array, and make sure that the amount is the maximum. Output that number. Input Input two lines. The first line contains an integer n (3 <...

 
12:51 PM
@NewSandboxedPosts Hmm, I feel like it'd be possible to reach every number but don't want to prove it
 
1:11 PM
0
Q: Track a point on the video

Geza KerecsenyiLet's say I have a grid of pixels as follows: -----------***-- -----------***** ---**********--- --*-********---- -*--*-*--*-*---- I can choose any point on this image using coordinates: e.g grid[0][1] (0-indexed) = (1, 2) (1-indexed) = {x=1, y=2} = -. I can also choose a square on this grid,...

 
 
1 hour later…
2:21 PM
Any last feedback on this before I post it?
 
@Skidsdev I'll give it a quick once-over
Looks pretty good, maybe add [06:01] or [18:01] as a test-case? Not sure if it'll catch anyone
 
2:47 PM
@Veskah can do, thanks!
 
@Skidsdev Oh, trailing .0 is fine for whole numbers, right?
Someone will probably ask that
 
@Veskah Ah, yes it is, I'll clarify that
 
Other than that, looks good to ship
 
3:13 PM
0
Q: Number conversion

User AAssume that there is a number a. In every conversion of that number, the number can either convert itself to its value plus the value of one of its digits, or convert itself to its value minus the value of one of its digits. In this situation, find the minimum number of conversions one has to ma...

 
 
2 hours later…
5:14 PM
0
Q: Analog is Obtuse!

SkidsdevAn analog clock has 2 hands*: Hour and minute. These hands circle the clock's face as time goes by. Each full rotation of the minute hand results in 1/12th of a rotation of the hour hand. 2 full rotations of the hour hand signifies a full day. As these hands are fixed to the same central point, ...

 
 
2 hours later…
6:47 PM
Is the SE inbox button broken for anyone else too?
 
@DJMcMayhem what did it do?
 
Ah, it's fixed now. But for a minute it wouldn't load
 
alright, I asked because if it takes you here then you're most probably rushing it a bit too much :P
 
7:41 PM
Since my vote is a hammer, does anyone disagree with closing codegolf.stackexchange.com/questions/26/… as the dupe of the new question?
 
eh, the input restriction on the older one makes it a dupe of the newer one (old standards)
 
yeah that's what I said
 
8:05 PM
imo that's dumb
but so is posting the same challenge with looser restrictions
so
 
reposting a challenge with newer standards is allowed
 
doesn't mean it's not dumb
 

« first day (3065 days earlier)      last day (1785 days later) »