34
votes
Solve Grid-Tangram
BBC BASIC, 570 514 490 bytes ASCII
Download interpreter at http://www.bbcbasic.co.uk/bbcwin/download.html
435 bytes tokenised
Full program displays an input from ...
22
votes
Accepted
Dennis, Doorknob, Martin Büttner, Chris Jester-Young - Pizzeria!
CJam, 20 bytes
q~1$*4/"CEDM"e*/:$N*
I think this should work :)
Try it online
Explanation:
This first makes a pizza labeled CC…EE…DD…MM… from left to right ...
13
votes
13
votes
Generate all Sublist Partitions
Retina, 27 19 bytes
Byte count assumes ISO 8859-1 encoding.
+1%`,
;$'¶$`];[
;
,
Try it online!
Explanation
Of course this computes all partitions using string ...
13
votes
Partition a square grid into parts of equal area
JavaScript (ES7), 166 bytes
Outputs a matrix of integers that describe the partition, or \$false\$ if there's no solution.
...
12
votes
Partial factorisations of a positive integer
Haskell, 56 bytes
_!1=[[]]
i!n=[j:f|j<-[i..n],mod n j<1,f<-j!div n j]
(2!)
(2!)(1338557220::Int) prints in five ...
12
votes
Count occurences of a set in a list
Python, 30 bytes
lambda s,l:min(map(l.count,s))
Try it online!
11
votes
11
votes
Third Stirling numbers of the second kind
Jelly, 6 bytes
3Ḋ*)SI
Try it online!
-1 byte thanks to Jonathan Allan
1-indexed sequence without leading zeros. Uses the formula \$\sum_{k=1}^{n} 3^k - 2^k\$.
...
10
votes
Accepted
Sorted Lexical Partition of a Number
Pyth, 34
FNyUz#aYmv:zhdedC,+0N+NlzB)efqSTTY
Try it online here. Notice, this has a time (and space) complexity of O(n). Therefore the test case ...
10
votes
Generate all Sublist Partitions
Pure Bash, 28
eval echo [${1//:/{:,]:[\}}]
Here, lists are colon-separated, and contained in square brackets. For example in the question, the input list would ...
10
votes
Accepted
Counting the number of restricted forests on the Möbius ladder of length n
CJam (58 56 chars)
Some characters unprintable, and one is a tab which will be mangled by the StackExchange software:
...
9
votes
Accepted
Maximum Concatenated Product
CJam, 32 28 23 12 bytes
0le!f{~*}:e>
Try it online in the CJam interpreter.
Thanks to @user23013 for helping me save 16 whole bytes!
Idea
Permuting the ...
9
votes
Refined Partitions
Pyth, 19 bytes
&gF_m{.u+NYdYQqFsMQ
Try it online: Demonstration or Test harness
I'm using Pyth's tuple/list format as input. Simply replace the spaces of ...
9
votes
Split a number in every possible way
Brachylog, 8 bytes
ṫ{~cịᵐ}ᵘ
Convert to string ṫ and get all unique {…}ᵘ reverse ...
8
votes
Dennis, Doorknob, Martin Büttner, Chris Jester-Young - Pizzeria!
Pyth, 30 25 bytes
jb.eu_GkbceQs*R/*FQ4"EDMC
Live demo and all test cases.
Cut off 5 bytes thanks to @Jakube!
Same algorithm as my K answer...but a lot shorter....
8
votes
Finding sum-free partitions
Python 3, sort by greatest number, n = 92 121
Thanks to Martin Büttner for a suggestion that unexpectedly improved the maximum n reached.
Last output:
...
8
votes
Interquartile Mean
Pyth, 11 10 bytes
.O><lQS*4Ql
.OsPtc4S*4
Test suite.
How it works
It quadruplicates the input list to ensure that the data count is divisible by 4.
It still needs sorting, because ...
8
votes
Interquartile Mean
MATL, 12 11 bytes
4Y"G"6L)]Ym
Input is a horizontal vector, with the format
[1, 3, 4, 5, 6, 6, 7, 7, 8, 8, 9, 38]
or
...
8
votes
Split a list into sized chunks, but not counting items failing predicate
Brachylog, 37 bytes
hW&t~c.k{↰₂ˢl}ᵐ;WxĖ∧.bhᵐ↰₂ᵐ∧.t↰₂ˢl≤W∧
Try it online!
I was pleasantly surprised to find that this - pretty much a restatement of the ...
8
votes
Split a list into sized chunks, but not counting items failing predicate
Apl (Dyalog Unicode) 17 16 bytes (SBCS)
Thanks to Adám for saving me 1 byte.
w⊆⍨⌈⎕÷⍨1⌈+\⎕¨w←⎕
Try it online!
for explaination purposes I will leave up the 17 byte ...
8
votes
8
votes
Is it a vampire number?
Husk, 18 17 14 13 12 bytes
Edit: -3 bytes, and then another -1 byte, thanks to Leo, and -1 byte thanks to inspiration from pajonk's R answer (3rd edit)
€¹mΠ†dm½f→Pd
...
8
votes
Third Stirling numbers of the second kind
R, 23 bytes
3^(n=scan()+2)/2-2^n+.5
Try it online!
Outputs without the leading zeros, 0-indexed.
Uses formula from OEIS page:
$$ a(n) = 9 \cdot 3^n/2 - 4 \cdot 2^...
8
votes
Third Stirling numbers of the second kind
Jelly, 7 bytes
cþæ*2FS
Try it online!
Now that xigoi has outgolfed me, I thought I'd share my answer.
This outputs the \$n\$ term of the sequence without leading ...
8
votes
There's more than one way to skin a set
BQN, 15 bytesSBCS
(1=⊒)⊸/·⥊(∾∾+)˝
Run online!
BQN, 19 bytesSBCS
(1=⊒)⊸/<+´∘ר⟜⥊⟜↕2¨
Run online!
...
8
votes
Divisible subset sums
JavaScript (ES6), 40 bytes
Expects (k)(n).
k=>g=(n,s=0)=>n--?g(n,s)+g(n,s-~n):s%k<1
Try it online!
Commented
...
8
votes
Divisible subset sums
Python 3, 54 bytes
f=lambda n,k,r=0:n and f(n-1,k,r)+f(n-1,k,r-n)or r%k<1
Try it online!
7
votes
Refined Partitions
JavaScript (ES6), 67 70
Edit 3 bytes saved thx @apsillers
Run the snippet below in Firefox to test
...
7
votes
Accepted
Compute the Join and Meet of Partitions
CJam, 32 - 10 = 22
q_~{_{T&},:U-U:+a+}fTp~m*::&La-p
::& is newer than this question.
CJam, 36 - 10 = 26
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
set-partitions × 54code-golf × 52
combinatorics × 17
number × 7
grid × 7
math × 6
sequence × 6
array × 5
decision-problem × 4
number-theory × 4
geometry × 4
string × 3
arithmetic × 3
subsequence × 3
primes × 2
tiling × 2
statistics × 2
ascii-art × 1
code-challenge × 1
tips × 1
game × 1
matrix × 1
parsing × 1
graph-theory × 1
permutations × 1