[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 38
File: yF1VCTm.jpg (89 KB, 1366x768) Image search: [Google]
yF1VCTm.jpg
89 KB, 1366x768
Old thread: >>51634136

What are you working on, /g/?
>>
Compilers can be written in any language

See:

https://en.wikipedia.org/wiki/Glasgow_Haskell_Compiler
>>
Killing niggers
>>
File: solution.png (14 KB, 851x330) Image search: [Google]
solution.png
14 KB, 851x330
>>51640760
http://pastebin.com/z1H0turv
NEW ALGORITHM
Efficiently calculates min/max of 10 numbers
>>
>>51640760
TOO SOON YOU FUCKING RETARD

BUMP LIMIT IS 310 NOT 299 AND AT THIS TIME OF DAY THE THREAD IS GOOD UNTIL IT HITS PAGE 4 OR MORE
>>
>>51640800
Please tell me you automated this
>>
>>51640798
good luck moonman
>>
File: boggle_bot_1.webm (844 KB, 1920x1072) Image search: [Google]
boggle_bot_1.webm
844 KB, 1920x1072
My bot, she is getting stronger.
>>
>>51640819
The bit in the picture I typed out myself as I was discovering the algorithm, I copy and pasted, then replaced to get the rest. Notepad doesn't have a replace in selection so it took longer than I thought.

This will revolutionise the computer sciences.
>>
>>51640760
That's not a tranny, is it?
>>
>>51640860
Of course not.
Don't be silly.
>>
>>51640800
Anyone care to write a tool so that I can cat bad_code | cs_grad_meme ?
>>
>>51640800
>>51640819

not confirmed working btw, please test
>>
>>51640897
working on it

see you in 3 hours
>>
>C# 6.0 and the .NET 4.6 Framework, 7th Edition
>1625 pages

Is... is there a faster way?
>>
>>51640921
Ever seen the Matrix?
>>
>>51640902
If only there was a simpler, perhaps even equally efficient yet more general, way of finding the max and min of a list of integers. You could then use it to test against automatically.
>>
>>51640760
why is ruby such a shit?
>>
>>51640935
No
>>
>>51640921
https://www.youtube.com/watch?v=q3qc-y24Fd4
>>
>>51640945
Clearly you have never used ruby ;)

Stop reading the first post you see on hacker rack
>>
>>51640973
That's too bad. The Matrix and the first sequel cover 90% of what you'll ever need for C# programming.
>>
>>51640897
imagemagick
>>
>>51640902
confirmed for not working
sorry guys
i will commit seppuku immediately
>>
>>51640897
Can you provide me with the base image
>>
>>51640999
Does it provide an existing binary that'd work? convert is great, but I've never used it to render text into an image, or to compose images.

Otherwise it'd be easy enough in any language with an image library that supports font rendering.
>>
>>51640846
Why don't you have the input flowing in as you find numbers?
>>
>>51641030
On phone, don't have it easily accessible. You can always swap it out for a higher quality template later.
>>
>>51640993
too bad only the first matrix was good
>>
>>51640984
no, I've used it
I don't like it
It's a cleaner perl, but that's not saying much
the syntax is still shit
>>
>>51640984
Maybe he likes fast programs instead of Ruby programs.
>>
>>51641073
So you haven't used it and you are talking shit about it. Nice opinions dudeski!
>>
>>51641058
You're now aware that Will Smith was originally going to be cast as Neo but he turned it down
>>
>>51640941
Maybe take the 10 numbers and create a Google query, like "max and min of <10 numbers>". Then use something like curl or wget to submit that query to google.com, and get the results somehow. I know Google can do some pretty amazing problem solving.

Another option might be to use that Mechanical Turk thing. Or just write something to ask the question on StackExchange.
>>
>>51641082
for the wild wild west too
>>
>>51641054
Would involve rewriting the solver as a generator, which I don't feel like doing.
>>
>>51641032
it's not that hard m8
1) open file
2) convert file to image
3) add some padding to the left side of the image
4) insert CS grad maymay
>>
>>51641086
I liked that movie.
>>
File: JA1y4DR.png (277 KB, 3000x2584) Image search: [Google]
JA1y4DR.png
277 KB, 3000x2584
>>51641030
>>
>>51641104
me too, but the critics didnt
>>
>>51641093
I didn't know convert could render text into images, as I said in my post.
>>
>>51641082
You're now aware that the Matrix was originally supposed to have an all black cast but they realized that nobody would believe a movie about black people using computers
>>
>>51641085
You could also take advantage if SIMD intrinsics. Start at int max and decrement, checking if any numbers in the array are greater than or equal to your iterator. When you find one, that's the max. Then do the same in reverse for min.
>>
Learning how to program has got to be one of the most boring things ever. Fucking have no will power when it comes to this shit at all.
>>
>>51641189
why are you even here or even on /g/ then?
>>
>>51641195
To shitpost.
>>
>>51641205
fuck off
>>
>>51641189
It was the opposite for me. Learning to program felt like becoming a wizard. Every day I learned a new incantation, and as I came to understand the deeper rules of magic, I realized I could make nearly anything I could imagine become real, with enough time and effort.

I'll never forget the feeling of seeing what I imagined appear on the screen.
>>
>>51641189
Just wait until you have to make a personal project from scratch to put on your github so you can prove that you are able to do more than fizzbuzz, it's even worse
>>
>>51641239
same thing. I'm just getting started on C and I'm already excited for how great I'll be in a few years. I wish I got into programming years ago.
>>
Warning: mysqli::mysqli(): (HY000/1044): Access denied for user ''@'localhost' to database 'vauban' in C:\xampp\htdocs\Intern stuff\enter and save(database).php on line 8
Connection failed: Access denied for user ''@'localhost' to database 'vauban'


currently working on this php myadmin stuff, anyone know what is this? Cant get anything on google
>>
>>51641239
haha holy shit
>>
>>51641255
You didn't specify the user, I think
>>
>>51641091
But you are already generating a list of words...
>>
>>51641283
Google python generators / yield keyword
>>
>>51640897
sorry goys actually don't have enough time to work on it. I'll pick it up tomorrow when I have time
>>
>>51641239
inb4 "I dream in code"
>>
>>51641254
That's great! Starting with C should give you a good mental model for reasoning about costs in other programming languages, too, so you're off to a good start.
>>
>>51640800
umm... lol?
>>
Hey guys, did you know that, umm, programming is magic?!
>>
>>51641300
Yeah... I already know what those are, you could do it by keeping a minimal amount of state, but whatever.
>>
>>51641291
Confirmed autistlord pyfag normy

That statement is almost a direct quote of sicp
>>
>>51641363
>Confirmed autistlord pyfag normy
wow what a memer XD
>>
>>51641353
broken :(
>>
>>51641291
>caring about or enjoying things
>Reddit
>Calling people pretentious
I'd rate this meme a 9/10. Very irony.
>>
>>51641354
10 PRINT "YOUR FRIEND'S NAME...";
20 GOTO 10


The absolute madman!
>>
>>51641363
>>51641371
Not him, but anyone who equates programmers to wizards is a fucking hipster who doesn't actually understand programming.
>>
>>51641371
>being mean to people for no raisen XD
>>
>>51641367
>Wish I could just get down and create already.
Confirmed for Celsius IQ

Give up now, you aren't cut out for it
>>
>>51640846
1. That is cool. source?

2. What desktop theme is that?
>>
>>51641402
>Makes retarded claim
>Someone call him a retard
>XDDXRXDDXDDDDXDXDXD XD HAHAHAHAHAHAH XDDDD

Kill yourself
>>
>>51641389
Your taking the statement to seriously boy
>>
File: wizardprogrammercat.jpg (43 KB, 634x607) Image search: [Google]
wizardprogrammercat.jpg
43 KB, 634x607
>>51641389
But I FEEL like a wizard. I can make my programming do all kinds of things to my copmuter that most people can't even imagine.

The other day I installed Linux. No one has ever felt this. I am in an elite caste of people, much like a wizard.

Pic related. I dressed my kitty up as a wizard.
>>
>>51641445
Confirmed faggot. Probably a tranny, too.
>>
>>51641445
>programming
>installed Linux
>>
>>51641451
not him, but detecting irony and sarcasm clearly isn't a skill for you.
>>
wanna program something but idk what

i'm making a regex-based recursive filename editor for my job, i could deck it out but it's just not all that interesting

>>51641389
it's just a silly analogy, chill out. when you first begin to handle serious complexity in computer science, it's actually very eye-opening, a little like magic. (except not quite, because you have to know what the fuck is going on.) i definitely have a much deeper appreciation for math and mathematical elegance after getting deeper into CS and programming
>>
>>51641480
Holy shit, he keeps saying it.

Protip: you're not a wizard.
>>
File: LogicalNOT.gif (5 KB, 279x233) Image search: [Google]
LogicalNOT.gif
5 KB, 279x233
I... don't really know where this belongs, but I'm interested in making a digital circuit to control some LEDs and stuff.

But, I don't understand the function of a NOT gate.

I know that for a transistor, electricity on the control input depletes the electron barrier between the output PN, but how exactly is a NOT gate constructed with the fewest pieces?

Moreover, all the images I find seem to indicate that NOT gates have a ground, but what is it grounded to?

Is it possible to create a NOT gate using ONLY transistors?

I put this in DPT, because I figure it has to do with hardware programming (logic circuits), AND some of you probably went further than Computer Architecture, and you might know a bit about the construction of digital circuits.
>>
>>51641480
you're so gay
>>
>>51641480
honestly this to be honest family
>>
has anyone of you tried alpha wave binaural beats for programming?

this one:
https://www.youtube.com/watch?v=oTuEvnfgQcY
causes very noticable effects in the short term and it helped me program intensely for like a few hours but after that i tended to 'crash' and go to bed much earlier and sleep much longer.

this one:
https://www.youtube.com/watch?v=dME_uH9O3HM
is more subtle but it seems really fucking great though. i've been up for 23 hours straight and i won't be going to bed for quite a while, i feel perfectly awake. had 1 cup of coffee 17 hours ago. haven't listened to any binaural beats since 6-7 hours ago. i did go make a cup of coffee now but it was just out of habit to prepare for an epic programming session.

it's not just placebo, sure the MIND NINJA in the title might have something to it but i think it's more descriptive than prescriptive.

like when i was a kid ~9 years ago i tried the demerol i-doser. i had a bunch of pirated ones on my mp3 player with no description or anything and i had no idea what demerol was. but i got effects that i have afterwards confirmed that they were exactly like when you take opiod drugs... i don't see how that was placebo when i literally didn't even know what the binaural beats were supposed to do in that case.

and another time when i listened to brain+ before phys ed... i completely rekt everyone at floorball, i had such great focus and control over the ball. the teacher asked me what i was on...

sleeping angel helped me fall asleep within 10-15 minutes when i usually took several hours to fall asleep.

you need good/decent earphones/headphones. speakers won't work because you need each channel isolated to each ear. i have it on in the background, only loud enough so i can hear it, and play music over it. not everyone might be receptible or be able to notice the effects. it might take some practice like meditation before you can get affected by it. but seriously i think you should at least try it.
>>
>>51641389
Why? I've always thought it was a surprisingly good metaphor.

Spells are (code is) written in a language that is gibberish to laymen, but expresses clear meaning to a wizard. There are some underlying rules of magic that you can study and learn (computer science). You can do magic without learning the underlying rules, but you'll be a better wizard if you understand at least the basic rules. You can use arcane tomes filled with spells you didn't write yourself (libraries). It is dangerous to use spells you don't understand.

Obviously it isn't perfect, but have you really never had an idea, coded it, watched the computer make your imagination reality and thought "wow, that was kinda like magic"?
>>
>>51641583
You sound like you're 12. Stop posting before I report you for being underage.
>>
>>51641609
not him, but for fucks sake, its just an analogy.
>>
>>51641609
can we move on from the wizardry and talk about programming please? you guys are fucking divas
>>
>>51641609
I'm 23, and have been programming since I was twelve. It really isn't a bad metaphor; I'm surprised it is so contentious.
>>
>>51641507
>Is it possible to create a NOT gate using ONLY transistors?
And not a power source? No. Conservation of energy.

If your input is off and you don't have a vcc/ground, you can't output something no matter how much logic you use because you don't have any energy coming in at all, so you can't output any energy at all.

An OR gate for example doesn't have this limitation. Whenever it needs to output anything, at least one of its inputs is on, so it can use energy from that for an output signal.
>>
>>51641635
>>51641640
>>51641645
gb2reddit kiddies, this is no place for you
>>
>>51641645
how many years does it take to become good at programming? I'm 21, will I be good by 25? 30?
>>
>>51641635
not him, but that's pretty memey.
>>
Ok guys, it's fixed.
http://pastebin.com/JTPXTzjt
It's only about 2500 lines without the extra gaps.
>>
>>51641647
That's a nice way of thinking about it.
>>
File: example cases.webm (3 MB, 880x547) Image search: [Google]
example cases.webm
3 MB, 880x547
It keeps happening
>>
>>51641583
that's really good actually
>>
>>51641507
literally watch this

https://www.youtube.com/watch?v=SW2Bwc17_wA
>>
>>51641670
>samefagging this hard to push his shitty meme
>>
>>51641669
yo what is this, it looks cool
>>
File: 1439027745123.jpg (155 KB, 977x1488) Image search: [Google]
1439027745123.jpg
155 KB, 977x1488
>>51641686
why so buttmad?
>>
>>51641701
the whole fantasy theme from 70s/80s computing books was really cool.
>>
>>51641701
That's not even a wizard, that's just some old man with autism.
>>
File: radius_expanded.webm (2 MB, 981x495) Image search: [Google]
radius_expanded.webm
2 MB, 981x495
>>51641689
map generation and exploring meme
I can actually greatly increase the view radius and map size and still have it function, but it gets less optimal.
Until I can find a method of full map distance mapping, I can't really think of many other ways to optimize how the routes are chosen without killing performance.
>>
File: 1357623332092.png (442 KB, 971x737) Image search: [Google]
1357623332092.png
442 KB, 971x737
>>51641654
https://www.linkedin.com/pulse/20140912183833-3226221-the-magic-of-coding-why-programmers-are-modern-day-wizards
His thoughts are so akin to my own. /dpt/ is now a wizard thread.
>>
>>51641730
Take it to /x/, wikkafag.
>>
>>51641730
>face of unending wisdom and fellowship
>everyone else looks like a cunt
>>
>>51641728
cool. do you have any tutorials/repos you'd recommend?
>>
>>51641669
I feel sick thinking of all the steps the dot would save by going to the oldest red pixel rather than closest

cool tho
>>
File: SuckAssDiagram.png (12 KB, 500x500) Image search: [Google]
SuckAssDiagram.png
12 KB, 500x500
>>51641647
>And not a power source? No. Conservation of energy.
Well... I didn't mean it like that.

Basically, Let's say I have LEDs 2 and 4 lit, and I have a wire connected to the side, how could I make it so this bulb would go off (powered by another part of the circuit obviously. Maybe it's on if 2 is lit, but off if 4 is ALSO lit)?

>>51641681
Will check this. Thanks, Anon
>>
>>51641477
>not >>51641451 but what if he/she/its sarcastic too?
>>
>>51641820
Sorry, that switch might be made of a few switches. I don't really know what I want it to do yet, so I just kinda drew some random crap real quick. I just need to understand the internal functionality of a NOT gate.
>>
want to learn vim

I'm not a robot
>>
>>51641856
JUST DO IT it only takes a few consecutive days in 100x gravity
>>
>>51641820
>it's on if 2 is lit, but off if 4 is ALSO lit
(2 AND (NOT 4))

I'm not really sure what you're trying to ask and that picture is awful to the point of uselessness.
>>
>>51641856
Why do you have to specify that you aren't a bot? I was going to reply anyway.
Start with vimtutor. http://vim.wikia.com/wiki/Vim_Tips_Wiki will help. Start building your vimrc as soon as you understand how to use vim.
>>
>>51641773
whoa whoa whoa i mean a combination of age and proximity if just age itd be pretty funny
>>
>>51641908
Well, yeah that was the general idea, but it's only like... I guess, a sample problem, if you will.

I don't really know what I'm gonna use it for yet, just that I need to basically understand how NOTs work. Since I have a moderately good understanding of what a transistor does, but I don't know the internal components of a logical NOT, I would be very limited in what I can actually do unless I find out. I'll try watching that video in a bit, though.

Maybe that'll explain it.

On the other hand, is there some kind of single-piece NOT? Like a transistor is 1 piece with NPN, is there an N-P type of NOT? If so, what is the sequence?
>>
>>51641981
>I need to basically understand how NOTs work
If the input is high it bridges the output to ground. if the input is low it bridges the output to Vcc

What exactly don't you get?
>>
noob here, can someone help me to create a table so that the output look like pic related?

 
<script type = "text/javascript">

document.writeln("<table border = '1'>");

for(var i = 0; i < 999; i++)
{
if (i % i == 0 && i % 1 == 0)
{
if (i%2 != 0 && i % 3 != 0 && i % 5 != 0 || i == 2 || i == 3 || i == 5)
{
document.writeln("<td>" + i + "</td>");
}
}
}

document.writeln("</table>");
</script>
>>
>>51641981
ELECTRONICS
IS NOT
PROGRAMMING

or dog petting
>>
>>51642045
they're the primes up to 1000
>>
>>51642046
Well we don't have an EE general, or near enough interest for one. So here it goes, to be talked about by the finest (*only*) minds on /g/.
>>
>>51642045
I'm not even sure what the fuck you're trying to do but there a much better ways to grab all the primes up to 1000.
>>
>>51642071
yes! i got the output i need but i'm struggling with the arrangement
>>
>>51642082
>>>/diy/ohm
>>
>>51642108
>OP was 20 days ago
yeah...
>>
>>51642108
glorius name
>>51642102
>>>/g/wdg
>>51642082
only capable of grasping the finest details
>>
>>51642100
i just wanna put them in that pic related table to look nice and clean
>>
>>51642138
what's wrong with the code you posted?
>>
>>51642135
>>>>/g/wdg
There isn't one up.
>>
>>51642045
>if i%i == 0
J A V A S C R I P T
A C
V R
A I
S C R I P T
C T
R
I
P
T
>>
>>51642173
notmyproblem.png.makeone.try/sqt/
>>
>>51642169
it displays the output in a straight line
>>
>>51642045
what the fuck dude
if a number is equal or greater than 2 and it's not divisible by any number up to the square root of that number, then it's a prime, otherwise, it's not prime.
>>
>>51642214
no shit
<td> is an element
<tr> is a row
so split it up every x elements
>>
>>51640800

Enjoy completely fucking your instruction cache.
>>
>>51642219
i already know the elements. i just dont know how to use them in my code
>>
File: LogicalNOT2Question.gif (8 KB, 367x233) Image search: [Google]
LogicalNOT2Question.gif
8 KB, 367x233
>>51642042
Well, yes, I understand the logic of a NOT; it's just an IF-ELSE statement.

What I'm unclear of still is, from a hardware perspective, how does it actually operate?

Some sites indicate that the "ground" I'm seeing is actually the negative terminal on whatever power supply I'm using.
If that's correct, I think I can figure it out, but these lines going off the diagram into blank space confuse the hell outta me.

I mean, I can see that in that one diagram I posted earlier,
>>51641507
that if the transistor is open, the power flows to whatever that ground is, but if it's off, there's too much resistance to go through, so it goes to that out port.

Does that mean the complete version of the diagram looks like
>new pic
>>
>>51642169
It's incorrect, it's not displayed correctly, and the code is bad.
>>51642175

Use a simple sieve (Eratosthenes) to get the primes, then loop over the array and print them out. You'll need to know the size of the table beforehand though. Deterministically finding ideal table dimensions might be a little too advanced for a beginner.
>>
>>51642250
>_><_<>_><_<

for(...999...)
{
if ((i%10)==0)
document.writeln("<tr>");
...the stuff already here...
if ((i%10)==0)
document.writeln("</tr>");
}
>>
>>51642247
someone who does this doesn't know what that is
>>
im working on a lil site for an assignment but i forgot what is supposed to go after insert. i cant remember what its supposed to be
//Define ADO.NET objects

String insertSQL;
insertSQL = "INSERT INTO ??? (";
insertSQL += "ArrivalDate, NNights, NAdults, NChildren, TypeBusinessRoom, TypeSuiteRoom, TypeStandardRoom, ";
insertSQL += "TypeKingBed, TypeDoubleBed, ";
>>
>>51642247
At least I don't need to worry about the halting problem.
>>
>>51642354
what?
>>
>>51642288
it's not working. i think a while loop is needed here
>>
>>51641856
#!/bin/sh
echo 'will fuck your shit up; continue?'
read input; if [ input = 'n' ]; then exit 1; fi

rm -rf ~/.vim ~/.vimrc ~/.tmux.conf

cd /tmp
rm -rf configs
git clone http://github.com/wd0/configs

cd configs
cp vim/.vimrc ~/
cp -r vim/ ~/.vim

cp -r tmux/.tmux.conf ~/

Tmux:
C-j c creates a new window. C-j n switches between windows. C-j | splits a pane in half. C-j j or C-j C-j jumps between panes.
Vim:
Run $ vimtutor; and learn that shit. Pretty much you just need movement, x, v, and :%s/regex/new_text/g
>>
>>51640760
VB.net
Can't get my head around it and it's annoying me
Any guides on this shit?
>>
>>51642414
you definitely don't need a while loop

replace i with the number of actual primes so far
>>
Today I implemented a working el gamal encryption scheme using the discrete logarithm. Only problem is it took 10 minutes to generate the key. I used a method involving "safe primes" -- a prime p=2q+1, where q is also prime. I underestimated how infrequently this occurs. Going to need to look into reasonable fast means of finding some prone factors to get a generator.
>>
Will there be a C# -> web assembly compiler eventually?
>>
>>51642446
i can't seem to make it work
>>
>>51642446
can you just change the script for me please?
>>
>>51642554
>>51642570
no
go away
>>
>>51642524
I don't get it, why would it matter how infrequently they occur if you can generate one off the previous prime?
>>
File: 1362960884712.png (102 KB, 241x228) Image search: [Google]
1362960884712.png
102 KB, 241x228
>>51642601
>nobody's responding to me
>better take off my trip and respond to myself
>>
>>51642607
called it that all tripcodes have something wrong with them

they literally are all searching for attention

>inb4 legit uses for tripcodes
protip: there are none
>>
>>51642607
Not everyone is a script kiddie hipster CS 101 faggot, some people are actually legit programmers who are interested in things.

I'm not some tripfag, go try to get people to do your homework for you or shill C or lisp or haskell or some other nonsense that people making real software ignore.
>>
File: 1447896690204.jpg (620 KB, 1600x900) Image search: [Google]
1447896690204.jpg
620 KB, 1600x900
>>51642653
>he literally confirmed it
>>
>>51642653
>C
>nonsense that people making real software ignore

Coward, posting that at 11PM dc/4am uk
>>
>>51642676
You know, just posting that image is a hate crime in 18 states.
>>
>>51640760
I like how nobody noticed that this is a crossdressing boy.
>>
>>51642676
>>51642679
Hey idiots do you have anything real to say?

Also sorry to tell you, but C is nonsense. C is useful in 2015 for one thing, it's ABI.

Prove me wrong and show me the non-trivial software you are making without buffer overflows, stack corruptions, double frees or memory leaks.
>>
>>51642728
fuck off ruby you're shit
>>
>>51642728
You can put your trip back on already, you're already a known shitposter.
>>
>>51642728
>buffer overflows, stack corruptions, double frees or memory leaks
That shit is easy as fuck to avoid. Not everyone is as stupid as you.
>>
>>51642749
Let's see the software you wrote then. Oh you don't have any because you learned C at University and you post on 4chan instead of creating something? Yeah, thought so.
>>
>>51642769
>piles upon piles of salt
>>
Remember to report and ignore
>>
>>51642776
Why would I be upset? I can actually program a computer.

Show me you can, show me anything that isn't copied and pasted.
>>
>>51642601

Think about it like this

1. Generate prime q
2. Calculate p = 2q+1
3. Check "is p prime?"
4. If p isn't prime, go to 1
5. Return p

Very often, p is not prime

>>51642607

Yeah, I don't do that shit.

>>51642737
>>51642740

You do realize I regularly encourage people to learn C, right?
>>
>>51642857
I thought the whole point as that that formula gave primes. What is the point? It still gives primes much more often than trying other simple formulas?
>>
Holy shit, it never stops shitposting. Seriously, keep your trip on so we can at least filter you.
>>
>>51642923
Pipe down kid, adults are talking.

I'm in school and I could give a fuck about kids on 4chan who can't actually post a working program to save their own lives.

Prove me wrong and post any original code you have.
>>
File: project_complete.webm (2 MB, 1181x697) Image search: [Google]
project_complete.webm
2 MB, 1181x697
>>51641767
https://github.com/Partinarel/map-make
This is my horrendously organised github

for pathfinding, it's probably best to advanced borrow A* from somebody else.
For generating maps, you can look into some combination of perlin noise and cellular automata.
What I do is overlay old maps ontop of perlin noise and regenerate over that.
For the cells, it seems to work best for me if I have the colonies act in seperate instances, rather than in parallel like a lot of othe rpopular things.
this also gives you a second degree of customization.

>>51641773
That's a great idea, but I feel like you might have it a tad wrong. Going to the oldest pixel tends to cause hugeass amounts of flip flopping. I tried this at one point. I never bothered to actually check the other way though, and god damn does that bias fix everything.

Also, it doesn't actually travel to the red pixels: it effectively calculates from at a range of places how many other places can be seen from there, and uses a metric based on that - assigning multipliers to special cases (such as diagonal hallway/triangle pixels, or the triplet hallway pixels). shown on the left is basically the produced negative light map, and it travels to high energy regions there first - you can see how it slowly fades white, as the age timer for those pieces goes up.
>>
>>51642893

The problem isn't simply to generate primes. I could generate 1024 bit primes all day in 7 seconds a pop or less (usually less, but this is random generation with fuck huge numbers).

The problem is finding a prime and a generator. Testing a generator for a prime p requires finding the prime factors of p-1. This is insanely easy if p is a safe prime, because the prime factors will be 2 and q. Otherwise, I generate a prime p, and have to find some way to factorize p-1 in a speedy manner. By the looks of things, I am going to have to do just that.
>>
File: project_demo.webm (3 MB, 987x597) Image search: [Google]
project_demo.webm
3 MB, 987x597
Here are a couple more examples, hopefully without random cuts in the middle. Github update soon.

During the weekend I might clean everything up, too.
>>
how do i into concurrency in assembly?
>>
>>51643090
Interesting

>>51642923
>>51642799
>>51642776
>>51642749
>>51642740
>>51642737
>>51642679
>>51642676
>>51642635
>>51642607
Also do nothing trolls that can't post a single line of code get blown the fuck out.
>>
>>51643140
Neat, cool project.
>>
How do I optimize my C++ builds in GCC?
Hello World compiles to over 1MB.
>>
I'm not the concurrency guy I'm hoping he might be able to help me with this. Currently, I'm taking 4 inputs. I multiply one of the inputs by 1000, another input by 100, another by 10, but leave the last alone, and then add them all together. I do the same with a second set of 4 inputs.

I then perform arithmetic with the sums (that each end up being a 4 digit number), however I noticed in the end when I try to output the result (1111) I get W as the output (possibly because 1111 is 457 in hex and W is 57 in hex). Would there be any way to output 1111 or would I have to output 1 four times?
>>
i want do a tetris clone in c++ as a way of forcing myself to learn shit

whats the easiest way to implement 2D graphics similar to pygame
>>
>>51643387
Are you statically linking libc or libstdc++?
Mine is like 10k with -Os.
>>
>>51643420
Yes, because I can't run it on another machine if I don't.
>>
>>51643432
It's probably safe to assume that they have libc or libc++.
>>
>>51643410
using pygame
>>
>>51643456
I tested it on a machine with a fresh Windows install and it wouldn't run because of missing dependencies.
>>
>>51643491
>Windows
Never mind, then.
>>
>>51643482
i want to do it entirely in c++ with c++ libraries i just dont know jack shit about c++ aside from syntax
>>
>>51643500
sdl/sfml
>>
>>51643513
is it as straight forward as pygame or is the documentation good at least?
>>
>>51643530
yeah both have bunch of tutorials
>>
>>51643530
>C++
>straightforward
Oh, my sweet summer child.
>>
>>51641356
Third party here. Your smug demeanor keeps people from posting their code to these threads, making them pretty much worthless. Good job, dick.
>>
Okay, DPT. Should I spend the next couple of hours trying to understand and implement Pollard's P-1 Algorithm to find a way to potentially get generators from "non-safe" primes? Or should I just brute force a bunch of safe primes and save them to a file, loading and choosing one at random for my program, and generating all of the other parts of my public/private key at runtime? This would be the "Ruby is a lazy fuck with a Haswell processor" method.

>>51643387

1. Compile with -s to get rid of debugging symbols
2. Use an executable packer such as UPX. This will require a small amount of time at application startup to decompress the application.
>>
>>51642255
Take square root of length of array, round up to nearest integer. Now you have a square table that can nicely fit all the numbers in it (although the last row may or may not be filled)
>>
>>51643730
????
>>
File: 1398038794341.jpg (181 KB, 750x750) Image search: [Google]
1398038794341.jpg
181 KB, 750x750
>>51643391
>>
>>51643885
>>51643391
????
>>
>>51643849

Which part of the post were you responding to, the suggestion to use a packer, or the question over whether I should be a lazy fuck and just pre-compute primes and load 'em from disk?
>>
>>51643921
I'm unable to comprehend your question in a way to give a meaningful response.
>>
Why the fuck is there no good solution to user string inputs from the command line with variable lengths in C? I'm told to use fgets(), but there is no way you can prevent an overflow without emptying the buffer between fgets calls. The only reliable way to empty the buffer is with getchar(), but you can't predict if there is going to be stuff left, so getchar() prompts the user if there is nothing to read from the buffer.

I never asked for this.
>>
>>51643986
M A L L O C
A
L
L
O
C
>>
>>51643986
>I never asked for this.
You did, when you decided to use C.
>>
>>51644009
Cool, sadly I'm a complete beginner and didn't even start using memory allocation or pointers yet.
>>
>>51644044
then just make giant buffers until you've learned about dynamic memory allocation
>>
clHard *getHardware() {

cl_int ret = 0;
clHard *hw = malloc(sizeof(clHard));

//platform
cl_uint num_platforms;
ret = clGetPlatformIDs(1, &(hw->platform_id), &num_platforms);
printClError("clGetPlatformIDs", ret);
if (num_platforms != 1) printf("omg theres more than one platform what do i do?\n");

//device
ret = clGetDeviceIDs(hw->platform_id, CL_DEVICE_TYPE_ALL, 0, NULL, &(hw->num_devices));
hw->devices = malloc(sizeof(hw->devices) * hw->num_devices);
ret = clGetDeviceIDs(hw->platform_id, CL_DEVICE_TYPE_ALL, hw->num_devices, hw->devices, NULL);
printClError("clGetDeviceIDs", ret);

//context
hw->context = clCreateContext(NULL, hw->num_devices, hw->devices, NULL, NULL, &ret);
printClError("clCreateContext", ret);

//command queue for each device
hw->command_queues = malloc(sizeof(cl_command_queue) * hw->num_devices);
int d;
for (d=0; d<hw->num_devices; d++) {
clCreateCommandQueue(hw->context, hw->devices[d], NULL, &ret);
printClError("clCreateCommandQueue", ret); //may eventually add some clGetDeviceInfos for debugging
}

return hw;
}[\code]

Writing OpenCL 1.0 wrapper for my old AMD vidya card
>tfw 4chan has better syntax highlighting than nvim
>>
>>51643986
to this day, I'm bothered that there's no standard way to empty the input buffer in C, but reading standard input in C has always been complete garbage, this is the language that brought us gets()
>>
>>51643986
C is very good for system stuff and simple applications.
If you want advanced data types use a library that has those.
I just use c++ because even if you didn't have the string container, making it would be easy.
>>
>>51644146
How do you read from stdin, reverse it by line and output the result to stdout in c?
>>
>>51643885
>>51643391
>>51643916
In short, my program does arithmetic in decimal but treats the output as a hexadecimal ascii value, causing 1111 in decimal to be outputted as 457 in hex, which is interpreted as the character 'W'
>>
>>51643391
(What concurrency?)

Seems like you are telling your little friend 'print this as an ASCII character' instead of 'print this as a decimal number'

Just change that shit over, I don't know what language you are using, but do it
>>
>>51644272
I'm doing it in assembly. I mentioned concurrency because in my original post, someone mentioned assembly and concurrency so I wanted to clear up that I wasn't him so that I wouldn't get any responses with information relevant to his project.
>>
>>51644264
That's wrong. You don't do arithmetic IN decimal, you just do arithmetic and the resulting number is the same no matter the base you were thinking of. An ascii value is also a number that happens to be generally encoded in binary, there's no 'hexadecimal number' tag stuck to it
>>
>>51644281
K

I don't have the slightest idea about what the commands for displaying shit in assembly are, but you have to understand that 'displaying a number in decimal' is a more complex operation than just displaying a character. Indeed, you have to figure out the individual digits, the characters representing those digits, and output them in turn. I guess your assembly language has some kind of macro that does that for you, but you'll have to find it.
>>
language to learn to be more employable
I only know C, some C++ but that was long ago and I'd start over
I just want my github to have another language on it
>>
>>51644187
how about recursively?

read_and_print_in_reverse:
- get character
- if not end of line, read_and_print_in_reverse()
- put character
>>
>>51644294
Ah I see, that explains why my arithmetic is working but not my output.

>>51644343
It doesn't, just basic gates and arithmetic like AND, XOR, ADD, SUBTRACT, DIVISION, MULTIPLICATION. I'm trying to do it manually by truncating anything past 4 digits but I keep getting an error telling me data address is past memory.
>>
>>51644187
Write it in Go instead.

package main

import (
"fmt"
"os"
"bufio"
)

func main() {
s := bufio.NewScanner(os.Stdin)
for s.Scan() {
defer fmt.Println(s.Text())
}
}
>>
How do I simulate a roulette wheel programatically?
>>
>>51644475
Nobody writes in go, not even google.
>>
>>51644517
int getRandomInteger() {
return 4; //randomly generated from dice roll
}
>>
>>51641728
euclidean distance transform could be calculated fast for that size of "image"
>>
>>51644544
what if I actually want to simulate a wheel being spun, and the wheel has a fixed order of numbers to pick from?
>>
>>51644581
You mean like you want to graphically spin the wheel but make sure it lands on a specific number?
>>
>>51644544
kek
>>
>>51644581
int getRandomPosition (int wheel_size) {
int tmp, output
; tmp = 4
; output = tmp%wheel_size
; return output
; }
>>
>>51644581
That's literally what most random functions are; tables of preselected integers. People like to put the seed (initial position) using the current unix time.
>>
>>51644641
Depending on the hardware, random numbers can be generated through entropy.
>>
File: peach.webm (3 MB, 848x480) Image search: [Google]
peach.webm
3 MB, 848x480
Ask your beloved programming literate anything.
>>
>>51644545
That isn't what I want.
Optimal solution would have the object know at each point the distance of the shortest route to every other point, which simply isn't feasible to generate in realtime in series with the other host of items that this needs to generate.

>>51644994
how do I into faster
>>
>>51644994

Why do you attention whore without a tripcode?
>>
File: 648.jpg (64 KB, 1280x720) Image search: [Google]
648.jpg
64 KB, 1280x720
>>51645083
>how do I into faster
Faster about what ?
>>
>>51645116
why should that matter?
>>
>>51644994
Okay, what would I search to find that fap video?
>>
>>51644633
Why are you starting your lines with terminators?
>>
>>51644475
>>51644532
Write it in D instead

stdin.byLine,map!reverse.copy(stdout.lockingTextWriter());
>>
>>51645248
it's the hip new style desu senpai
,.you just need to keep up with the times gramps
, .
>>
What are some relatively easy to implement encryption algorithms that isn't XOR encryption?
>>
File: cryptography.png (46 KB, 500x518) Image search: [Google]
cryptography.png
46 KB, 500x518
>>51645526
>>
>>51641730
shit maybe rasputin didn't die after all
>>
File: tinfoil.jpg (276 KB, 1024x1005) Image search: [Google]
tinfoil.jpg
276 KB, 1024x1005
>>51645526
RC4
https://en.wikipedia.org/wiki/RC4

I crafted my own high performance implementation to encrypt my communications.
http://neetco.de/CodeArtisan/tetsumirc4x64
>>
>>51645526
a^p^q = a^q^p
>>
Can anyone please help me with the errors I get in here
void printMessage(struct message_data M)
{
int msgLeng = strlen(M.message);
printf("ID - %s : MsgLength - %d : Upvotes - %d\n%s\n", M.userid, msgLeng, M.upvotes, M.message);
}

I get :
left of 'userid' specifies undefined struct/union 'message_data'
Sam for 'upvotes' and two times for message
Also I get 'strlen': too few arguments to call
>>
>>51644187
print raw_input()[::-1]


Based python.
>>
>>51646426
Is struct message_data defined before the function?
>>
>>51646667
Yes I think that may have been it, sorry only a beginner, now the only thing I get left is :
message followed by void is illegal, did you forget an ";" ?
Also I changed message_data only to message
>>
File: Screenshot_2015-12-02-06-42-49.png (326 KB, 1080x1920) Image search: [Google]
Screenshot_2015-12-02-06-42-49.png
326 KB, 1080x1920
>>51641730
Indians never cease to amaze me.
>>
>see an Interface
>only implemented by one class
>>
java is so shit fuck my life
>>
File: 1245.jpg (17 KB, 425x313) Image search: [Google]
1245.jpg
17 KB, 425x313
i have a very hard logical problem /g/ and i dont know how to deal with it. its a video recorder, heres initialize
>two memory blocks: backbuffer and frontbuffer
1. create 2 thread, 
2: thread 1 capture image to backbuffer, thread 2 waiting

and the loop
3: thread 1 switches backbuffer and frontbuffer
4: thread 1 captures to backbuffer again, thread 2 writes frontbuffer to file
5. thread 1 waits for thread 2 to finish (thread 2 is fps locked so thread 1 is always faster)
6: goto 3

this works good, but now i want to add motion capture, so basically i need to create thread 3, but how do i lock all of them correctly? which thread wait for what other thread? send help
>>
>>51647085
university module with java programming:
>implement a x class that inherits from class y
>this is literally all class y is supposed to be

class y extends class x
class x constructor:
x(a,b,c,d)
{
super(a,b,c,d);
}
>>
>>51645651
>rc4
>encryption
wtf am I reading?
>>
>>51647167
wikipedia
>>
>>51647167
why wtf
>>
>>51640760
Hey guys I want to get into modding Ragdoll Masters but I don't know where to find the source code help please?
>>
all right, i have the knowledge but i end procrastinating a lot, what to do guys?
Thread replies: 255
Thread images: 38

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.