/script>
[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

how would one go about solving this with programming? one can

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 94
Thread images: 14

File: tetris challenge.png (55KB, 1079x966px) Image search: [Google]
tetris challenge.png
55KB, 1079x966px
how would one go about solving this with programming?
one can use any language btw
>>
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.
>>
File: 1471663262539.png (73KB, 694x801px) Image search: [Google]
1471663262539.png
73KB, 694x801px
>>56236858
/thread
>>
>>56236858
did u read the problem
>>
>>56236824
>you can reuse them
fill space with yellows or cyans
programming faggots have shit all over /g.. tis a pity.
>>
>>56236925
What's wrong with this method? I'm dumb
>>
>>56236824
>5x6 grid = 30 cells to fill
>7x4 blocks = 28 cells available
>time wasted: 10 seconds counting
did I pass the autism test?
>>
>>56237033
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)
>>
>>56236955
did you?
>>
>>56236824
https://en.wikipedia.org/wiki/Dynamic_programming
>>
>>56237050
>you can rotate any block and reuse them
you're an utter failure and fit right in with the future society from idiocracy.
>>
File: autism.png (45KB, 1079x966px) Image search: [Google]
autism.png
45KB, 1079x966px
>>56236824
>The box is completely filled
check
>No blocks are overlapping
check

What do I win?
>>
>>56237103
Please explain how this makes 30 a multiple of 4
>>
>>56237033
>>56237055
>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.
>>
>>56237103
someone who can't do simple math problems doesn't have the right to call other people an idiot
>>
>>56237112
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.
>>
>>56237104
Is this what they call “thinking outside the box”?
>>
>>56237144
The amount of blocks created by placing rotated and reused tetris shapes can be 28 or 32, but not 30, so his reasoning stands.
>>
>>56237129
Wait how does a char array contain integers? I'm a Java college codemonkey I don't know a lot about C
>>
>>56237169
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.
>>
>>56237144
The post said nothing about being allowed to split up pieces, so assuming you can't overlap the border like >>56237104, your best choices are 7x4 = 28 or 8x4 = 32, neither of which are 30

Fuck off if you can't into basic logical reasoning
>>
>>56237169
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.

http://www.asciitable.com/
>>
>>56237195
Interesting. Does C allow casting it as char inside printf so that it works properly?
>>
>>56237144
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.
>>
File: Untitled.png (47KB, 1079x966px) Image search: [Google]
Untitled.png
47KB, 1079x966px
>>56236824
>CS majors are that stupid
>>
>>56237254
the box isn't completely filled
>>
>>56237254
>didn't even solve the problem
>>
>>56237249
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]);
>>
File: 1471231890313.png (209KB, 3757x2411px) Image search: [Google]
1471231890313.png
209KB, 3757x2411px
>>56237145
>>
>>56237289
>and it will still be promoted to INT after it.
Fixed.
>>
WTF I hate Tetris now.
>>
>>56236824
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
>>
>>56237416
>neural networks in Javascript
Fuck the JS cancer. It has spread too far.
>>
>>56237033
>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

>>56237169
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).
>>
>>56237134
>>56237112
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.
>>
>>56237651
what is c bad for?
>>
>>56237452
this
java should've died 15 years ago
how is it so prominent today?!?!?!?
>>
>>56237772
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.
>>
>>56236824
>7 4 square pieces = 28 squares
>6x5 board = 30
cant be done
>>
>>56237803
>>56237772
Make note of the third line of the text in OP picture.
>>
>>56237772
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.
>>
>>56237772
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.
>>
>>56237788
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.
>>
>>56237867
so, only use c for speed stuff?
>>
>>56237933
That's how C is generally perceived, yes.
>>
>>56237788
>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.
>>
>>56237788
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.
>>
>>56236824
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.
>>
>>56238022
What about 2x2? I think there is a way to fill that one also.
>>
>>56236824
integer programming
>>
>>56238022
u mean 8x4?
>>
>>56237839
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.
>>
>>56237772
>overlap the blue and orange

>>56238255
>in no way are blue and orange overlapping.

aaaaaaaaaaaaaaaaaaaa
>>
>>56236858
It says no overlapping, didn't say it couldn't stick out the edge
>>
>>56237278
>>56237280

cerr<<" n % 4 ≠ 0 ";
while("CS is a shit") cout<<"\a";
>>
>>56237278

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.
>>
>>56236858
>>56238305
Whoops, realized it's a 5x6 graph and not 5x5
My bad yeah this pic is retarded
>>
>>56238312
You couldnt solve it for 5x5 either, how much can you reason?
>>
>>56238311
i can't wait for you to realize you can fold blue or orange together to form a 6 by 2 rectangle.
>>
>>56238458
That's also a multiple of 4 so how is that gonna help you reach a sum that isn't?
>>
>>56238458
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.
>>
>>56238632
it's actually a 8 by 2 rectangle
>>
>>56238458
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
}
>>
File: 1407618897346.jpg (22KB, 230x470px) Image search: [Google]
1407618897346.jpg
22KB, 230x470px
>>56237104
congratulations you win.

post dont say it can not be out the box.
>>
>>56237803

>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 Anon 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.
>>
>>56236858
>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?
>>
>>56236824
Fill it with blue L's, you dumb fucks.
>>
>>56239525
>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 /g/ really is?
>>
>>56236824
5*6 = 30
30/4 = 7.5

You need 7.5 blocks to fill it.
No need to even start programming.
>>
File: 1472011681807.png (72KB, 1041x966px) Image search: [Google]
1472011681807.png
72KB, 1041x966px
easy
>>
>>56239739
Find your nearest 5 year old and ask him to show you how to count up to 4.
>>
File: 1472011681807.png (47KB, 1079x966px) Image search: [Google]
1472011681807.png
47KB, 1079x966px
>>56236824
>>
File: 1472011681807.png (60KB, 1079x966px) Image search: [Google]
1472011681807.png
60KB, 1079x966px
>>56236824

Am i doing it right, senpai?
>>
>>56239819
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.
>>
>>56236824
this puzzle cannot be solved without pieces hanging out the box, in which case the puzzle is retardly easy.
>>
>>56239525
Nope, division is slow.
>>
File: 1.png (66KB, 1079x966px) Image search: [Google]
1.png
66KB, 1079x966px
>>56236824
Nothing said about resize.
>>
>>56242126
absolutely kekful post
>>
>>56242126
Actual hacker detected.
>>
File: 1400439739287.gif (45KB, 498x336px) Image search: [Google]
1400439739287.gif
45KB, 498x336px
>>56236824
>30 block grid
>every tetris block is 4 blocks in size
>7x4 = 28
>8x4 = 32
The only way to do it is like
>>56237104
>>56239850
>>56242126
because fuck you nobody said anything about overlap or resizing.
>>
>>56237790
Java != Javascript
>>
File: 1472011681807.png (57KB, 1079x966px) Image search: [Google]
1472011681807.png
57KB, 1079x966px
>>56236824
>>
>>56242538
Do you mean != or !== or !=== ?
>>
File: 1472011681807.png (90KB, 1079x1589px) Image search: [Google]
1472011681807.png
90KB, 1079x1589px
>>
>>56237145
Actually yes, this is great example.
>>
>>56242126

Nice.
>>
someone run a constraint satisfaction solver on it
>>
It's unsolvable because every time you complete a row it disappears.
>>
File: nedry.jpg (50KB, 899x489px) Image search: [Google]
nedry.jpg
50KB, 899x489px
>>56244507
>>
>to fill completely requires 30 1x1 blocks
>you are not given enough pieces to fill completely
Thread posts: 94
Thread images: 14


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.