What are you working on?
Previous:
/dpt/ - Daily Programming Thread
Other urls found in this thread:
hg.python.org
cardiff.ac.uk
bbc.co.uk
rextester.com
csapp.cs.cmu.edu
gcc.gnu.org
bitbucket.org
github.com
github.com
twitter.com
I posted this in the end of old thread but I'm moving it here.
I'm trying to solve Problem 621 on Project Euler, and the code I've written works fine on numbers on the scale 10^9, but when I try numbers on the scale 10^10 it returns 0 no matter the number. Why does it do this? I need to get it working for numbers on the scale 10^14.
public class triangular {
public static int triSq(double x) {
return (int) Math.floor((Math.sqrt(8*x + 1) - 1)/2.0);
}
public static long tri(int n) {
return n*(n + 1)/2;
}
public static int comp(int a, int b, int c) {
int s = 0;
//System.out.println(tri(a) + " " + tri(b) + " " + tri(c));
if (a == b) {
if (b == c) s += 1;
else s += 3;
} else {
if (b == c) s += 3;
else s += 6;
}
return s;
}
public static long triCheck(long n) {
int s = 0;
int c = 0;
for (int a = triSq(n/3.0); a
nobody knows what 'problem 621 on project euler' entails, and your variable naming convention is a fucking mess. Good luck.
try using longs instead of ints
if longs aren't enough, try using BigDecimals
In triSq you are returning int casted from potentially huge number. Is it possible that there is an overflow? Maybe try long instead?
what are python lists in the underlying C code?
Arrays
Insertion is O(n)
You should read "No Silver Bullet" by Fred Brooks
use python and enjoy bignums by default
It was enough to change from ints to longs (at least for order 10^10), thankfully I didnt need to start messing with BigDecimals.
I'm not quite sure why ints dont work since the values from triSq shouldn't exceed that of an int but I'm guessing the casting is what is causing the overflow?
It's only 16 pages, sure I'll give it a read.
shit.
50% is /dpt/ is genius-tier smart.
Real hardcore C hackers.
What stops Fortune 500 companies from hiring everyone ITT for 200k starting?
It's an anonymous board
>being a wagecuck
>tfw to intelligent to earn 200k+
this. But unironically.
Would someone be able to have a quick look at this course and r8 it for me please?
cardiff.ac.uk
It doesn't have the normal modules Computer Science usually does, I'm wondering if it would be worth doing.
>A key distinguishing feature of this degree is that all theory, teaching and learning is explored through real world software development projects. Students work individually and in teams to manage, design, code, test and maintain high quality software.
This is hit or miss. Could be a very very good course, if the requirements are set very high and class isn't entirely made up of brainlets.
The course description seems to imply that only 1/6 get accepted.
I like that you think this deters me
The entry requirements are the same as Computer Science. Apparently it's a new course I'm just a bit sceptical about it.
bbc.co.uk
I did something like this, in latin america. It's decent if you don't mind being a wagekek running proprietary software.
Like the other user say, it's a hit or miss. I enroled in what was a pretty new course, and my experience was extremely mixed. Some parts were well planned and thought out, other were utter shit and I had to pick up the slack on my own.
If I were able to go back in time, would I take it again? Yes. That's my personal experience though.
Thanks for the advice m8s I'll find out more at the open day. Do you think having a degree in software engineering prevent you from getting a job you could get with a computer science degree?
In most places you don't need a degree at all.
I know but there are a lot of graduate jobs that require a degree and look like they would be a great role to learn in.
what field doesn't require constant learning of new technology and framework like webdev?
The jobs that would require a degree barely care about the degree itself, as long as you have one.
Keep in mind that the degree requirement is just there to set the bar higher, if you have the experience or skill for the job, you'll probably get it regardless of the degree.
neetdom
Fair enough thanks for the advice mate
I'm stuck on a regex
I need to match all the strings that have more than x (3) new lines
(?:(?:\n)?[^\n]*){0,3}
(?m)[\n]{3,}
I have no idea sorry lad
Thanks, that helped a lot.
I'm trying to work out some ASM shit, however when i try to find a solution to a problem i'm having (i'm half sure it's caused by the fact i'm using an online gcc compiler) i find various different syntax for if (one has "asm{}, another __asm, another has __asm__, one uses ";", another "\n" etc etc etc) and obviously they don't work nice with each other
What i'm trying to do is, in inline assembly with C using a gcc compiler (so the __asm__(code :output :input :clobbered); form i think) is:
1) make a char array in C
2) pass the address of the first element of the array to the EAX register
3) move 4 bytes in the EBX register (and output it into a variable)
4 move 1 byte in the ECX register (and output it into a variable)
The problem is that it segfaults and i do not know if the problem lies in the compiler or code
es:
int main(){
char array="hello";
int b,c;
__asm__(
movl (%%eax), %%ebx //move the first 4 bytes (so the binary for "hell") in EBX
movb (%%eax), %%cl //move the letter "h" in the least significant bits of ECX
: "=b" (b), "c" (c) //the outputs, both in integer form
: "a" (array) //move the address of the array in EAX
: //clobbered nuthin
);
printf("%u\n%u"b,c)
}
Unfortunately it segfaults and i can't pinpoint the cause
I'm using this because i do not have access to a linux machine at the moment
rextester.com
Oh, and like an idiot i forgot:
each ASM instruction is terminated by a ";" and enclosed by ""
>es: "movl $4, %%eax;"
inlined assembly is a compiler extension and not in standard, maybe look at clang and gcc docs to find recommendation on how to do it.
Here is a quick info from Computer Systems: Programmer's Perspective book, maybe you can find something valuable there.
csapp.cs.cmu.edu
their syntax for GCC is:
asm("movq %[x],%%rax # Get x\n\t"
"mulq %[y] # Unsigned long multiply by y\n\t"
"movq %%rax,%[p] # Store low-order 8 bytes at dest\n\t"
"setae %[b] # Set result"
: [p] "=m" (*dest), [b] "=r" (bresult) /* Outputs */
: [x] "r" (x), [y] "r" (y) /* Inputs */
: "%rax", "%rdx" /* Overwrites */
);
absolutely disgusting
A bit helpful but not by much, it's very different from what i know in certain areas (the [name] in front of the register at the input/output declaration and the absence of the ;" at the end of every instruction)
and there it is in GCC manual
gcc.gnu.org
HRT and fursuits will save programming.
I am working on generating tilesheets and analyzing how they perform when they are used to import images by Playscii, an ASCII art program, which can also import bitmaps.
I'd like to write my own import function, I'm using R but for this section I'd probably drop down to C for speed.
Anyone got some tips on how to import an image as tiles in a tilesheet?
I don't really know python but his source code is at bitbucket.org
It seems to be: Divide up the image into regions the size of the tiles, look at a region and find the best fitting tile, and put it there.
Here's every possibly 3x3 tile, there's 2^(3*3) of them.
>tfw lost passion for programming
I haven't programmed for fun in almost a year. Work does really ruin everything.
Thank god for someone to blame, right?
I'm pretty disillusioned too...
learn a language completely different than the one you use for work
post the oldest code of yours you can find
Is tech just not an honorable profession? After so many rejections despite nailing the interview I am starting to see that it truly does not matter how much you actually know programming. Is everything just a matter of race or politics?
dynamic typing is so awkward and unnatural
I've been thinking of getting into setting symbols for spacing, this looks pretty good, with the vertical line for tabs.
What is this in?
those tab renders are pretty ugly
Actually this one's older, but I have no fucking clue what's going on here — is the System::/Console::/^ some kind of weird Windows thing?
ST3
It's not my normal color scheme, which has them a color only slightly different from the background
This ^ syntax is C++/CLI. It's a weird C++ dialect for the C# runtime.
no, it's who you know/ nepotism.
keep trying lad. Or just look into freelancing sites.
Interesting, it was a file left over from a class I took like my second semester of college. I may not have even written that code, could have been something for us to test the VC++ setup.
meant for sorry
>Interesting
Not really
>returning non-zero for success
>not defining data Result = Correct | Incorrect
>redefining booleans
>using bare booleans
>not redefining Booleans
optrional< correct_monostate >
I have a function func(void *a)[/code
ais received from another function. How do I printfthe value of a?
>not having your program be total
the absolute state
Whom are you quoting?
>Whom quotest thou?
FTFY
it's not quoting, meme arrows are how you establish "facts" in the "imageboard" programming language
in a sense it's the unsafeCoerce of the language
>>print statement debugging
regarding 66657222
this seems to be a quote, but who exactly is it quoting?
>this seems to be a quote
I think I may have identified your misapprehension. The post to which you refer contains no quotes nor attempts at quotes.
Find a better way to make money. Sooner or later the chinaman is just going to flood the market with cheaper alternatives anyways.
Simple discord bot
>github.com
The code on github isnt with the classed that i import.
Nobody, outside of your mom's basement, needs another autistic C/Haskell/Erlang nerd. All Fortune 500 boys want is a nimble python homie :3
thanks for the laff
Stop smoking weed
in general, your skill level matters much more than language choice
>try to get [big library] to work
>can't
what do most people do when this happens? just give up?
read the docs
sure buddy
Are there any pure SQL devs? Isn't that like a sysadmin?
or DBA maybe
>Are there any pure SQL devs?
I assume that includes stored procedures written in PL/pgSQL or other languages, optimizing complex queries for very large data sets, and so forth
Thanks for all the quotes
How to make it so that my software can be installed (into Program Files and all that)?
this is not a /Stupid Questions/ thread
If you name your variables single letters it produces more compact bytecode and yields better performance.
If you name your variables like,
a1
a2
a3
..
then they become invalid variables behind the scenes, resulting in an even better bytecode and thus performance
What's wrong with your second solution?
\n{4,} should be enough, if you mean strictly more than 3
There are people paid to write 'advanced SQL' yes. DBA is a dying art, almost every dbms is going to be autonomous. They even use AI now to optimize Postegres, Sap-Hana, MySQL and other dbms github.com
use somethign to create a .msi file out of your package
it works for 3 consecutive new lines,
I need something that tells me if my string has more than x (3) lines
I don't have a car and my town has 0(zero) tech companies
closest ones are a city over
(.+\n){4,}
How does this sound?
that's what I meant! thank you, really
where have you learned regex?
at you're momas house