How would one go about solving this with programming?

how would one go about solving this with programming?
one can use any language btw

Other urls found in this thread:

en.wikipedia.org/wiki/Dynamic_programming
asciitable.com/
twitter.com/AnonBabble

if (5*6 != 4*7) {print("This is an unsolvable problem retard")}

Look up tessellation of Tetrominoes, copy algorithm.

Probably best to represent the grid as a 1 dimensional array. Create a list of all of the valid positions / rotations of the pieces, and find a set of disjoint arrays whose union is an array of all 1's.

/thread

did u read the problem

>you can reuse them
fill space with yellows or cyans
programming faggots have shit all over /g.. tis a pity.

What's wrong with this method? I'm dumb

>5x6 grid = 30 cells to fill
>7x4 blocks = 28 cells available
>time wasted: 10 seconds counting
did I pass the autism test?

it takes a new string with the data "string" instead of the input, it does return the result and instead prints the entire string 1 character at a time (and not even reversed)

did you?

en.wikipedia.org/wiki/Dynamic_programming

>you can rotate any block and reuse them
you're an utter failure and fit right in with the future society from idiocracy.

>The box is completely filled
check
>No blocks are overlapping
check

What do I win?

Please explain how this makes 30 a multiple of 4

>instead prints the entire string 1 character at a time (and not even reversed)
I don't think so.
s is an array; s[N] is just an integer; printf("%s",s[N]) will ask the program to print the string at memory address s[N], which for 's' is 115, for example. The program will either print trash and crash, or will just crash with segfault.

someone who can't do simple math problems doesn't have the right to call other people an idiot

Re-read his post, out loud if you have to. If that still doesn't work then look up the definition of each word in the greentext until you figure it out.

Is this what they call “thinking outside the box”?

The amount of blocks created by placing rotated and reused tetris shapes can be 28 or 32, but not 30, so his reasoning stands.

Wait how does a char array contain integers? I'm a Java college codemonkey I don't know a lot about C

A char is promoted to integer when you send it to function with variable arguments in C; printf here.
Also, although unrelated, in C, the type of character constant (like 'x') when you just use it as a character constant in code is int, not char.

The post said nothing about being allowed to split up pieces, so assuming you can't overlap the border like , your best choices are 7x4 = 28 or 8x4 = 32, neither of which are 30

Fuck off if you can't into basic logical reasoning

A char is a 1-byte integer. You store a number from 0 to 255 in it, and the computer interprets it as a character, based on the ASCII encoding table.

asciitable.com/

Interesting. Does C allow casting it as char inside printf so that it works properly?

Re-read his post, out loud if you have to. If that still doesn't work then look up the definition of each word in the reply until you figure it out.

>CS majors are that stupid

the box isn't completely filled

>didn't even solve the problem

Welp. Yes, you can cast it as char. and it will still be promoted to that after it.
It works "properly" when you use "%c" mask instead of %s", with or without casts.
"%s" asks the program to interpret the argument as memory address and print out a C string at that address: printf("%s",s);
"%c" asks the program to interpret the argument as character code and print out that single character: printf("%c",s[N]);

...

>and it will still be promoted to INT after it.
Fixed.

WTF I hate Tetris now.

var brain = require('brain.js');
var net = new brain.NeuralNetwork();

net.train([{input: [[2, 2], [[1,1,0,0],[1,1,0,0]]], output: {
[[1,1,0,0],[1,1,0,0]]: [[0,0],[2,2]]}},
{input: [[4, 2], [[1,1,1,1],[1,1,1,1]]], output: {
[[1,1,1,1],[1,1,1,1]]: [[0,0],[4,2]]
}}]); //Todo generate code or something

var output = net.run([[5,6], [[1,0,0,0],[1,1,1,0]], [[0,0,1,0],[1,1,1,0]]]); //etc
console.log(output);


kinda like that

>neural networks in Javascript
Fuck the JS cancer. It has spread too far.

>string is hard-coded, rather than read from stdin or passed as a command line argument
>string length is hard-coded, rather than using strlen()
>function doesn't actually store the reversed string in a variable (which it should, as that's more general-purpose than printing to stdout)
>do while loop used when a for loop or plain while loop would suffice (minor issue, but do...while loops seem awkward when a more common loop type would work instead)
>printf statements prints the string forward, not in reverse (something like s[place--], with place starting at 6, would have to be used instead
>printf uses the %s format specifier even though it's only printing 1 char at a time and so should use %c

C chars are just small integers (usually 8 bits) that are usually interpreted (depending on context) as the character of the corresponding ASCII code. So when you type char c = 'a', that really means "there is an 8-bit integer, c, containing the ASCII value of 'a'".

And if you print it as an integer, using printf("%d", c), it will show that integer value. Printing it with %c, which is what should be done, will show it as a character.

But where it really gets tricky is that the %s format specifier means string, which in c is an array of chars. And arrays in C are passed as a pointer to the first element. So
char hello[] = "Hello, World!";
printf("%s", hello);

is fine, the printf function recieves a pointer to the hello[] array and is able to handle it properly as a string. But if the printf statement was istead printf("%s", hello[2]), it's receiving the value of a specific array element, and thinking it's a pointer. In this case,hello[2] is the character 'l', with ASCII hex value 0x6C, so printf will be looking for a string (char array) starting at memory address 0x6C (which is most likely not part of the memory the program has access to, resulting in a segfault).

are you really this stupid?
overlap the blue and orange horizontally
overlap blue and orange vertically
repeat until entire surface area is full

fucking idiot. go back to grade school
better yet, clean yourself from the gene pool. god forbid idiocracy actually comes to fruition.

what is c bad for?

this
java should've died 15 years ago
how is it so prominent today?!?!?!?

by overlap i mean fold them together, so that they take up 6 squares total.
when you realize this, you can realize how utterly moronic you are.
and please do teh world a favor, and remove yourself from the gene pool.
you're wasting earth LIMITED resources to continue your worthless existance.

>7 4 square pieces = 28 squares
>6x5 board = 30
cant be done

Make note of the third line of the text in OP picture.

I don't need to try it to know you're full of shit. I already proved mathematically that it's impossible.

Feel free to waste your entire life trying it.

Re-read OP's post, out loud if you have to. If that still doesn't work then look up the definition of each word in the image until you figure it out.

With C you write much more code compared to other language to achieve same results. So anything big. Of course, in some cases there just is no better alternative.

so, only use c for speed stuff?

That's how C is generally perceived, yes.

>what is c bad for?

whenever you have a constraint on time, it's better to use a more abstracted language that doesn't deal with the nitty gritty.

In an ideal world where we can debug for weeks and have development cycles lasting decades C would be amazing, atm C is not recommended whenever you need to put out an app and only have a week.

Stuff where performance doesn't matter. C is good at fiddling with details to crank out extra speed, but it takes a lot more effort to write.

Python, by contrast, is designed to be really easy to write, but runs slower.

The only way I can think is to do it via brute force checking/optimisation. Certain sized grids you might not be able to fill completely. I think 5×8 is the first one you can do.

What about 2x2? I think there is a way to fill that one also.

integer programming

u mean 8x4?

are you really this fucking stupid?
in no way are blue and orange overlapping.
this is comparable to teaching a dog how to write
dog's are probably smarter than your baiting ass.

>overlap the blue and orange

>in no way are blue and orange overlapping.

aaaaaaaaaaaaaaaaaaaa

It says no overlapping, didn't say it couldn't stick out the edge

cerr

do some basic thinking, bro.

the grid is 6x5 = 30 squares.
Each piece is 4 blocks. 7x4 = 28 squares.

I'll leave the rest up to you.

Whoops, realized it's a 5x6 graph and not 5x5
My bad yeah this pic is retarded

You couldnt solve it for 5x5 either, how much can you reason?

i can't wait for you to realize you can fold blue or orange together to form a 6 by 2 rectangle.

That's also a multiple of 4 so how is that gonna help you reach a sum that isn't?

This the person that keeps calling everyone retarded.
In his mind, he combines two four-block tetris shapes, without overlapping, to create a 6x2, 12-block rectangle. Bravo.

it's actually a 8 by 2 rectangle

but folding a orange or blue into one rectangle forms a 8x2 not 6x2

You cannot fill that box with tetriominos.
//takes 2 command line args, width and height of grid
int main(int argc, char **argv)
{
if (argc != 3) exit(1);
int w, h;
w = atoi(argv[1]);
h = atoi(argv[2]);

if (w*h%4 != 0) exit(1);
solve(w, h);
}

void solve(int w, int h)
{
//todo
}

congratulations you win.

post dont say it can not be out the box.

>you're wasting earth LIMITED resources to continue your worthless existance.

This is a silly thing to say. The Earth doesn't own anything, the people do. People voluntarily trade their resources in exchange for other resources of for labor. If user does work and buys property, he is not wasting Earth's resources; he is using HIS resources -- resources that belong to him and only to him, and only he can decide how they are used.

>if (5*6 != 4*7) {print("This is an unsolvable problem retard")}
>you can reuse them
wouldn't 5*6 MOD 4 != 0 make more sense?

Fill it with blue L's, you dumb fucks.

>wouldn't 5*6 MOD 4 != 0 make more sense?
wouldnt true make more sense?

Can we sticky this thread to prove just how fucking retarded Sup Forums really is?

5*6 = 30
30/4 = 7.5

You need 7.5 blocks to fill it.
No need to even start programming.

easy

Find your nearest 5 year old and ask him to show you how to count up to 4.

...

Am i doing it right, senpai?

I'm retarded. Ignoring the fact that this particular case is unsolvable, I didn't realize how simple the algorithm would be if one just counted to 4.

this puzzle cannot be solved without pieces hanging out the box, in which case the puzzle is retardly easy.

Nope, division is slow.

Nothing said about resize.

absolutely kekful post

Actual hacker detected.

>30 block grid
>every tetris block is 4 blocks in size
>7x4 = 28
>8x4 = 32
The only way to do it is like

because fuck you nobody said anything about overlap or resizing.

Java != Javascript

...

Do you mean != or !== or !=== ?

...

Actually yes, this is great example.

Nice.

someone run a constraint satisfaction solver on it

It's unsolvable because every time you complete a row it disappears.

...

>to fill completely requires 30 1x1 blocks
>you are not given enough pieces to fill completely