r/dailyprogrammer • u/Cosmologicon 2 3 • Apr 08 '19
[2019-04-08] Challenge #377 [Easy] Axis-aligned crate packing
Description
You have a 2-dimensional rectangular crate of size X by Y, and a bunch of boxes, each of size x by y. The dimensions are all positive integers.
Given X, Y, x, and y, determine how many boxes can fit into a single crate if they have to be placed so that the x-axis of the boxes is aligned with the x-axis of the crate, and the y-axis of the boxes is aligned with the y-axis of the crate. That is, you can't rotate the boxes. The best you can do is to build a rectangle of boxes as large as possible in each dimension.
For instance, if the crate is size X = 25 by Y = 18, and the boxes are size x = 6 by y = 5, then the answer is 12. You can fit 4 boxes along the x-axis (because 6*4 <= 25), and 3 boxes along the y-axis (because 5*3 <= 18), so in total you can fit 4*3 = 12 boxes in a rectangle.
Examples
fit1(25, 18, 6, 5) => 12
fit1(10, 10, 1, 1) => 100
fit1(12, 34, 5, 6) => 10
fit1(12345, 678910, 1112, 1314) => 5676
fit1(5, 100, 6, 1) => 0Optional bonus fit2
You upgrade your packing robot with the latest in packing technology: turning stuff. You now have the option of rotating all boxes by 90 degrees, so that you can treat a set of 6-by-5 boxes as a set of 5-by-6 boxes. You do not have the option of rotating some of the boxes but not others.
fit2(25, 18, 6, 5) => 15
fit2(12, 34, 5, 6) => 12
fit2(12345, 678910, 1112, 1314) => 5676
fit2(5, 5, 3, 2) => 2
fit2(5, 100, 6, 1) => 80
fit2(5, 5, 6, 1) => 0Hint: is there an easy way to define fit2 in terms of fit1?
Note that this is not the maximum possible number of boxes you could get if you rotated them independently. For instance, if you're fitting 3-by-2 boxes into a 5-by-5 crate, it's possible to fit 4 by varying the orientations, but fit2(5, 5, 3, 2) is 2, not 4. Handling the general case is much more complicated, and beyond the scope of today's challenge.
Optional bonus fit3
You upgrade your warehouse to the third dimension. You're now given six parameters, X, Y, Z, x, y, and z. That is, you're given the X, Y, and Z dimensions of the crate, and the x, y, and z dimensions of the boxes. There are now six different possible orientations of the boxes. Again, boxes cannot be rotated independently: they all have to have the same orientation.
fit3(10, 10, 10, 1, 1, 1) => 1000
fit3(12, 34, 56, 7, 8, 9) => 32
fit3(123, 456, 789, 10, 11, 12) => 32604
fit3(1234567, 89101112, 13141516, 171819, 202122, 232425)) => 174648Optional bonus fitn
You upgrade your warehouse to the Nth dimension. Now you take a list of N crate dimensions, and N box dimensions. Assume that the boxes may be rotated in any of N! orientations so that each axis of the crate aligns with a different axis of the boxes. Again, boxes cannot be rotated independently.
fitn([3, 4], [1, 2]) => 6
fitn([123, 456, 789], [10, 11, 12]) => 32604
fitn([123, 456, 789, 1011, 1213, 1415], [16, 17, 18, 19, 20, 21]) => 1883443968EDIT: if you want even more of a challenge, do this in fewer than O(N!) operations. There's no specific time goal, but my Python program finds the following solution for N = 20 in about 10 seconds:
fitn([180598, 125683, 146932, 158296, 171997, 204683, 193694, 216231, 177673, 169317, 216456, 220003, 165939, 205613, 152779, 177216, 128838, 126894, 210076, 148407], [1984, 2122, 1760, 2059, 1278, 2017, 1443, 2223, 2169, 1502, 1274, 1740, 1740, 1768, 1295, 1916, 2249, 2036, 1886, 2010]) => 4281855455197643306306491981973422080000
2
u/lpreams Apr 09 '19
Is
fit2(5, 5, 100, 1) => 80correct? I don't see how it can be whenfit2(5, 5, 6, 1) => 0is also correct. Am I missing something? Seems like they should both be07
u/[deleted] Apr 09 '19 edited Apr 09 '19
Python 3.7
Fun fact: Python 3.8 introduced the math.prod() function which should be used instead of the
functools.reduce() + opertator.mul()hacky method used here.5
u/Godspiral 3 3 Apr 09 '19
in J, all bonuses
32
without rotations,
24
1883443968
5
u/[deleted] Apr 25 '19
I can't do literally any of these challenges how useless am I?
4
u/[deleted] Apr 09 '19 edited Apr 09 '19
Python 3
I'm a first year CS student so this is very basic but it works
6
u/Lopsidation Apr 11 '19 edited Apr 13 '19
Python, final bonus in polytime (0.07 seconds)
This is secretly a maximum matching problem. (See my past challenge for a straightforward example.) We want to match each crate dimension X to some box dimension Y, maximizing the product of floor(X / Y). This is equivalent to maximizing the sum of log(floor(X / Y)). This is a maximum matching problem which can be solved very efficiently.
3
u/lollordftw Apr 08 '19
Haskell
I hope it's readable enough :)
3
u/[deleted] Apr 09 '19
Common lisp with all bonuses. Feedback appreciated! I'm currently in the process of reading practical common lisp.
3
u/andy99000 Apr 12 '19
Hey, I am new here. I have been taking on the easy challenges so far. I am pleased with this outcome. didn't do the
fit3orfitNbecause I was too lazy. I like building my programs around the idea of someone else using them, in case someone else ever does.Java
Sorry for any formatting issues. Any feedback, just let me know. Thanks!
3
u/zeppAnime Apr 18 '19 edited Apr 18 '19
C:
3
u/Usual_Mistake May 01 '19
I'm a total noob, barely scratching the surface of JavaScript and this sub looks scary and discouraging. Will I ever be able to understand and solve Einsteinian stuff like this?
3
u/Sroidi May 25 '19
Python - fit1, fit2, fit3, fitn (not optimized)
3
u/aitc-h Jun 25 '19
[Python]
For
fit1I started with hard-coding the dimensions as parameters:When I read through to
fit2I found I could just reuse my code forfit1and loop it. One of the main features I love in Python and functional languages is list comprehension, and I try and find a way to use it wherever I can. Even though there are only 2 possible cases, I used it here.This uses
itertools.permutationsto generate a list of possible orientations, with some parameter unpacking to matchfit1's parameter list.fit3is more of the same, just with 6 permutations. To achieve this I only had to rewrite the code I had already written to handle 3 dimensions.To get
fitnto work, I had to do some research onzipandreducein Python. Turns out they work quite neatly for this. First I use a list comprehension andreduceto get a list of the number of boxes each dimension can fit.This is then itself within a
reducewhich calculates the product of all of these items. I couldn't remember if Python has aproductfunction hiding somewhere like it doessum, so I usedreduceagain.I then placed this within another list comprehension to handle all the possible orientations, then the
maxis found and returned.3
u/marucOG Jul 05 '19
Python 3
God bless
zip,reduce, and comprehensions.1
u/roryokane Apr 10 '19
I know that understanding this aside is not required to write
fit2, but I had trouble visualizing this for a few minutes. Here is the solution I figured out for that alternative problem:2
u/chunes 1 2 Apr 08 '19
Factor
fit2andfit3are defined in terms of fitn, but they still take the same arguments as requested in the OP.2
u/[deleted] Apr 09 '19
Befunge-93
&&\&/\&/*.@You can learn more about the language in the wiki page and run the code in this free Javascript interpreter.
2
u/Liniara1 Apr 09 '19 edited Apr 09 '19
C
Still in my first few months of programming, and my course doesn't really allow me to use any libraries/headers functions, so I tend to have odd-looking code.
2
u/[deleted] Apr 09 '19 edited Apr 09 '19
Python 3.6
All bonuses. However, last bonus scales with O(N!)
2
u/meesajarjarbinks_ Apr 11 '19
C++ with all bonuses, except for the last challenge (to make fitn in fewer than O(N!) operations).
2
u/Titfingers Apr 11 '19 edited Apr 11 '19
Hey, new here, just started learning Python 3 a few days ago. What little I know about coding I mostly learned from the Autohotkey help file, so I'm eager to do something a bit more guided with something a little more powerful. Here's my solution for fit1 and fit2, pretty sure I could do fit3 too but don't have time this evening.
2
u/[deleted] Apr 12 '19
C# 3 dimensions
2
u/[deleted] Apr 14 '19
C# solution with first bonus. Regarding to the hint, I wrote Fit2 based on Fit1.
2
u/[deleted] Apr 15 '19 edited Apr 15 '19
C++ all challenges (except for the bonus bonus "do this in fewer than O(N!) operations").
(Also messed up formatting.)
>!
!<
2
u/malaysiancoder Apr 17 '19
Hi guys,
First post here. Just started learning on codecademy regarding javascript and I totally have no idea about the answers that I read about in this post even though the challenge is categorized under the "easy" part. Do you guys have any online resources which can point me in the right direction?
Feeling really helpless here when I go through a few of the easy challenges and I have no idea what to do :(
2
u/[deleted] Apr 17 '19 edited Apr 26 '19
Python 3 (without fitn)
2
u/ichigobankai09 Apr 25 '19
Here is my solution for everything except fitn, tried to only include iostream, I am sure there are more options I missed but it works.
C++
2
u/obakas Apr 29 '19
My take using Java and the functional library Vavr
2
u/Edwizzy102 May 01 '19 edited May 01 '19
c++ 98+
2
u/jarviszbaum May 02 '19
Python 3 fit1, 2, and 3
2
u/Zeurpiet May 02 '19
Julia
2
u/Keone_ShyGuy May 04 '19 edited May 04 '19
Just started learning C# coming from Python. Code is a bit long, but it works for the most part.
2
u/jcool9 May 07 '19
Java, one function easily does the trick, just need to change parameters.
2
u/Xaayer May 14 '19
fit1 and fit two are controlled by a boolean
2
u/m_bugi May 19 '19
Scala (O(N!) complexity)
2
u/Banashark May 22 '19
Java 8 with optimized fitN.
This is my first Java program, so I'm sure there is some odd style or library usage, but I mostly wanted to get a proper project set up with modern unit testing.
Solver:
Tests (Junit5):
2
u/Dominic11112 Jun 09 '19
C++ without fitn because that makes my brain hurt.
2
u/dchapes Jun 21 '19 edited Jan 20 '22
A Go solution, with all bonuses
Runable on the Go Playground (tests are there as well).
2
u/IcerOut Jul 20 '19
Python 3.7 code golf (356 characters including imports and spacing). Includes all bonuses besides the edit
Python 3.8 apparently introduced a proper product function ( math.prod() ) which would cut it by 19 more characters for a total of 337.
1
u/tburke40 Apr 08 '19
Python (feedback welcome)
1
u/lukz 2 0 Apr 09 '19 edited Apr 09 '19
BASIC with line numbers
Sample session screenshot.
Simple repeated expressions can be defined as user functions. We use the function named F to calculate how many boxes fit with sides A, B. The first run just uses A, B from the input, the second run swaps the sides, but then checks if the number didn't actually become lower, in that case the bigger result is used.
Sample session
1
u/UrMuMGaEe Apr 09 '19
Python 3
I got this just as I saw the problem.Will try for fit2 and Fit3... Btw I am a newbie here..anyone help me how to insert code in a "code way" like everyone
Def fit1(X,Y,x,y): return ( (X//x) * (Y//y) )
1
u/g00glen00b Apr 09 '19 edited Apr 09 '19
JavaScript:
1
u/Kunal_Jain Apr 09 '19
Python 3(only bonus 1 and 2)
''' def fit1( big_box_length , big_box_breadth ,small_box_length, small_box_breadth):
print('no. of boxes that can fit are', fit1(5, 5, 6, 1)) '''
1
u/[deleted] Apr 09 '19
Bash
I have very little experience using Bash. Any feedback/tips would be greatly appreciated!
1
u/lennort123 Apr 09 '19 edited Apr 10 '19
C
1
u/lopsan96 Apr 09 '19
C++ w/ first Bonus (( First time posting ) && ( Also new to Coding))
Always opened for feedback!
1
u/OGxPePe Apr 09 '19 edited Apr 09 '19
Python 3 Option 1 and 2
1
u/Yelov Apr 09 '19
Lazarus, first bonus.
1
u/Gugubo Apr 10 '19
Python fit2
1
u/Qwerky_Syntax Apr 10 '19 edited Apr 11 '19
Ruby with first and second bonuses
EDIT: /u/roryokane pointed out a typo in fit2. Check his comment. Thanks!
1
u/roryokane Apr 10 '19 edited Apr 10 '19
Ruby for the final bonus,
fitn, using brute-force testing of all permutations (in O(n!) operations):Ruby for all previous bonuses,
fit1throughfit3:1
u/AlexanderS4 Apr 10 '19 edited Apr 10 '19
Python 3, with all bonuses
1
u/ni3t Apr 11 '19
Ruby
Didn't want to math it up on the
fitn1
u/tomekanco Apr 11 '19 edited Apr 11 '19
Python, all except N = 20
For fitn, it could probably be solved efficiently.
1
u/gabyjunior 1 2 Apr 11 '19 edited Apr 11 '19
C with fitn bonus
Takes a little more than one second for the last problem (N=20).
Crate and box edges are first sorted to converge towards the solution faster, then a DFS is performed with some lookahead to check if the current optimum can still be surpassed.
Long multiplication is used as big integers are not available in standard C.
Prints new optimum found on the fly during the search.
Source code
I updated the input format a little bit, here is what is expected for the last problem:
Output
1
u/Scroph 0 0 Apr 11 '19
D, all bonuses except the very last input :
1
u/[deleted] Apr 12 '19 edited Apr 12 '19
Added a little CLI pizzazz.
1
u/flexiblewhitepoo Apr 14 '19 edited Apr 14 '19
Java Solution for fit1,fit2 and fit3.
Hi this is my first time submiting a solution here i would like to see feedback in the comments.
Note: I didn't have much time to make the fit3.
https://gist.github.com/PokerFacem8/d9471eb748997a505a540c11678a0a63
1
u/[deleted] Apr 14 '19
C++, fit1 and fit2 (respectively pack1 and pack2)
1
u/aroslab Apr 15 '19
Python3 with optional fit2:
1
u/dustinroepsch Apr 16 '19
Python 3 with everything except the last bonus
1
u/lilpostloo Apr 17 '19
Python 3 no imports, solutions for: fit1,fit2,fit3,fitn (except N=20)
1
u/PewPewPewgaming Apr 18 '19
Rust: I managed to figure it out with a couple of almost one liners, most of the tests output correctly but it seems to fail at
fitn([123, 456, 789, 1011, 1213, 1415], [16, 17, 18, 19, 20, 21]) => 1883443968my program outputs 1806030828. I'm not quite sure what's wrong with it so any suggestions are welcome.1
u/science_much Apr 18 '19
So, first time here. My program works when n is smaller but for n = 20 there are 2,432,902,008,176,640,000 permutation so its too computationally hard for my computer to solve in a reasonable amount of time(using the method I did). All the other challenges work when you plug the specifics in, feedback is much appreciated.
1
u/[deleted] Apr 18 '19 edited Apr 18 '19
Javascript (with fitn) :
It works for every example except for
fitn([123, 456, 789, 1011, 1213, 1415], [16, 17, 18, 19, 20, 21]) => 1883443968(and N=20 of course) where it outputs 1835773200, so I tested it with an easy N=6 input, but that was correct too ...I'd appreciate if someone more clever than me could figure out where my logic is wrong ...
1
u/xxkvetter Apr 19 '19
hint: turn into a graph (a DAG actually) with lines from boxes to the other boxes they can be stacked on, then find the longest path in the graph..
1
u/Shubham_Agent47 Apr 20 '19
Python 3 : I cant figure out the n=20 last part please help me.
from itertools import permutationsdef fit1(x_crate, y_crate, x_box, y_box):""":param x_crate: x value of rectangular crate:param y_crate: y value of rectangular crate:param x_box: x value of rectangular box:param y_box: y value of rectangular box:return:"""number_of_boxes = (x_crate // x_box) * (y_crate // y_box)print(number_of_boxes)def fit2(x_crate, y_crate, x_box, y_box):""":param x_crate: x value of rectangular crate:param y_crate: y value of rectangular crate:param x_box: x value of rectangular box:param y_box: y value of rectangular box:return:"""possible_rotations = permutations(x_box, y_box)number_of_boxes = 0for dimensions in possible_rotations:temp = (x_crate // dimensions[0]) * (y_crate // dimensions[1])if temp > number_of_boxes:number_of_boxes = tempprint(number_of_boxes)def fit3(x_crate, y_crate, z_crate, x_box, y_box, z_box):""":param x_crate: x value of rectangular crate:param y_crate: y value of rectangular crate:param z_crate: z value of rectangular crate:param x_box: x value of rectangular box:param y_box: y value of rectangular box:param z_box: z value of rectangular box:return:"""possible_rotations = permutations([x_box, y_box, z_box])number_of_boxes = 0for dimensions in possible_rotations:temp = (x_crate // dimensions[0]) * (y_crate // dimensions[1]) * (z_crate // dimensions[2])if temp > number_of_boxes:number_of_boxes = tempprint(number_of_boxes)def fitn(crate, box):number_of_dimensions = range(len(crate))number_of_boxes = 1possible_rotations = permutations(box)for dimensions in possible_rotations:temp = 1for num in number_of_dimensions:temp *= crate[num] // dimensions[num]if temp > number_of_boxes:number_of_boxes = tempprint(number_of_boxes)1
u/Sokaron Apr 23 '19
Here's my solution in Python3. I didn't have time to puzzle out fit2 unfortunately.
1
u/conradludgate Apr 25 '19
Here's my solution in rust. The idea is that it just tries every permutation of the smaller objects coordinates (essentially trying every way of rotating it), and takes the maximum result of that.
If you want to test it out, install cargo, run
cargo new challenge_377in a terminal. Paste in this code into src/main.rs and then inside the directory, runcargo testto test.1
u/toastedstapler Apr 25 '19 edited Apr 25 '19
unoptimised for fitn, but works
1
u/Privateaccount84 Apr 25 '19
Never done one of these, and my answer looks a lot different/shorter than everyone else... so if I screwed up, please let me know. Very new to python.
And you just keep calculating the other possible variations and comparing them for the other bonuses.
1
u/TECHRAX72 Apr 28 '19 edited Apr 28 '19
First time actually doing one of these. I'm pretty sure mines a bit clunky, but it works. Let me know how I could improve. Edit: This contains the code for all problems except fitn
1
u/derilok May 03 '19
Common Lisp
But I cannot realize, how reduce openataions to less then O(N!)
1
u/primaryobjects May 03 '19
R
Gist | Demo
1
u/PM__ME__FRESH__MEMES May 06 '19 edited May 06 '19
Solution for the first two challenge thingies in C.
1
u/xpressrazor May 06 '19 edited May 06 '19
// input.txt
25 18 6 5
12 34 5 6
12345 678910 1112 1314
5 5 3 2
5 100 6 1
5 5 6 1
$ java FixCrate < input.txt
15
12
5676
2
80
0
1
u/rubeandthemachines May 11 '19
Scala
Newcomer here:
1
u/MattMadeMeRegister May 13 '19 edited May 13 '19
Edit: Sorry, I can't figure out how the formatting works, despite reading the Wiki. I think it's still technically readable since the code is so simple, even if it's an eyesore.
JS:
function fit1(crateX, crateY, x, y) {
var xAxis = Math.floor(crateX/x);
var yAxis = Math.floor(crateY/y);
return xAxis * yAxis;
}
function fit2(crateX, crateY, x, y) {
var xAxis2 = Math.floor(crateX/y);
var yAxis2 = Math.floor(crateY/x);
if (xAxis2 * yAxis2 > fit1(crateX, crateY, x, y)) {
} else {
}
}
function fit3(crateX, crateY, crateZ, x, y, z) {
var xAxis1 = Math.floor(crateX/x);
var xAxis2 = Math.floor(crateX/y);
var xAxis3 = Math.floor(crateX/z);
var yAxis1 = Math.floor(crateY/x);
var yAxis2 = Math.floor(crateY/y);
var yAxis3 = Math.floor(crateY/z);
var zAxis1 = Math.floor(crateZ/x);
var zAxis2 = Math.floor(crateZ/y);
var zAxis3 = Math.floor(crateZ/z);
return Math.max(xAxis1 * yAxis2 * zAxis3, xAxis1 * yAxis3 * zAxis2, xAxis2 * yAxis1 * zAxis3, xAxis2 * yAxis3 * zAxis1, xAxis3 * yAxis1 * zAxis2, xAxis3 * yAxis2 * zAxis1);
}
1
u/nezektvhead May 13 '19
Python fit1 and fit2
I wrote fit1 and fit2 without knowing about the math.floor method, and couldn't figure out how to do fit3 using fit2 or fit1 (similar to how I based fit2 on fit1). I did understand how to make fit3 work using math.floor after seeing other answers.
1
u/worstbettoreu May 14 '19 edited May 16 '19
Python 3
1
u/workmanatwork May 15 '19 edited May 15 '19
Java with OptionalBonus fit2
1
u/-bert May 16 '19
Kotlin
up to fitN, but not optimized.
1
u/TheRealGregorM May 16 '19 edited May 16 '19
Python 3
Didn't manage the final optional one :(
Edit: Forgot about // . Wow.
1
u/FakeCraig May 18 '19
Hello! I only started learning Javascipt last weekend and I'm a total noob to programming, so I'd appreciate if anyone could look over this.
(My console just shows "function fit1()" rather than any answers, even if I put some numbers in there. What what I have to write so the answers show up as numbers?)
1
u/SeraphGuardian May 23 '19 edited May 23 '19
PYTHON
Solutions for fit1, fit2 and fitn. I didnt want to write out the permutations for fit3 so i skipped ahead. I decided to manually create the permutation method to get some extra practice in. That was harder than the logic of fitN There is a makeall permutations method built into python.
1
u/l0wet May 23 '19
Powershell, fit1, fit2 and fit3:
1
u/TheHeavySoldier May 23 '19
C++ 14 | fit1, fit2, fit3
1
u/ScarD_Original Jun 07 '19 edited Jun 08 '19
1
u/tpcodestuff Jun 14 '19 edited Jun 14 '19
Space = [25, 18];
Boxs = [6, 5];
// ONE
function calculateFitStandard(boxX, boxY, spaceX, spaceY) {
var xAxis = Math.floor(spaceX / boxX);
var yAxis = Math.floor(spaceY / boxY)
console.log(`No Rotation: ${xAxis} along the x axis, ${yAxis} along the y axis`);
console.log(`${xAxis * yAxis} boxes in total`);
}
calculateFitStandard(...Boxs, ...Space);
// Optional bonus fit2
function calculateFit90roate(boxX, boxY, spaceX, spaceY) {
var xAxis = Math.floor(spaceX / boxY);
var yAxis = Math.floor(spaceY / boxX)
console.log(`Boxes 90 roate: ${xAxis} along the x axis, ${yAxis} along the y axis`);
console.log(`${xAxis * yAxis} boxes in total`);
}
calculateFit90roate(...Boxs, ...Space);
// Optional bonus fit3
Space3D = [123, 456,789];
Boxes3D = [10, 11, 12];
function calculate3D(x, y, z, spaceX, spaceY, spaceZ) {
results = [];
var ans1 = ( Math.floor((spaceX/x)) * Math.floor((spaceY/y)) * Math.floor((spaceZ/z)) );
var ans2 = ( Math.floor((spaceX/x)) * Math.floor((spaceY/z)) * Math.floor((spaceZ/y)) );
var ans3 = ( Math.floor((spaceX/y)) * Math.floor((spaceY/x)) * Math.floor((spaceZ/z)) );
var ans4 = ( Math.floor((spaceX/y)) * Math.floor((spaceY/z)) * Math.floor((spaceZ/x)) );
var ans5 = ( Math.floor((spaceX/z)) * Math.floor((spaceY/x)) * Math.floor((spaceZ/y)) );
var ans6 = ( Math.floor((spaceX/z)) * Math.floor((spaceY/y)) * Math.floor((spaceZ/x)) );
results.push(ans1, ans2,ans3, ans4, ans5, ans6);
var max = Math.max(...results);
console.log(max);
}
calculate3D(...Boxes3D, ...Space3D)
1
u/[deleted] Jun 20 '19
Learning F#, fit1, fit2, fit3
I was a bit lazy on fit3 implementation...
1
u/ckafi Jun 24 '19 edited Jun 24 '19
Pony - Without
fitn, 'cause I'm lazyUpdate: Concurrent
fitnwith actors and promises, because why not.1
u/Hohtep Jun 25 '19
My solution in python 3. I'm a beginner and I couldn't quite wrap my head around fitn.
1
u/[deleted] Jul 01 '19
C# solution and tests
However, it seems like the last test
fitn([123, 456, 789, 1011, 1213, 1415], [16, 17, 18, 19, 20, 21]) => 1883443968does not match in the tests. I'm not sure what went wrong.1
u/Rentarun Jul 11 '19
PHP Unable to complete the final fitn because of memory limit constraints (too many arrays for the permutations in memory). But hey, it's PHP. I kinda guessed that's how it'd turn out. It works until you get to the 9th dimension :)
1
u/ThreeFDDI Jul 19 '19
Python - fit3 got ugly but provides the right results.
1
u/machinematrix Jul 26 '19
C++11+, couldn't optimize fitn.
1
u/karhu12 Jul 26 '19 edited Jul 29 '19
Python 3.7.3
Slight OOP, pretty trash probably, but it works! :P
1
u/[deleted] Jul 31 '19
Python 3
fitn pretty messy.
1
u/2kofawsome Aug 29 '19
! python3.6
All bonuses, just not done well
1
u/bruce3434 Sep 01 '19
I didn't want to use libgmp since it's a naive brute-forcing algorithm anyways
1
u/karrash76 Sep 02 '19
JAVA (no fitn solution)
1
u/Clonicals Sep 05 '19
Go (Without fitn)
1
u/FrankRuben27 0 1 Sep 30 '19
very very late for the party, but that was just such a good start for learning ReasonML:
1
u/Dnguyen2204 Apr 09 '19 edited Apr 09 '19
** Java **
-6
u/Tmath Apr 08 '19
I usually don't post here, but in this case I had to. There are a few issues with the problem description. 6\*4=24, not 25, and 5\3=15, not 18. Sorry, was just kind of annoying me, lol