[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: 34
File: himegoto.jpg (337 KB, 1280x1449) Image search: [Google]
himegoto.jpg
337 KB, 1280x1449
old thread: >>51784297

What are you working on, /g/?
>>
File: when_anime_eat_pizza.webm (3 MB, 800x450) Image search: [Google]
when_anime_eat_pizza.webm
3 MB, 800x450
Ask your beloved programming literate anything.
>>
File: 1446590110179.jpg (219 KB, 1000x1502) Image search: [Google]
1446590110179.jpg
219 KB, 1000x1502
>>51790693
go back to >>>/lgbt/
>>
File: painting.png (276 KB, 1840x1228) Image search: [Google]
painting.png
276 KB, 1840x1228
app
>>
>>51790752
What's that one thing you're missing just enough to be bothered by it but not enough to actually write it yourself?
>>
>>51790809
Dicks in my anus
>>
File: Untitled.png (149 KB, 1366x768) Image search: [Google]
Untitled.png
149 KB, 1366x768
Why doesn't the text show? I think the picture is covering it but I have no idea how to fix this.
>>
In python, I'm gonna need to read the clipboard for a large chunk of text and then print it line by line. Is there a memory efficient way to do that?
>>
>>51790867
if it's windows, pywin32
>>
>>51790809
league of legends on linux.
>>
>>51790867
let the OS deal with it
if you run out of memory, the os will just copy it to the pagefile.
>>
>>51790752
What's your saddest memory?
>>
>>51790883
stay on windows
>>
>>51790886
what about writing it to a file and reading line by line?
>>
>>51790883
Just use wine, works perfectly.
>>
>>51790797
remove this pic
>>
File: Bridget.full.780971.jpg (185 KB, 645x789) Image search: [Google]
Bridget.full.780971.jpg
185 KB, 645x789
Same person as post >>51789159
I now need to do a new program that ask's 2 Int's to the user.
First one is months second is years (Years have to be larger then 1900), and then the program has to count the total number of days in the years including the extra day in leap years.
I'm reusing this code.
public static void main(String[] args) {
// TODO code application logic here
int mth,mthD, yr, yrd ;
Scanner keyboard = new Scanner(System.in);

System.out.println("Insira um numero de um Mes no intervalo 1-12"); //Nº of the Month Insertion
mth = keyboard.nextInt ();
System.out.println("Insira um numero de um Ano"); //Year Insertion
yr = keyboard.nextInt ();

switch (mth) { //Month Count

case 1:
System.out.println("Janeiro");
break;
case 2:
System.out.println("Feveiro");
break;
case 3:
System.out.println("Março");
break;
case 4:
System.out.println("Abril");
break;
case 5:
System.out.println("Maio ");
break;
case 6:
System.out.println("Junho");
break;
case 7:
System.out.println("Julho");
break;
case 8:
System.out.println("Agosto");
break;
case 9:
System.out.println("Setembro");
break;
case 10:
System.out.println("Outubro");
break;
case 11:
System.out.println("Novembro");
break;
case 12:
System.out.println("Dezembro");
break;

}
}

}


What do I exactly need to do define a year as 365 days and every 4 years there is a an extra day added (help me get there)
>>
>>51790867
>In python
>Is there a memory efficient way to do that?
That would be a no.
>>
>>51790893
my only memory is volatile and reset during sleep.
>>
>>51790924
y?
>>
File: 1447269734130.jpg (78 KB, 429x331) Image search: [Google]
1447269734130.jpg
78 KB, 429x331
>>51790927
>brazilian programming.
>>
File: 40cakes_4996.jpg (168 KB, 1366x768) Image search: [Google]
40cakes_4996.jpg
168 KB, 1366x768
>>51790867
i was doing stuff with clipboard earlier
probably not memory efficient but it might help
>>
>>51790960
>Actually american
>Studying abroad in Portugal
>Teacher Forces me to write every Print in Portuguese.

Anon Please.
>>
>>51790927
>and every 4 years there is a an extra day added
You know that's not the only thing you have to do with leap years, right?
https://en.wikipedia.org/wiki/Leap_year#Algorithm
>>
>>51791011
how did you decide on what you gonna decode it with?
>>
>>51791011

import win32clipboard
win32clipboard.OpenClipboard()
value = win32clipboard.GetClipboardData()
win32clipboard.CloseClipboard()
>>
>>51790927
first, rep;ace the swith with
String monthNames[] = {"jan","feb","mar"}; // etc
System.out.println(monthNames[mth-1]); // array is indexing from 0


as for your other question
yrd = (yr%4==0) ? 356 : 355;
>>
>>51790897
>>51790904
too late, i am full linux since 8 months now. i don't really miss the game which is not that great but i miss playing with my nakama.
>>
>>51791041
fuck man i dunno i copypaste like 60% of my code i wasnt sure that my post would even be of help

>>51791060
wow holy shit what, every time i looked up how to get clipboard data they had the most roundabout ways... i didnt ask /g/ though
>>
>>51790675
>>51790717
some more answers on this please lads,also i start in like a month ,what to do in the meantime?
I know basic ubuntu(base folders structure,basic commands etc..) and learning bash/perl atm.
What else to do?
I never "worked" before so i dont know what to expect.
>>
I do all these online programming challenges, and for what lads?

for what?
>>
>>51790927
Use an array not a switch statement.
>>
>>51791038
It's all that was asked for me to include in the program roughly google-y translate the assignement
"At the end of should display on the screen the number
maximum days
for a particular month ( should include
leap years)."

>>51791079

I don't actually need the month's day I only need to add the number of days up that month in the last year.

>>51791207
Yeah I kinda scraped and am using this >>51791079


  public static void main(String[] args) {
// TODO code application logic here
int mth,mthD, yr, yrd ;

Scanner keyboard = new Scanner(System.in);

System.out.println("Insira um numero de um Mes no intervalo 1-12"); //Nº of the Month Insertion
mth = keyboard.nextInt ();
System.out.println("Insira um numero de um Ano"); //Year Insertion
yr = keyboard.nextInt ();
yrd = (yr%4==0) ? 356 : 355;


}


Still need to figure out how to get the nº of days up to the month specified by the user.
>>
>>51790927
>>51791207
string arM[12] = { "jan", "feb", ....};

Then just print the month with.
cout << arM[mth-1];



Don't know java. So I did a simple c++ example should carry over I believe, you just need to change the cout to whatever java does for printing variables.
>>
>>51791274
I don't need to print out the month i need to define that all months except the 3rd have 28-29 days depending on the year and I need the program to make the sum total of the days up to that month.
>>
So I'm supposed to create a program in C++ that outputs all r-combinations of arbitrary set of size n.

Something like this for the 3-combinations of a set of size 7.
{1, 2, 3}
{1, 3, 4}
{1, 4, 5}
{1, 5, 6}
{1, 6, 7}


Obviously I'm missing a ton of values. I was thinking I'd use a separate variable for each position to loop through the possible outputs, but this is inefficient and I would need to know the value of r beforehand.

Do I need to use recursion for this? I can't think of another way to get around this
>>
>>51791300
Is this homework?
>>
>>51791206

better your skills
>>
>>51791300

Look up "Lilian calendar"
>>
>>51791346
Yes and no.
I just want to learn but every time I search for a similar line of code I get nothing, and I can seem to logically in java to get there.

Mathmatically I can just do an equation to get there but I don't know how to do it in Java.

So what I still need to do (or so I think I need to do in java) is.
Define the nº of days in the months.
Define that in February the nº of days is 28 and 29 in leap years.
And then I still need the program to do the sum of all the days in the years up to the specific month and year the user introduces.

My main issue is that I barelly know java and the teacher only taught us to use basicly if and else if + a few other functions.
>>
>>51791300
use a multidimensional array if its feburary check if its a leap year and add one to the number of days.

I am confused as to what you are asking.
>>
>>51791421
I'm either not looking well enough or can't find exactly what your telling me to look.

>>51791449
I don't know how to use arrays.
see >>51791448
>>
>>51791449
string month [12][2] = { {jan, 31}, {feb, 28} .....};
if(month[input][0] == "feb" && leapyear)
cout << "Feb has 29 days";



http://www.tutorialspoint.com/java/java_arrays.htm

I dont know why I am holding your hand.
>>
>>51790883
play dota
>>
>>51791497
Thanks I feel like an idiot
>>
File: multidimensional-array.jpg (54 KB, 711x576) Image search: [Google]
multidimensional-array.jpg
54 KB, 711x576
>>51791512
Spend a little more time looking up what people tell you instead of saying you don't know. Arrays are easy.

if you have say

int imANarray[12];



this array can hold 12 integers.
and array is accessed from 0.
so from zero to eleven your values are stored. Access them by counting up from zero 12 places.

multidemensional arrays work with the same concept. however you just add columns to the rows. Think of it as an excel spread sheet.
>>
>>51790960
No, this is Brazilian Programming.
function CartesianProduct(l)
local p = {}
local function f(d)
d = d or 1
if d > #l then
coroutine.yield(copy(p))
else
for i = 1, #l[d] do
p[d] = l[d][i]
f(d+1)
end
end
end
return coroutine.wrap(f)
end
>>
>>51791566
Why are random names like foo so prevalent in examples?
>>
>>51791585
Are they really random if they are prevalent?
>>
>>51791585
>he doesn't know foo bar
m8 you are FUBAR
>>
Is it possible to make the computer check each character inside a character array and compare it to an specific character AND then do something with said character?

Example:
Search for 'O's in the char array "AEIOUOIEA" and then change them to '1's?.

(C++)
>>
>>51791331
You could use recursion. I would. It's possible in other ways, just more difficult.
>>
>>51791651
Like replace? Yeah absolutely. In C++ it's string::replace.
>>
>>51791566
>>51791512
More to my example.

So your array for months would look like pic related logically.

you code would be
string month [12][2] = { {jan, 31}, {feb, 28} .....};


the 12 is your rows and 2 the columns in your array.

so in c++
cout << month[11][1];


This would print 31. Same thing in java just change the syntax.
>>51791668
find and replace is what you want to google.
>>
>>51791478

>i need to define that all months except the 3rd have 28-29 days

 if (month <== 2)
numDays = numDays + (month - 1) * 31;



The if statement calculates number of days in February. January will always have 31 days so if your date is in January, the 31 is added in automatically.
>>
>>51791585
Because no non-random names apply in examples. Names like foo just signal "this is a random example" in a recognizable yet unobtrusive way.
>>
File: Capture.png (6 KB, 147x274) Image search: [Google]
Capture.png
6 KB, 147x274
>>51791688
MAN I AM FUCKING UP

>>51791686
>>51791688

GOD DAMN
>>
>>51791651
Yes. You'd need to loop through the array, then use an if statement to check for the desired value

Although note that since it's a character array the 1 will be a char and not an int

>>51791668
Yeah I'm trying this recursively now. Maybe afterward after I'm done I'll try tackling non-recursive solutions, though I honestly have no idea what they'd look like
>>
Why did I pick a fucking Java job? C++ feels like a breeze to work in.
>>
>>51791709

And then to add to this to find if February has 28-29 days, figure out if it's a leap year or not and either add a day or subtract.
>>
what kind of job does a c++ programmer does? it seems that most companies want java and .NET
>>
I want to create a simple but secure group chat program with end to end encryption. What would be a good library to handle the secure communications part? I'm using C++. I'm having some difficulty finding (and deciding on) a good, secure enough and performant enough lib. Preferably not a clusterfuck to use.
Any recs?
>>
>>51791079
> yrd = (yr%4==0) ? 356 : 355;
yrd = yr%400==0 || (yr%4==0 && yr%100!=0)

1900 and 2100 aren't leap years in spite of being divisible by 4. But if you only need to allow for years between 1901 and 2099, yr%4==0 will suffice.
>>
>>51791854
OpenSSH
>>
>>51791506
this
>>
>>51791854
Encrypt IRC
>>
>>51791854
OpenSSL.

Not perfect, but that's about as good as it gets.
>>
>>51791873
>>51791911
What's the difference between OpenSSH and OpenSSL?
And for the latter, would LibreSSL not be a better option?
>>
How long is the AoC day 10 answer supposed to be?

My solution reached 252000 characters in the 40th iteration and I'm pretty sure that's not right
>>
>>51791921
Other anon was right, use OpenSSL.
See this response: "OpenSSH is a program depending on OpenSSL the library, specifically OpenSSH uses the libcrypto part of OpenSSL.".
>>
int main()
{
//Initialize Variables, might make the code a user input later
string key = "MURCIELAGO";
string code = "TESTING";
int repeat;
int check = 0;
int loops;

//For loop for modifying crap
for(loops = 0; loops <= code.length(); ++loops)
{
if(code[loops] == key[loops])
{

}
}

}


C++

>>51791651
>>51791721
>>51791686

Well, I can't seem to get a way to make replace fit there in the way I want, and I don't really know what to do with if statements... Excuse my stupidity.
>>
>>51791949
// replacing in a string
#include <iostream>
#include <string>

int main ()
{
std::string base="this is a test string.";
std::string str2="n example";
std::string str3="sample phrase";
std::string str4="useful.";

// replace signatures used in the same order as described above:

// Using positions: 0123456789*123456789*12345
std::string str=base; // "this is a test string."
str.replace(9,5,str2); // "this is an example string." (1)
str.replace(19,6,str3,7,6); // "this is an example phrase." (2)
str.replace(8,10,"just a"); // "this is just a phrase." (3)
str.replace(8,6,"a shorty",7); // "this is a short phrase." (4)
str.replace(22,1,3,'!'); // "this is a short phrase!!!" (5)

// Using iterators: 0123456789*123456789*
str.replace(str.begin(),str.end()-3,str3); // "sample phrase!!!" (1)
str.replace(str.begin(),str.begin()+6,"replace"); // "replace phrase!!!" (3)
str.replace(str.begin()+8,str.begin()+14,"is coolness",7); // "replace is cool!!!" (4)
str.replace(str.begin()+12,str.end()-4,4,'o'); // "replace is cooool!!!" (5)
str.replace(str.begin()+11,str.end(),str4.begin(),str4.end());// "replace is useful." (6)
std::cout << str << '\n';
return 0;
}
>>
>>51791854
I'd suggest leaving all of the communication aspects to sshd and write a program which deals solely with local connections. So a user connects using ssh or PuTTY, sshd spawns a local client which connects to the chat server (either using a Unix-domain socket or pipe, or by passing a descriptor for the terminal).
>>
>>51791949
Oh you're using strings. They're different from character arrays. Do what the other anon said and use the replace function
>>
>>51791971
I'm not quite sure what most of that means, but it sounds like it would be asking too much from the end user. I really want it to be so simple any retard can use it, but with forced encryption.

I also want it to be as decentralized as possible, but I'm not sure how and if that can even be done completely. I think I may need a central server to at least let clients find the proper IPs to send shit to.

Also I feel I should mention I'm a retarded windows user (with a CS degree though)
>>
>>51791938
My 40th iteration is close to 500k
My 50th iteration is close to 7m
>>
>>51791721
Make the original set a ordered data structure, like a list. Now imagine all the combinations were done by 'selecting' which indexes to pull the value out for the combination. i.e.
[1, 2, 3, 4, 5]
1 0 1 0 0
so for a set of size s choosing r elements is simply counting from 0->2^n and using the number as a mask for selection from the list the number's Hamming weight (number of ones) is r. Since you are using C++ and I'd hope you are using gcc you can find the Hamming weight of a number with _builtin_popcount().
>>
>>51792043
Oh wait nevermind, the puzzle asks for the final length of the 40th iteration, not the actual number.
I'm still surprised my algo worked the first time.
>>
>>51792049
>so for a set of size s choosing r elements is simply counting from 0->2^n and using the number as a mask for selection from the list the number's Hamming weight (number of ones) is r.
so for a set of size s choosing r elements is simply counting from 0->2^s and using the number as a mask for selection from the list, if the number's Hamming weight (number of ones) is r.
>>
>>51791969
http://pastebin.com/zgxEabvA
>>
>>51792060
Not even close give me a second.
>>
>>51792081
Thanks for helping me, anon. I started like a week ago.
>>
>>51792049
This, of course, is stupid inefficient. As you have to check 2^n numbers and for each number do a n bit selection to build the combination. A recursive solution can generate the next combination exactly. So the difference in complexity is O(n*2^n) vs O(n * (n choose r)). The recursive solution is better.
>>
>>51792043
I managed to get to iter: 73, len: 2,075,159,224 before i run out of memory.
>>
>>51792084
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

using namespace std;

int main()
{
//Initialize Variables, might make the code a user input later
string key = "MURCIELAGO";
string code;
cout << "Inserte palabra: ";
cin >> code;
int repeat;
int check = 0;
int loops;

key.replace(key.find(code), code.length(), "FAGGOT");
cout << key << endl;
}


This could be more elegant. I suggest looking up C++ find as well. Use them both to find and replace. Also I believe you can use

#include <algorithm>


To find multiple letter with one line of code. I used this to delete from string without looping. Here's a line from my code using the algorithm library.

s1.erase(remove(s1.begin(), s1.end(), ','), s1.end()); s1.erase(remove(s1.begin(), s1.end(), '$'), s1.end());
>>
how would i go about making a sfx archive that works completely silently in C or python?
>>
>>51792128
terminate called after throwing an instance of 'std::out_of_range'
what(): basic_string::replace
Aborted
>>
>>51792147
fuccboi@m:~$ ./a.out
Inserte palabra: M
FAGGOTURCIELAGO
>>
I'm so close I can taste it

>>51792049
>>51792092
I'm on my cheap Chromebook ssh-ing into the school server right now, but I'll try that out later when I get home. Thanks anon
>>
What would you call making combinations where order matters, but repeats are allows and where order doesn't matter, and repeats are allowed? What are the uses cases of these combinations?
>>
>>51792154
Anon, that's not really what I wanted to do.

I wanted this:

Key: MURCIELAGO
Thing to encrypt: (User Input)

Encrypt by comparing each character in user input to the key and changing the words to the corresponding number.

Example:

Change the usern input (Let's say it's FAGGOT) to F8990T.
>>
>>51792168
Noice. Is that the recursive or bit-twiddling solution?
>>
File: chip8 emulator.png (32 KB, 654x356) Image search: [Google]
chip8 emulator.png
32 KB, 654x356
Does anyone else feel euphoric when shit finally werks?
>>
>>51792190
Recursive for now.

I lose a LOT more digits if I try larger size combinations. Don't shit on my code too much please. I've already done that myself
>>
>>51792207
Looks fine Jonny.
>>
>>51792178
oh woops. I was confused by what you were trying to do. I think you are close in the pastebin you posted. You just need to fix how you are checking and replacing. I have to go otherwise I'd offer another solution.


I made cipher using rot13 and rot47 recently. not complicated. ill attach my code hopefully it gives you an idea.


#include <iostream>
using namespace std;

void rot13(string xx){
for(int i = 0; i < xx.length(); i++){
if(xx[i] >= 97 && xx[i] <= 122){
if(xx[i] < 110)
xx[i] += 13;
else
xx[i] -= 13;
}
if(xx[i] >= 65 && xx[i] <= 90){
if(xx[i] < 78)
xx[i] += 13;
else
xx[i] -= 13;
}

}
cout << "ROT13: " << xx << endl;
}//end of rot13

void rot47(string xx){

for(int i = 0; i < xx.length(); i++){

int num = 33;
if(xx[i] >= 33 && xx[i] <= 126){
if(xx[i] <= 79)
xx[i] += 47;
else{
xx[i] -= 47;
}
}

}
cout << "ROT47: " << xx << endl;

}//end of rot47

int main()
{
string x = "abcdefghiklmnopqrstuvwxyz";
string y = "23456789:<=>?@ABCDEFGHIJK";
string z = "This is a test";

cout << "original: " << x << endl;
rot13(x);
rot47(y);
rot47(z);
// cout << x<< endl;
}
>>
>>51792207
My current problem

It's not returning back far enough to re-print the values that don't change. I think some of my arguments need to be passed by reference? Not sure how to fix this exactly
>>
>>51792178
One more thing. Consider using c string. This will allow you to treat both as arrays making this easier for you.
>>
>>51792260
Instead of printing from the current index in the loop, just print from the very beginning once the recursion goes to its max value.
>>
Learning clojure so trying make a lagdroid app
>>
>>51792281
>max value
*max index comboMember == r
>>
>>51792281
>>51792302
Not sure what you mean by this

But your post gave me the idea to make a separate array of size r just to hold my values that I could pass through the recursion and output at the end. I'm sure that's not what you meant but I think I'll give it a shot
>>
File: advent tree.jpg (96 KB, 701x651) Image search: [Google]
advent tree.jpg
96 KB, 701x651
Who /20stars/ here?
>>
I can't even imagine having to do all of Advent of Code in C. I would probably implement dictionaries of tuples in C just like in my Python:

import sys

def main():
houses = {}
santaPos = (0, 0)
deliverPresent(houses, santaPos)
direcs = sys.stdin.read().rstrip()
for direc in direcs:
santaPos = moveSanta(santaPos, direc)
deliverPresent(houses, santaPos)
print(len(houses))

def moveSanta(santaPos, direc):
if direc == '<':
return (santaPos[0] - 1, santaPos[1])
if direc == '>':
return (santaPos[0] + 1, santaPos[1])
if direc == 'v':
return (santaPos[0], santaPos[1] - 1)
if direc == '^':
return (santaPos[0], santaPos[1] + 1)
return santaPos

def deliverPresent(houses, santaPos):
if santaPos not in houses:
houses[santaPos] = 0
houses[santaPos] += 1

main()
>>
File: Untitled.png (55 KB, 686x392) Image search: [Google]
Untitled.png
55 KB, 686x392
>>51792355
ez
>>
Got my os to print color escaping. It's shitty in implementation. Please shit on it.
uint8_t terminal_escape_sequence(const char *es)
{
const char *es2 = es + 1;
if(*es2 == '\x1b') {
terminal_writestring("^[^[");
es2++;
return es2 - es;
}
else if (*es2 == '[') es2++;
if(es2[2] == 'm')
{
switch(*es2 - '0') {
case(0):
terminal_color
= make_color(COLOR_LIGHT_GREY, COLOR_BLACK);
break;
case(3):
if(es2[1] - '0' < 0x8)
{
terminal_foreground(es2[1] - '0');
}
else
{
terminal_writestring("^[3");
terminal_putchar(es2[1]);
terminal_putchar('m');
}
break;
case(9):
if(es2[1] - '0' < 0x8)
{
terminal_foreground(es2[1] - '0' + 8);
}
else
{
terminal_writestring("^[9");
terminal_putchar(es2[1]);
terminal_putchar('m');
}
break;
case(4):
if(es2[1] - '0' < 0x8)
{
terminal_background(es2[1] - '0');
}
else
{
terminal_writestring("^[4");
terminal_putchar(es2[1]);
terminal_putchar('m');
}
break;
default:
terminal_writestring("^[");
terminal_putchar(*es2);
terminal_putchar(es2[1]);
terminal_putchar('m');
break;
}
es2 += 2;
return es2 - es;
}
else if(*es2 == '1' && es2[1] == '0' && es2[3] == 'm')
{
if(es2[2] - '0' > 0x8)
{
terminal_background(es2[2] - '0' + 0x8);
}
else
{
terminal_writestring("^[10");
terminal_putchar(es2[2]);
terminal_putchar('m');
}
es2 += 3;
return es2 - es;
}
}
>>
>>51792325
I think I mean exactly what you are talking about. I'm just really used to closures so I don't have to pass shit around. But yeah, another array to hold the current combination and when you hit the end of the array (comboMember == r) you print out that finished combination.
>>
File: mp02S4T.png (793 KB, 2880x1800) Image search: [Google]
mp02S4T.png
793 KB, 2880x1800
Found a bug in Swift's optimizations

Basically Swift's global variables are lazily computed, however changing the optimization level to -O seemed to break that principle. Hence too different results when running the exact same code

https://bugs.swift.org/browse/SR-181
>>
>>51792369
Well duh C is not suitable for most tasks unless you're a masochist.
>>
>>51792369
def day03(data):
def solve(moves, house=(0,0)):
move = lambda (x,y), d: {'^':(x,y+1),'v':(x,y-1),'<':(x-1,y),'>':(x+1,y)}[d]
houses = set([house])
for direction in moves:
house = move(house, direction)
houses.add(house)
return houses
print("Part 1: {0} different houses".format(len(solve(data))))
print("Part 2: {0} different houses".format(len(solve(data[::2]) | solve(data[1::2]))))


>using dictionaries of tuples, but checking for uniqueness instead of just using sets of tuples, which only add if unique
>>
File: adventofcode1.png (50 KB, 629x256) Image search: [Google]
adventofcode1.png
50 KB, 629x256
>>51792355

Mirroring continued if you don't want to "identify":

Day 1: https://paste.installgentoo.com/view/raw/770a1225
Day 1 input: https://paste.installgentoo.com/view/raw/ae0e09d8

Day 2: https://paste.installgentoo.com/view/raw/a1d7af1c
Day 2 input: https://paste.installgentoo.com/view/raw/75f7f51f

Day 3: https://paste.installgentoo.com/view/raw/0eb17a9e
Day 3 input: https://paste.installgentoo.com/view/raw/5dbccc12

Day 4: https://paste.installgentoo.com/view/raw/e1e9f76c
Day 4 input: https://paste.installgentoo.com/view/raw/ca32e94d

Day 5: https://paste.installgentoo.com/view/raw/70bcb8ec
Day 5 input: https://paste.installgentoo.com/view/raw/9af42714

Day 6: https://paste.installgentoo.com/view/raw/9f864447
Day 6 input: https://paste.installgentoo.com/view/raw/1b9aadb7

Day 7: https://paste.installgentoo.com/view/raw/1c6e7472
Day 7 input: https://paste.installgentoo.com/view/raw/3294b0fd

Day 8: https://paste.installgentoo.com/view/raw/2c33c700
Day 8 input: https://paste.installgentoo.com/view/raw/4a5e19f3

Day 9: https://paste.installgentoo.com/view/raw/ea1bce9a
Day 9 input: https://paste.installgentoo.com/view/raw/da1f96f5

Day 10: https://paste.installgentoo.com/view/raw/ed4e45e9
Day 10 input: https://paste.installgentoo.com/view/raw/39260721

Answers: https://paste.installgentoo.com/view/raw/e02b3183
>>
>>51792355
>>51792373
How far can your day 10 solution go?
I can get up to iteration #73 of length 2,075,159,224 before segfaulting.
>>
>>51792395
so you are Kevin Ballard ?
>>
>>51792379
It's something at least.
>>
>>51792444
No, I'm the guy who just found the bug. Kevin reported it. I wish I was as smart as Kevin
>>
>>51792423
Bit strange adding in the input and answers when inputs and their corresponding answers are picked randomly from a set
>>
>try day 6
>have no idea how to parse input
great
>>
>>51792463
(toggle|turn on|turn off) (\d*),(\d*) through (\\d*),(\\d*)
>>
Why isn't this working? Anyone with a knowledge higher than mine would be willing to compile this and see all the errors? It's just a wall of text I can't understand to track down the errors.

http://pastebin.com/QWt6CNfN

If the code is not understandable I can explain.
>>
>>51792478
>tfw never used this before starting the challenge
>parsed it letter by letter, detecting words, commas, spaces and numbers
>look up other people's solutions
>25-50 line code solution in 1 regular expression line
I don't even
>>
>>51792460
You have to create/attach an account to get the question and random input+answer.

This is for the benefit of anyone that doesn't want to. They'll have to settle for non-random input but it doesn't really make a difference.
>>
>>51792463
i haven't even looked at it yet but i would just
>turn off 499,499 through 500,500
char state[3];
int x, y, a, b;
fscanf(file, "turn %s %d,%d through %d,%d", state, &x, &y, &a, &b)
>>
>>51792369
The lookup is just a pair of integers (x,y coordinates, which can be mapped to a line), the dictionary could just be a simple array.
>>
Post your favourite one-liners

isPrime=lambda x:(x%2!=0 or x==2) and x>1 and sum(i for i in range(2,int(x**0.5)+1) if x%i==0)==0
>>
>>51790809
I3 for widows
>>
>>51792381
I mean technically it isn't wrong

I'm sure I can figure out where I fucked up here though. Thanks for all your help anon
>>
>>51792549
int main(int argc, char **argv) { while(1) fork() } return 0; }
>>
>>51792509
I can't wrap my head around distinguishing toggle and turn on/off instructions, because toggle is one word, and turn off/on is two words separated by space
>>
File: Untitled.png (2 KB, 448x46) Image search: [Google]
Untitled.png
2 KB, 448x46
>>51792438
I'll report later since it's still running but at the moment it's at 61st iteration with 8G mem in use.
>>
>>51792536
I am a mentally retarded Python user (coincidence?) and I couldn't really think of a way to effectively map negative numbers into the simple house array. How do you deal with the reallocation when santa goes too far into negative x and y?
>>
Is there a way in bash to sleep until a specific application is open? I'm using wmctrl to have certain applications open on specific workspaces, but I don't want to just sleep for X arbitrary seconds.

#! /bin/bash

application &
sleep 2
wmctrl -r application -t 2

exit 0


This is a script I found that I'm looking to modify.
>>
>>51792499
code related, please lads, it's my first time with Python:

with open("Advent6.txt") as myfile:
data=[i for i in myfile]

lights=[]

for i in range(0,1000):
lights.append([])
for j in range(0,1000):
lights[i].append(0)

def getNumAndDigits(string, stopper):
digits=0
num=""
for i in string:
digits+=1
if i==stopper:
return [int(num),digits]
else:
num+=i

for i in data:
instruction=""
readI=0
currNum=""
nums=[0,0,0,0]

if i[6]=="n":
instruction="turn on"
readI=8
elif i[6]=="f":
instruction="turn off"
readI=9
elif i[6]==" ":
instruction="toggle"
readI=7

pair=getNumAndDigits(i[readI:],",")
nums[0]=pair[0]
readI+=pair[1]

pair=getNumAndDigits(i[readI:]," ")
nums[1]=pair[0]
readI+=pair[1]+8

pair=getNumAndDigits(i[readI:],",")
nums[2]=pair[0]
readI+=pair[1]

pair=getNumAndDigits(i[readI:],'\n')
nums[3]=pair[0]

if instruction=="turn on":
function=lambda x: 1
elif instruction=="turn off":
function=lambda x: 0
elif instruction=="toggle":
function=lambda x: 1-x

for x in range(nums[0], nums[2]+1):
for y in range(nums[1], nums[3]+1):
lights[x][y]=function(lights[x][y])

count=0
for i in lights:
for j in i:
if j==1:
count+=1
print count
>>
any crm devs here?
>>
>>51792554
looks like you are accessing out of bounds.
>>
>>51792603
>ftfy
%0|%0
>>
>>51792638
>reallocation
>arrays
nigga just use a set of coords
>>
>>51792660
while true; do
(pgrep 'application' > /dev/null && sleep 0.1) || break
done
>>
REAL THREAD

>>51792714
>>51792714
>>51792714
>>
>>51792491
What am I doing wrong?

Help?
>>
>>51792720
Go suck a fuck.
>>
>>51792702
But the grid is theoretically infinite and hardcoding a size like #define GRIDSIZE 400000 would be shit.

Also I guess I just don't understand mapping negative coordinates into a positive array index.
>>
retard coming through

can someone explain me double arrays and how to loop through these? (java)
>>
>>51792638
There's only about ~10 000 instructions, just preallocate at worst +- 10 000, i.e 20 000 elements (pack 16-bit coordinates in a 32 bit int), map 0, 0 to index 10000 and you'll never go out of bounds.
>>
>>51792762
You don't actually have to create a grid. The only (x, y) coordinates that matter are the ones you have visited.
>>
>>51792762
Not sure what you are talking about, but I mean using a set of tuples representing coords visited with 0,0 as origin

Start set
(0, 0)

Santa moves north
(0, -1)
>>
>>51792438
>>51792637

Aaand it's done.

>Iteration: 62
>lua5.1: table overflow
>>
>>51792792
>double arrays
As in an array of double (double[]) or a 2D array (int[][]) ?
>>
How do I write fizzbuzz in swift? With emojis, I mean.
>>
>>51792808
Wow I really fucked that up

Start set
(0, 0)

Santa moves north
(0, 0)
(0, -1)
>>
Are Taylor series really the best way to approximate mathematical functions like ln(x)/e^2/etc. on a microcontroller?
>>
>>51792842
how else
>>
>>51792762
>hardcoding a size like #define GRIDSIZE 400000 would be shit.
No, that is the good solution.
Always know your data, let the actual real world data inform your algorithm and data structure choices.
A O(n^2) algorithm can be faster than a O(n) for 'small' n.
>>
>>51792851
Interpolation from a lookup-table?
>>
>>51792842
No, Chebyshev polynomials are way better.
Which kind depends on the hardware, whether you have fast multiplication, how many adders and shifters, etc.
>>
>>51792549
>sum instead of len
Why?
>>
>spend hours making shit
>still can't make shit work

FUCK, I'm starting to get frustrated.
>>
>>51792699
Well fuck. The reason it's displaying that is because I forgot to store the last value into the output array in the base case before displaying

I promise I'm not retarded
>>
>>51792854
>good solution
It's a mini seasonal comp where people are competing for short code typed in order to top leaderboards. Leave the professionalism to work or more professional projects
>>
>>51792491
Doing it wrong.

Here's some C:
#include <stdio.h>
#include <ctype.h>

const char murckey[] = "MURCIELAGO\n";
const char murkval[] = "1234567890\n";

char
murcenc(char c) {
for (size_t i = 0; i < sizeof murckey - 1; ++i)
if (murckey[i] == toupper(c))
return murkval[i];
return 'x';
}

void
murc(void) {
int c;
while ((c = getchar()) != EOF)
putchar(murcenc(c));
}

int
main(void) {
murc();
return 0;
}
>>
>>51792925
It's beautiful
Thanks again everyone who helped
>>
>>51792808
You're saying you would implement a set of tuples in C for this problem?

>>51792794
>>51792854
Okay, I see. I really agree with the idea of "knowing your data" so that sunk in pretty well.
>>
What's the best way to generate a random number in assembly (x86)? Right now I'm just using rdtsc and shifting bits around
>>
So I'm using pubixml to read a bunch of text from an xml file. But I was wondering if there was an easy way to mimic what would happen if I could put a variable name(from my C++ source) into my XML file and have it use that variable every time I try to cout that text.

It sounds stupid I know but it would make my life so much easier.
>>
>>51793075
make that variable a struct of the actual type and a string for its name
like

int myvar = 10;
// becomes
myint myvar(10, "myvar");

:&)
>>
>>51793052
You could use RDRAND on newer Intel chips.
>>
>>51793121
Not an option
>>
>>51793017
Yes. With a set, you're assured of uniqueness, and because it's a set of tuples, you can easily move Santa around with a lambda function

See
>>51792415
>>
>>51793099
I'm confused here, never used structs since I'm a beginner.

What do you mean by make it a struct of the actual type?
>>
>>51793172
you shouldn't be working with a library and xml if you don't know what a struct is
>>
>>51793197
Well I kind of know what a struct is, but I've just never had to use one. So far I've only used classes and they've suited my needs. I just don't see how a struct would help with my issue here. The way I have my text structured, I don't want to have to break up the xml tags into multiple different ones to accommodate printing a variable.
>>
>>51793229
make it a class then
???
>>
>>51793229
>I've just never had to use one
>I've only used classes
they're fundamentally the same you cretentious melt
>>
>>51793256
But how would that help I don't understand. I just want some kind of functionality where I have %variable somewhere in my XML data and printing it would replace %variable with what I need.
>>
>using google docs as primary code editor

how do people get this far?
>>
>>51792991
Bootiful... post code? use [cdoe][/cdoe] tags (spelled correctly obviously).

Lua code for the same thing. Closures are REALLY nice, I only need to carry around what changes every recursion. And I wrap it up in a coroutine so I can yield the combinations in a loop, which is what it does at the bottom.
function combinations(set, r)
local p = {}
r = r or #set
local function combo(pos, comboMember)
pos = pos or 1
comboMember = comboMember or 1
if comboMember > r then
coroutine.yield(p)
else
for i = pos, #set - r + comboMember do
p[comboMember] = set[i]
combo(i+1, comboMember+1)
end
end
end
return coroutine.wrap(combo)
end

local function printTable(t)
io.write("{"..table.concat(t, ", ").."}\n")
end

for c in combinations({1, 2, 3, 4}, 2) do
printTable(c)
end

Only thing I really need to fix is the yield. tables are passed by reference only; so if some dumb motherfucker alters the returned array in the for body it's fucked up until the function touches again what the person screwed up. Ideally I could do something like this:
if comboMember > r then
table.setAttribute(p, table.ReadOnly, true)
coroutine.yield(p)
table.setAttribute(p, table.ReadOnly, false)
end

So I don't have to full-on copy the table for every combination, but can make it so that trying to set the table while in ReadOnly mode causes an error. Alas, there is no such metamethod for controlling setting in a table, I'd have to use a proxy table and the __newindex metamethod, which is a complete fucking hack. It's the only thing the authors STILL have not gotten right, slight performance degradation my ass.
>>
http://pastebin.com/QEY1ikgw

I'M SO CLOSE

FUCK
>>
>>51793345
good god dude...
>>
>>51793318
Not him, but
from itertools import permutations

Set=[1,2,3,4,5,6,7,8,9]
for i in permutations(Set,7):
print i


:^)
>>
>>51793345
lmao
>>
>>51793362
>>51793378

I-it's my first program guys

P-please
>>
>>51793345
sweet mother mary
>>
>>51793345
top fucking kek
>>
>>51793318
Here you go

#include <iostream>
using namespace std;

void combine(const int theSet[], const int r, int pos, const int size, int comboMember, int outputArray[], int outputPos);

int main()
{
int arraySize;
int rCombos;

cout << "What is the desired array size? ";
cin >> arraySize;
cout << "What size combinations are you searching for? ";
cin >> rCombos;
cout << endl;

// create the set
int theSet[arraySize];
for (int i = 0; i < arraySize; i++)
theSet[i] = i + 1;

int outputArray[rCombos];

// output
cout << "These are all the " << rCombos << "-combinations of"
<< " a set of size " << arraySize << ": " << endl;

for (int m = 0; m <= arraySize - rCombos; m++)
combine(theSet, rCombos, m, arraySize, 1, outputArray, 0);

return 0;
}

void combine(const int theSet[], const int r, int pos, const int size, int comboMember, int outputArray[], int outputPos)
// theSet is the set storing our values
// r is r-combinations we are interested in
// pos = position in array
// size = total size of array
// comboMember = which element of the subset we are currently displaying
// outputArray to hold final combination
// outputPos remembers where the next value goes in outputArray
{
if (comboMember == r)
{
outputArray[outputPos] = theSet[pos];

// output when entire combination is built
cout << "{";
for (int j = 0; j < r; j++)
{
cout << outputArray[j];
if (j != r - 1)
cout << ", ";
}
cout << "}" << endl;
return;
}
else
{
for (int i = pos; i < size - (r - comboMember); i++)
// loop condition ensures enough space to the right
{
// store value in outputArray to output later
outputArray[outputPos] = theSet[pos];

// recursive call
combine(theSet, r, i + 1, size, comboMember + 1, outputArray, outputPos + 1);
}
return;
}
}
>>
File: smileandoptimism.png (345 KB, 640x480) Image search: [Google]
smileandoptimism.png
345 KB, 640x480
>>51793399
>>51793378
>>51793345
>>51793362
>>51793415

>mfw everyone laughs at my code
>>
̊̊ ̊̊̊ ̊̊̊̊ ̊̊̊̊̊ ̊̊̊̊̊̊ ̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊ ̊̊̊̊̊̊ ̊̊̊̊̊ ̊̊̊̊ ̊̊̊ ̊̊
̊̊ ̊̊̊ ̊̊̊̊ ̊̊̊̊̊ ̊̊̊̊̊̊ ̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊ ̊̊̊̊̊̊ ̊̊̊̊̊ ̊̊̊̊ ̊̊̊ ̊̊

>̊̊ ̊̊̊ ̊̊̊̊ ̊̊̊̊̊ ̊̊̊̊̊̊ ̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊ ̊̊̊̊̊̊ ̊̊̊̊̊ ̊̊̊̊ ̊̊̊ ̊̊ ̊̊ ̊̊̊ ̊̊̊̊ ̊̊̊̊̊ ̊̊̊̊̊̊ ̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊ ̊̊̊̊̊̊ ̊̊̊̊̊ ̊̊̊̊ ̊̊̊ ̊̊
̊̊ ̊̊̊ ̊̊̊̊ ̊̊̊̊̊ ̊̊̊̊̊̊ ̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊ ̊̊̊̊̊̊ ̊̊̊̊̊ ̊̊̊̊ ̊̊̊ ̊̊ ̊̊ ̊̊̊ ̊̊̊̊ ̊̊̊̊̊ ̊̊̊̊̊̊ ̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊̊ ̊̊̊̊̊̊̊ ̊̊̊̊̊̊ ̊̊̊̊̊ ̊̊̊̊ ̊̊̊ ̊̊
>>
>>51793435 cont

Aside from MATLAB, which I took years ago and forgot, C++ is my first programming language. How hard is it to learn another language? I'm thinking of picking up Python, since that's what the 4-year uni I'm transferring to uses in their intro classes. What are the differences between different languages in terms of usage and what they're good at?
>>
>>51793437
sorry anon :(
>>
>>51793437
There's a reason why...
>>
>>51793437
shoulda used python lad..
>>
Re factoring our front end into React

Wonder how long until we decide we need a new js framework / react support falls off
>>
>>51793364
>LuaJIT
lelelelelelelelel


But yeah, python is cool in my book. I've been using it more recently.
>>
>>51793476
>>51793468
>>51793459

B-but why, though

I want to be better at programming. This is literally my first time doing something.
>>
>>51793052
How random does it need to be?

The simplest approaches to pseudo-random number generation are:
1. A linear congruential generator (LCG), which basically x = a * x + b, where a and b are large (so the calculation normally wraps around).
2. A linear feedback shift register (LFSR), where you shift a fixed-length sequence of bits along one step, with the shifted-in bit calculated by XORing some subset of the bits. The shifted-out bits are pseudo-random.

Neither of these are suitable for crypto, and not entirely suitable for applications requiring "good" random numbers. The Mersenne Twister is basically the standard non-crypto PRNG.

For crypto, any feedback or chaining block cipher mode can be used as a PRNG. Alternatively, RC4's PRNG is quite simple and fairly strong (there are enough breaks that it's now considered deprecated, but it's probably still good enough unless you're dealing with a determined adversary; it's not shit-tier crypto like DRM).

If you're trying to generate genuinely random numbers (rather than pseudo-random), you'll need more entropy than you'll get from rdtsc, and you need to use a decent whitening algorithm.
>>
>>51793522
>This is literally my first time doing something.
There is your problem, program more.
The trick is to write the least amount of code while staying readable.
A million if-else statements is cancerous
>>
>>51793522
Take a look at your if-statements and tell me if you see any similarities or repeating code. Do you see the problem?

Yes) think of a more broad approach that requires writing less code
No) install gentoo
>>
>>51793345
>long list of if else chain
>graduate level coding
Mfw he could get a job
>>
>>51793456
>C++ is my first programming language. How hard is it to learn another language?

Any non-functional language will be cake to learn if you know C++. But then again, you don't *know* C++, do you?

There's only one way to learn: start programming in it. Building a daily habit of learning and applying is the hard part. You have to get over the hump to begin writing idiomatic LanguageX. Otherwise, you'll forever be writing C++ style LanguageX.
>>
>>51793596
Mfw I'm a front end dev with OOP background
Mfw everything I write look's like c++
Mfw community now calls this "modular"

Learn oop and rest easy knowing functional methadologies are spaghetti
>>
>>51793532
>How random does it need to be?
Random enough to be suitable for a standard library function in an OS. The problem is I don't really have the first clue about how to generate the damn thing.

I'll look into Mersenne Twister (found some other mentions of it on google) and the linux kernel. Thanks anon.
>>
>>51793345
Unless I'm missing something, ++loops will always skip the first character too

>>51793596
I've been getting good grades in my classes and generally the assignments come pretty easily to me. But I'm by no means a master at it. Should I wait until I'm better at C++ first?
>>
free(calloc(SIZE_MAX, 1));
if you care about security
>>
How do I avoid annoying if/else chains in C++, /dpt/?
>>
>>51793650
wait 1 year after starting your first language to learning another
>>
>>51793753
It's been a year and a half
>>
>>51793749
Generally, you can't.
>>
>>51793749
learn how to program
>>
>Tfw cannot figure out how to read registry keys in retarded winapi

How the fuck are you suppose to do this?
>>
>>51793761
go ahead then
>>
>>51793771
Why do you want to read registry keys
>>
>>51793749
What are functions / classes?
Learn computer theory as you learn to code. Syntax doesn't matter if you're literally writing monkey logic.
>>
>>51793786
I want to make a practice program that will tell the User's hardware. and that's stored in registry keys
>>
File: solution.png (14 KB, 851x330) Image search: [Google]
solution.png
14 KB, 851x330
>>51793749
>annoying
>>
>>51793805
Anon why
>>
>>51793749
If you're this guy >>51793345, then please learn that where there's repetition, there's an opportunity to refactor into a function, a LOOP, etc.
>>
>>51793345
#include <limits.h>
#include <stdio.h>

int main()
{
unsigned char lut[UCHAR_MAX + 1] = {
['M'] = '1', /* C++fags wish they could do this */
['U'] = '2',
['R'] = '3',
['C'] = '4',
['I'] = '5',
['E'] = '6',
['L'] = '7',
['A'] = '8',
['G'] = '9',
['O'] = '0'
};

unsigned char code[] = "PRUEBA";

for (size_t i = 0; i < sizeof(code); ++i)
if (lut[code[i]])
code[i] = lut[code[i]];

printf("%s\n", code);
}
>>
>>51793749
use lambdas
>>
>>51793771
>>51793802
Well /9gag/?
>>
>>51793831
lambdas are a meme, anon
>>
>>51793456
>How hard is it to learn another language?
Not difficult. The basics of all languages are common, unless you head into functional-land... Python is a good choice. I could go into a detailed analysis, but the categories of programming languages are generally this:

>Compiled statically-typed procedural languages
C, C++, Fortran, Ada, Pascal, etc.
You know C++, so you know what these languages are like

>Compiled (usually JIT'd) statically-typed managed languages, usually procedural with lots of OOP, little functional
Java, Go, C# and F#
You'll need to learn OOP to really take advantage of these languages, although they are somewhat simpler since they manage object creation and deletion for you (no need to delete()) and usually have fuller libraries with abstract data structures, algorithms, and convenience utilities made for you. But you'll be comfortable going to these languages because they are usually very similar to C/C++.

>Interpreted dynamically-typed languages
Python, Lua, Ruby (but that's a little more functional than the rest), Tcl, Javascript
Supports C-like procedural at its base, but usually has an object system and a few functional-esque (usually inspired from LISP) features like first-class functions which allow for a lot more flexibility in your programming style. It might take some time to attune to the mode of thinking necessary for these languages if you are a hard-baked C++ programmer.

>Shell scripting languages
Bash, Cmd/Powershell, AutoHotkey
Slow as fuck, have few if any built-in abilities and usually rely on DSLs and system programs for functionality, but are usually invaluable for system maintenance, NOT for general programing. I'd learn one for your system, if only half-heartedly.
>>
>>51793885
>Go
>OOP

que
>>
>>51793906
interfaces are still OOP. Structs still have methods which operate only on them. Go just does it a little different (better IMO).
>>
>>51793940
I agree that Go has done "OOP" better by only having polymorphism, but the lack of any sort of generic programming really sours it.
>>
New thread

>>51793974
>>
>>51790935
Even as a beginner programmer, I get this joke.

I'm laughing at computer jokes now. What has my life become.
>>
>>51793977
224 you cunt
>>
>>51793965
Yeah, generics are a must in a modern language, especially when it has to compete with Java and C#. They fucked the pooch on that one. Yet another project limited by over-opinionated dictators.
>>
Why won't this work?

if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("BCD00000000\\HARDWARE\\DESCRIPTION\\System\\BIOS\\CentralProcessor\\0\\ProcessorNameString"), 0, KEY_READ, &hkey)!= ERROR_SUCCESS)
{
MessageBox(NULL, "Can't open the registry", "Error", MB_OK);
}
>>
>>51794016
I just don't see what Go is good for. It's got C's lack of flexibility, with the performance characteristics of any other managed language, and coroutines, which aren't really that special anymore.
>>
>>51792610
if (strcmp(state, "off") == 0);
// do stuff
else
// do other stuff
>>
>>51794048
anyone?
>>
>>51794055
>and coroutines, which aren't really that special anymore.
Go does them much better than any other language, I'll give it that. Java's coroutines are convoluted shit, most other languages aren't as flexible as Go's because they either run only on a single thread, or can't be coordinated between multiple threads, or are too heavy to be used the way Go can use them. Of course excluding Erlang, but that's a given...
>>
>>51793885
Thanks for the write up, anon, even though I had to Google to understand some of what you said.

I know I have a long way to go, but this is one of the few subjects I'm actually excited about in school. Every program is like playing a puzzle game. It probably won't be like that in the real world but for now I'm having a ton of fun and I think I'll be able to handle the grind of everyday work in this field
>>
>>51794048
Sorry, no one here cares to deal with Microsoft-only problems.
>>
>>51793290
>cretentious

That's a new one.
>>
>>51794055
It's pretty much a C upgrade for me, which is very nice.
>>
>>51794148
Is everyone an unemployed neet tbqh?
>>
>>51794152
It's like a combination of cretinous and pretentious. I like it.

>>51794162
>Employed = Microsft baby
Yeah, you're right. That's every single one of us.
>>
In c++, how do I read from an excel file then rewrite certain values?
>>
>>51793345

Well, looks like I'm not ready for codding yet. I still can't find any way to avoid the alrge IF chains. I think I'll go back to reading Absolute C++
>>
>>51794212
We've been helping you anon
You see all those if statements with only one character changed between them? You can use a loop to condense it
>>
>>51794210
analyze the excel file
>>
>>51794212
Reading books isn't going to help you
>>
>>51794235
Not denying you were helping me, actually you helped me a lot.

Just saying I'm still too shit for "complicated" projects.
>>
>>51794212
I don't know. You just need to reason about your program some more. Notice how you do
                if(code[loops] == key[0])
{
code[loops] = keyVal[0];
}
and the index of both the arrays are the same? It usually means you can do something more general than what you are doing here and cut the amount of code down to a few lines.
>>
>>51794212
this isn't even difficult
        for(loops = 0; loops <= sizeof(code); ++loops)
{
if(code[loops] == key[0])
{
code[loops] = keyVal[0];
}
else if(code[loops] == key[1])
{
code[loops] = keyVal[1];
}

could be rewritten in 2 lines.
int i;
for (i = 0; i < sizeof(loops)/sizeof(loops[0]); ++loops)
{
keyVal[i] = code[i];
}
>>
>>51794210
Does it have to be excel? xlsx is pretty complicated. If you just need a basic spreadsheet, use csv.
>>
>>51794188
>It's like a combination of cretinous and pretentious. I like it.

Exactly.

>Microsft baby

Also, what's wrong with that? C# is good. It feels good. And Mono is available for loonixfags. :)
>>
>>51794298
>If you just need a basic spreadsheet, use csv.

Which, as a bonus, if excel is the target, it's great at dealing with CSV files.
>>
>>51794302
In what way does C# help with using winapi over C++?
>>
>>51794274
That's not correct. He isn't trying to set keyval, he wants to transform the string code using key/keyval as a map. He just isn't setting things up correctly.
for (int i = 0; i < sizeof(code); i++) {
int j;
for (j = 0; j < sizeof(key); j++) {
if (code[i] == key[j]) {
goto found;
}
}
// do not transform, no transformation found
continue;
found:;
code[i] = keyval[j];
}
>>
>>51794340

Most of the WinApi stuff is already wrapped. Registry.GetValue && Registry.SetValue are very noice, not that I advocate using the Registry for any reason.
>>
File: Untitled.png (1 KB, 291x39) Image search: [Google]
Untitled.png
1 KB, 291x39
>>51794298

Yeah, it has to be excel. The professor is doing it for a final project for c++ programming. I have to create a program that reads the excel file, rewrite new values, and saves it into the excel sheet.
>>
>>51794359
>Registry.GetValue && Registry.SetValue are very noice, not that I advocate using the Registry for any reason

Sweet because I am struggling like a nigger to do that in c++.

int main()
{
using namespace std;

HKEY hkey;
DWORD type = REG_SZ;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("BCD00000000\\HARDWARE\\DESCRIPTION\\System\\BIOS\\CentralProcessor\\0"), 0, KEY_READ, &hkey)!= ERROR_SUCCESS)
{
MessageBox(NULL, "Can't open the registry", "Error", MB_OK);
}
else
{
MessageBox(NULL, "Successful", "Success!", MB_OK);


return 0;
}

This is what i have so far. I may giving a lil visit to mr C# soon
>>
File: 1431524229524.jpg (27 KB, 217x320) Image search: [Google]
1431524229524.jpg
27 KB, 217x320
>tfw only 4 stars
JUST
>>
>>51794380
why on earth does it keep failing

also opps didn't copy the header files and forgot a bracket but the point is the same
>>
>>51794409
UAC maybe?
Thread replies: 255
Thread images: 34

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.