/dpt/ - Daily Programming Thread

PRIME FIZZBUZZ V2: CONTINUED INCOMPETENCE EDITION
{ f(x) | x i don't understand
Don't call us, we'll call you

Previous thread

>ever checking prime(x) ∧ (x % 15 = 0)
>checking 3 and 5 on every iteration instead of just printing them at the start
retard

Fuck off with this aborted meme faggot, changing the braces doesn't make it better, and it's shit anyway, just stop stop stop and stop!

Ok, what are percentages doing there, why is this shit a fucking SET{} ffs and more broadly wtf? How are strings math?

"No."

>fucking spergs arguing about useless fucking labels "hurr you're not allowed to call it OOP if there are some parts that aren't """"100% pure OOP"""""

ITT: Haskell users fail to understand mathematics

yep FP fags are fucking delusional, they think they're so smart and competent when they're in fact stupid for not realizing how shit FP is

Sh-Shut UP you NERD.

What does Haskell have to do with anything?

Haskell =/= FP

I remember when trolls used to put effort into their posts.

I think the anons who reacted to this shitty OPcode and brought in Haskell did it precisely because they didn't know Haskell enough to recognize that it wasn't Haskell, but maybe you'd like to pretend like you're not awfully retarded?

it's as shitty as haskell code though

>no u

Why is it that in C/C++ declarations go in a .h file and definitions go in a .c file? Why shouldn't you put both in one file?

Because you don't need the function to be defined ahead-of-time to use it, the linker will make everything work in the end.

Though, yes, the C/C++ way of doing things is horrible compared to a proper module system.

#include, that's why. Nothing's stopping you from including a .c file tho, it's just that it doesn't allow separate compilation. Look it up.

How am I supposed to use this in python?
My POST data usually looks like
payload = {'username':'derp','password':'123456'}
Please, someone give me an example of how to post on Sup Forums using python.

you know you're not allowed to auto post on Sup Forums right

Help a python newbie here
Exercice:
- if a 0 is found in a list include the adjacent elements
- however, if the element next to 0 is another 0 include all the elements until a 1 appears
- print the new list formed
- your program should check the cases where a 0 is found at the last position of the list

example:
lst = [1,0,1,1,0,0,1,1,1,0]

1º case: your_list = [1,0,1] because ([1,0,1,-,-,-,-,-,-,-])
2º case: your_list = [1,0,0,1] because ([-,-,-,1,0,0,1,-,-,-])
3º case: your_list = [1,0,1] because ([1,-,-,-,-,-,-,-,1,0])


my solution:


def solve(lst):

my_list = []
for i in range(len(lst)):
if (lst[i] == 0 and lst[i+1] == 1):
my_list.append(i-1)
my_list.append(i)
my_list.append(i+1)
print my_list
else:
if (i ==len(lst)-1):
if (lst[i] == 0 and lst[0] == 1):
my_list.append(i-1)
my_list.append(i)
my_list.append(0)
print my_list

any help please?

if i have a list of numbers
nums = [45,3,5,2,1]

but I'm trying to sort

nums.sort(cmp=lambda x, y: cmp((x+y), (y+x)))


what is the x and y in this?

How do mobile applications do it?

I'm not going to auto-post.

>I do Multiparadigm and would prefer to call it OOP
I find this a rather striking contrast to FP people. They do the opposite. They discriminate heavily because they're confident in their programming paradigm. Post a (clearly non FP) procedure and claim it's functional here. See what happens.

Same generally doesn't happen with OOP. People don't complain that you're not encapsulating your data because they know it's a shit paradigm.
>if it's overwhelmingly or primarily based on OOP you could label it as OOP
Sounds more like it has large chunks of OOP or is 'mostly OOP'. Depends. But either of those are far more descriptive and accurate than 'it's OOP' as you point to you accessing a public variable from a singleton class declared at global scope. Which I don't object to your doing. But I don't think it's OOP.

Go ask someone who you trust about this.
Fair enough. They wasn't my understanding of FP. I don't do it on principle so it never occurred to me really. But I've been told you're allowed to modify input for some reason. Doesn't matter, I yield that I don't know FP that well aside from how my code breaks the rules sometimes. I understand why I think FP is nice but I thought that was a digression you made or something.

anonymous members.

you're using lambdas and you don't know what they are?

there's a Sup Forums API

It's read-only.

>useless fucking labels
>and he argues why things are OOP not Multiparadigm
Again, OOP fags trying to steal the glory from real paradigms. Go write yourself a gf or some shit. I'l enjoy the thought of you attempting to have relations with your imaginary representation for data.

kill yourself you insufferable sperg

>People don't complain that you're not encapsulating your data because they know it's a shit paradigm.

>You don't force yourself to use every aspect of a thing as much as you can, all the time, so it's shit.

LOL

No good reason anymore. But there's so much stuff that relies on it that you do it anyway.

You could put everything in any type of files and include that. Assuming the compiler would try to read regardless of extension.

His word was "because", not "so".

I've looked at the source code for a few of them, they scrape the captcha, it's not all that hard.
(me ) I just have never used multiform-data? I don't know how. What I've tried so far doesn't really work.
I can scrape the captcha, though

And the logical implication is the same, faggot.

you only need header files for things that are exposed as "interfaces" so that you can include the header from other files

...

Well the reason you don't is because it's flawed. Well, I suppose it's not really 'flawed'. You can do it its just incredibly inconvenient or slow.. How are you not understanding this user?

It's like you're disagreeing just for the heck of it.
It's almost like you're just pretending to be retarded or something.

>(A => B) (B => A)
Ah yes.

It's almost like your understanding of how OOP can be used is fundamentally flawed.

>kys
>you're too correct and I can't argue yet I'm heavily invested in this discussion so I feel obligated to make a non-reply as if I'm taking a stance because I'd feel like a quitter if I don't.
When you accept that you're a pathetic flawed human being who (somehow) thought computers can deal with objects sensibly everything becomes so much simpler user.

yeah everyone except you is disagreeing with you just for the heck of it... keep believing that and keep wasting your time on this inane argument

we've been over this countless times

you're a clueless arrogant idiot

1) Mod
2) How are numbers maths?

Makes it more obvious it is mathematics

Soo give me an example of how OOP (neatly) solves a problematic message structure? Where you need to pass a message up the structure rather than down at the leaves.

Preferably one of your own. Ignoring more pressing issues (when doing multiparadigm and involving OOP) it's my biggest concern and is why I find it pointless to do OOP even if it had the predictability it claims.

today I learned to comment code instead of deleting it.

return message;

See I'm posting on Sup Forums because I like it. It's as much wasted here and now as if I wasn't having the argument.
Regardless I somehow doubt someone would just go down to throwing insults with no substance over and over if that's what they did. If they find it enjoyable power to them I say.

kys

>tfw storing 10+ comment blocks containing previous implementations below your code
I'm happy I can avoid searching comment blocks in atom though. It'd be a real pain.

the absolute madman.

messageReceiver.passMessage(message);

>statement based language

HALP

Now we're just getting spammy but this post:
Accurately responds to the message you just sent. I'd consider reading it if you want a good estimate of my response.

1) then write mod like everyone else thank you
2) There is a nontrivial thing called number theory? How do strings have any property worth a mathematical analysis? They are meant for human consumption in programming, and they're a trivial arbitrary concept, unlike numbers which are simple yet fundamental and powerful. How is using strings not absolutely uncharacteristic of abstract mathematic and proper to computer programming?

stay delusional

>In formal languages, which are used in mathematical logic and theoretical computer science, a string is a finite sequence of symbols that are chosen from a set called an alphabet.

is this anyhow acurate?

1) % is more concise
2) Any structure is a mathematical structure

public String message(String message){
return message;
}

let id x = x

id

>assembly isn't portable
Then how come rollercoaster tycoon works on any computer that meets minimum specs, even modern computers?

backwards comparability & multiple sources

Explain

it works on x86, not on other architectures

the code that i wrote with String message, return message is totally useless. There is no point in return, since in returning the message you have to put in the message. You are basically writing message twice, i was trolling you

Most architectures only expand the instruction list (and sometimes deprecate very few instructions) & it was likely written multiple times

that's what id does
returns what it's given

So if I were to write a program for the i386 processor, I would work on even an i7, yes?

i think so yes

but it wouldn't work on e.g. ARM

whats the point of that? I dont understand user. Why return something you already know?

Yes.

Sup Forums, what algorithm would you use to curve an image so that it fits an existing, background image?

I'm writing a program to put a logo onto a glass bottle (yes, this is coursework). How can I curve the edges so that it looks like it wraps around the bottle, rather than just being flat?

useful when working with higher order functions (functions that take functions as parameters)

fragment shader in opengl

model the curved surface and read the texture coordinates according to how the image is mapped to the surface

You need to figure out what the question is asking before you can program it. It's kind of ill-defined.

In my understanding, it's saying something like... go through the input list, if you find a 0, then start a new sublist with that 0 and the immediately adjacent elements. For each of those immediately adjacent elements, if it's also a 0, then keep adding elements in that direction to the sublist until you either reach a 1 or (if there are no 1s in the input list) you've wrapped around such that the sublist is the entire input list. Then output that sublist, and skip to the next element you haven't yet considered, or if there are none, terminate.

Which means:

list = [1,0,1,1,0,0,1,1,1,0]
results are
[1,0,1]
[1,0,0,1]
[1,0,1]
as given

list = [0,0,5,1,0,1]
results are
[1,0,0,5,1]
[1,0,1]

list = [0,0,0,1,0,0]
result is
[1,0,0,0,0,0,1]

list = [0,0,0]
result is
[0,0,0]

Etc.

If that understanding is correct, that should tell you something about how to structure the solution and what you're currently doing wrong.

Oh i see now, iv never dealt with high order functions. Thx for explaining

Awesome, were there architectures with major changes/removing a lot of older instructions or will any older processor be guaranteed to be compatible with a newer one.

For instance, map /fmap can be used (this is specifically for lists, it works with other functors) to transform every element in a list

map (+1) [2,3,4,5] = [3,4,5,6]
map (*2) [2,3,4,5] = [4,6,8,10]
map (%3) [2,3,4,5] = [2,0,1,2]

map id preserves the structure
map id [2,3,4,5] = [2,3,4,5]
so if you're writing something that can be mapped, you want map id x = x

>list = [1,0,1,1,0,0,1,1,1,0]
>results are
>[1,0,1]
>[1,0,0,1]
>[1,0,1]
>as given
thats correct


>list = [0,0,5,1,0,1]
>results are
>[1,0,0,5,1]
>[1,0,1]
No. the list only have zeros and ones. in the case of [0,0,5,1,0,1] it would be [1,0,1]

>list = [0,0,0,1,0,0]
>result is
>[1,0,0,0,0,0,1]
no result here.
you only want to add elements to the sublist if the 0 is surrounded by ones


sorry about the confusion

>still no solution
yet further proof that /dpt/ is now full of retards

for (int i = 1; i i % n.Item1 == 0);

if (x.Count() == 0)
Console.Write(i);
else
Console.Write(string.Join("",x.Select(e => e.Item2)));

Console.Write(Environment.NewLine);
}

>no, the list only have zeros and ones
Making an assumption like that will bite you in the ass one day unless the language you're working in can enforce it. Python cannot. Accommodating elements that are neither 0 nor 1 is easy given the exercise spec anyway.

>in the cast of [0,0,5,1,0,1] it would be [1,0,1]
No, it would be as I stated it originally. Consider the first element, which is a 0. The left adjacent is 1, so stop there. The right adjacent is 0, so keep expanding right until you hit a 1 or you have to stop because no 1s are to be found. Thus, [1,0,0,5,1].

>you only want to add elements to the sublist if the 0 is surrounded by ones
That's not how you specified the exercise. If a 0 has another 0 adjacent to it, you need to include further elements in that direction until you hit a 1.

For the last fucking time, read the god damn problem description

public static String fizzbuzz(int yourNumber){
String fizzbuzz = "";
if(yourNumber % 3 == 0){fizzbuzz = "fizz";}
if(yourNumber % 5 == 0){fizzbuzz += "buzz";}
return fizzbuzz;
}

What's the problem description?

Hey guys I made the bestestest OOP FizzBUzz
#include
#include
#include

using namespace std;

class FizzBuzz {

private:
bool isDivByThree;
bool isDivByFive;
int n;

public:

FizzBuzz(int n) : isDivByThree{!(n%3)}, isDivByFive{!(n%5)}, n{n} {};

bool getIsDivByThree() { return isDivByThree; }
bool getIsDivByFive() { return isDivByFive; }
int getN() { return n; }

};

ostream &operator

For the last fucking time, suck my dick

see this why are you doing so much extra shit?

>using namespace std
kys

Are you fucking gay or something? No, faggot

...

this is an epic meme and I really hope it never ends
why not? it's a shit exercise and I was bored, wanted to make it as unnecessarily OOP as possible

I think my next attempt will even have inheritance and templates
what else could I put in there?

Maybe one day you can learn about source control.

inheritance and an interface. Make separate classes for fizz and buzz.

>implying 'using namespace std' isn't the epic meme

The answer is obviously MAX_BUF.

GTP, please save us from this hell and implement a solution to OP

What the fuck do they want? Forward slash means nothing afaik. do they want name/.extension ? cause I can't have that sort of filename in linux

What is even the OP's question?

A solution to what?

actually, your massive autism is the epic meme