Mafiascum Coding Challenge
- Kagami
-
Kagami Jack of All Trades
- Kagami
- Jack of All Trades
- Jack of All Trades
- Posts: 7065
- Joined: November 5, 2013
Vonflare, I'm not sure what the input to the desired function is. Is it an array of strings, or a string together with a preexisting grid?
Is the grid of fixed size prior to any input (as it apparently is in your example)?
Does the grid fit it such that there are as many empty spaces as possible (as in your example) or does it prefer to use completely empty diagonals (as in the problem statement)?- Kagami
-
Kagami Jack of All Trades
- Kagami
- Jack of All Trades
- Jack of All Trades
- Posts: 7065
- Joined: November 5, 2013
I think a more elegant problem statement for this challenge is as follows:
Input is a set of strings. The function should output the smallest square matrix such that each string fits in the manner vonflare specified. When there are multiple configurations that yield the smallest square matrix, the output should be one (though there are still multiple possibilities) that also maximizes the number of empty squares.- Kagami
-
Kagami Jack of All Trades
- Kagami
- Jack of All Trades
- Jack of All Trades
- Posts: 7065
- Joined: November 5, 2013
- AxleGreaser
-
AxleGreaser Mafia Scum
- AxleGreaser
- Mafia Scum
- Mafia Scum
- Posts: 3346
- Joined: April 19, 2014
- Location: (+10)
Your avatar seems strangely apt.
Spoiler: a problem- Kagami
-
Kagami Jack of All Trades
- Kagami
- Jack of All Trades
- Jack of All Trades
- Posts: 7065
- Joined: November 5, 2013
Worst case scenario is that you store 2^(2N) bits, but in practice it's going to be far fewer: (2^N) * foo, where foo is the number of steps between the initial state and the first repeated state.
If you're worried about memory, which perhaps you should be for a large board, you can run two threads of the game. For each step in thread A, thread B advances two steps. They will eventually have the same board, you store that step number, and then keep going until they meet again. The difference of the final step number and the earlier step number is the period of the final board state.- AxleGreaser
-
AxleGreaser Mafia Scum
- AxleGreaser
- Mafia Scum
- Mafia Scum
- Posts: 3346
- Joined: April 19, 2014
- Location: (+10)
In post 79, Kagami wrote:
If you're worried about memory, which perhaps you should be for a large board, you can run two threads of the game.
2^32 is 4 gig.
A game of life board with 32 cells is trivially small.
2^48 is 256 terra bytes
2 ^ 64 (and 8x8 game of life board.) is ... oopsie
Non trivial boards would fairly rapidly have more memory required than there are baryons in the visible universe.- Kagami
-
Kagami Jack of All Trades
- Kagami
- Jack of All Trades
- Jack of All Trades
- Posts: 7065
- Joined: November 5, 2013
- Ircher
-
Ircher He / Him / HisWhat A Grand Idea
- Ircher
- Kagami
-
Kagami Jack of All Trades
- Kagami
- Jack of All Trades
- Jack of All Trades
- Posts: 7065
- Joined: November 5, 2013
The problem is that I got some wires crossed in my head.
The worst-case memory requirement for the original algorithm is N*2^N bits with the actual requirement N*<steps of longest run>, which is generally not too bad.
The alternative algorithm requires at least twice as much computation. You'd likely want to pick between them based on the input's N.
I can't think of a better algorithm to solve the problem, and I would surprised if anything beyond an incremental refinement is possible.- Kagami
-
Kagami Jack of All Trades
- Kagami
- Jack of All Trades
- Jack of All Trades
- Posts: 7065
- Joined: November 5, 2013
- yessiree
-
yessiree heMafia Scum
- yessiree
he- Mafia Scum
- Mafia Scum
- Posts: 4389
- Joined: June 6, 2013
- Pronoun: he
- Ircher
-
Ircher He / Him / HisWhat A Grand Idea
- Ircher
He / Him / His- What A Grand Idea
- What A Grand Idea
- Posts: 15190
- Joined: November 9, 2015
- Pronoun: He / Him / His
- Location: CST/CDT
- Realeo
-
Realeo Jack of All Trades
- Realeo
- Jack of All Trades
- Jack of All Trades
- Posts: 5238
- Joined: February 11, 2016
- Location: Indonesia
Why I can't spoiler code..
Spoiler: Ircher's LCMLast edited by Realeo on Fri May 13, 2016 11:56 pm, edited 1 time in total."The debate on whether short multi postings or a long wall of post is good or not is like a debate on gun control--we would never understand each other and we have to make peace with it." -Realeo
I'm mabye a serious player, but I'm capable of joke. Ok?- Plotinus
-
Plotinus Kitten Caboodle
- Plotinus
- Kitten Caboodle
- Kitten Caboodle
- Posts: 7611
- Joined: March 13, 2015
- Location: UTC+1
- Contact:
Code: Select all
[spoiler=Ircher's LCM] [code] #Python def LCM(a,b): return a*b/GCM(a,b) def GCM(a,b): if a==0: return b return GCM(b%a,a)
[/spoiler][/code]
produces:
Spoiler: Ircher's LCMThe failure mode of clever is asshole.
Modding checklists | Sequencer is in Game 5 | Space II is in Day 4- Ircher
-
Ircher He / Him / HisWhat A Grand Idea
- Ircher
He / Him / His- What A Grand Idea
- What A Grand Idea
- Posts: 15190
- Joined: November 9, 2015
- Pronoun: He / Him / His
- Location: CST/CDT
- Ircher
-
Ircher He / Him / HisWhat A Grand Idea
- Ircher
He / Him / His- What A Grand Idea
- What A Grand Idea
- Posts: 15190
- Joined: November 9, 2015
- Pronoun: He / Him / His
- Location: CST/CDT
- Realeo
-
Realeo Jack of All Trades
- Realeo
- Jack of All Trades
- Jack of All Trades
- Posts: 5238
- Joined: February 11, 2016
- Location: Indonesia
Simple.In post 90, Ircher wrote:Now, to make it a but tougher:Make it where it can handle an arbritrary number of arguments. The number of arguments provided may be supplied as a parameter.Take the first two number. Find the lcm, Find the lcm of the lcm and the 3rd number. Rinse and repeat. Code coming later.
EDIT:
Spoiler: Ircher's LCM"The debate on whether short multi postings or a long wall of post is good or not is like a debate on gun control--we would never understand each other and we have to make peace with it." -Realeo
I'm mabye a serious player, but I'm capable of joke. Ok?- Ircher
-
Ircher He / Him / HisWhat A Grand Idea
- Ircher
- AxleGreaser
-
AxleGreaser Mafia Scum
- AxleGreaser
- Mafia Scum
- Mafia Scum
- Posts: 3346
- Joined: April 19, 2014
- Location: (+10)
LCM is an odd concept. It is equivalent to wanting the smallest of all the common prime factorsIn post 91, Realeo wrote:
Simple.In post 90, Ircher wrote:Now, to make it a but tougher:Make it where it can handle an arbritrary number of arguments. The number of arguments provided may be supplied as a parameter.Take the first two number. Find the lcm, Find the lcm of the lcm and the 3rd number. Rinse and repeat. Code coming later.
EDIT:
Spoiler: Ircher's LCM
So just to check that I have that oddness right.
The LCM of 30 and 12 is 2? (3 and 6 are also common multiples but 2 is smallest)
(also implcitly is not 1)
Re Irchers list problem.
LCM of 30,12, 9....
The algorithm above claims
LCM ( LCM (30,12) , 9 ) is the same as LCM(30,12,9)
its not.
The LCM of 30,12 is 2. (we chucked the 3 out because both numbers had prime factor of 2.)
LCM of 2 and 9 is ... doesnt have one?
Ok trying again.....
nope i cant make the algorithm succeed but be wrong, but it can for lists fail to find an LCM when there is one.
Spoiler: alt alg no code- AxleGreaser
-
AxleGreaser Mafia Scum
- AxleGreaser
- Realeo
-
Realeo Jack of All Trades
- Realeo
- Jack of All Trades
- Jack of All Trades
- Posts: 5238
- Joined: February 11, 2016
- Location: Indonesia
Can we have a coding competition? I mean, like the ICM ICPC or Google Jam or Codeforces style? I think some site lets us to host one?"The debate on whether short multi postings or a long wall of post is good or not is like a debate on gun control--we would never understand each other and we have to make peace with it." -Realeo
I'm mabye a serious player, but I'm capable of joke. Ok?- Frozen Angel
-
Frozen Angel SheQueen Shifty
- Frozen Angel
She- Queen Shifty
- Queen Shifty
- Posts: 18753
- Joined: October 26, 2015
- Pronoun: She
Its doable.
even in this site and theme
we need to choose a team for making the questions and stuff and asking to see if people are interested or not.False tears bring pain to those around you
False smile brings pain to one's self
"Frozen Like Your Heart." -Ginngie- Flubbernugget
-
Flubbernugget Survivor
- Flubbernugget
- Survivor
- Survivor
- Posts: 11751
- Joined: June 26, 2014
Shameless bump. Updating the OP with Ircher's problem and crediting Realeo with the solution.
I would have to look into the rules of the coding competition to see how it would be modded on the side and how much work that would take before I offer hosting/modding. Consider me interested at the least.- Realeo
-
Realeo Jack of All Trades
- Realeo
- Jack of All Trades
- Jack of All Trades
- Posts: 5238
- Joined: February 11, 2016
- Location: Indonesia
What came to my mind was Project Euler style competition.Flubbernugget wrote:Shameless bump. Updating the OP with Ircher's problem and crediting Realeo with the solution.
I would have to look into the rules of the coding competition to see how it would be modded on the side and how much work that would take before I offer hosting/modding. Consider me interested at the least.
Preface:
Most common OJ ask you to upload the code an let the judge compiles it for you. Euler just posts the test case and he just asked you for your solution.
Like Google Jam, but if GJ you only have 5 minutes to submit the answer after you downloaded the .in, Euler-style let you submit your answer at any point that you want.
Format:
We will have problem call where user can send in problem. Each user can have max. 1 problem accepted.
Material that will be our person of interest.
Code: Select all
[*] Ad-Hoc [*] Geometry [*] Math [*] Brute force [*] Divide & Conquer [*] Searching (ie. Binary search) [*] Dynamic Programming [*] (anything else that I forgot)
Then competition day. We will release the problem and give 1 weeks to compete. They can submit their answer via PM.
Each correct answer worth 100 points. But 3 most difficult problem worth 125 points instead. Player who send in the problem is automatically credited with correct answer.
The winner is the one with most point.
A primitive programming, if OJ is not a solution."The debate on whether short multi postings or a long wall of post is good or not is like a debate on gun control--we would never understand each other and we have to make peace with it." -Realeo
I'm mabye a serious player, but I'm capable of joke. Ok? - Realeo
Copyright © MafiaScum. All rights reserved.
- Flubbernugget
- Frozen Angel
- Realeo
- AxleGreaser
- Realeo
- Ircher
- Ircher
- Plotinus
- Realeo
- Ircher
- yessiree
- Kagami
- Kagami
- Kagami
- AxleGreaser
- Kagami
- AxleGreaser
- Kagami
- Kagami
- Kagami