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

/dpt/ - Daily Programming Thread

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

Thread replies: 340
Thread images: 35

File: 1481654229907.jpg (264KB, 1440x1080px) Image search: [Google]
1481654229907.jpg
264KB, 1440x1080px
What are you working on, /g/?

Old thread: >>59794995
>>
Please do not use an anime image next time. Thanks.
>>
Reminder:
http://harmful.cat-v.org/standards/

UTF-8 is the only good string encoding standard.
>>
>>59800214
>programming on wangblows
>>
>>59800214
>HINSTANCE hPrevInstance
>>
>>59800214
I doubt that animegirls are into winapi desu
>>
What is man supposed to use when here's just no good statically typed and compiled language.
>sml
no good implementaion
>ocaml
sml with shitty syntax, also does not support native threads
>lisp
too verbose, also static typing not standardized
>c
decent but manual memory management is annoying in prototyping phase
>sepples
cluster fuck that no sane person would touch
>d
can't decide if it wants to have gc or no
>rust
better stay away from it because it attract lot of crazy hipsters
> any jvm/clr lang
requires huge vm
>go
Rob Pike is faggot, also no macros
>>
>>59800248
fuck uriel and his gang
the only good thing they ever made is dmenu
>>
>>59800248
>cat-v
opinion discarded

>>59800296
Pascal?
>>
>>59800296
time to write your own language
>>
Anyone arguing against UTF-8 should kill themselves.
>>
File: 1479596863096.png (20KB, 640x480px) Image search: [Google]
1479596863096.png
20KB, 640x480px
>>59800296
>Not using Ada with RAII or scoped dynamic memory pools
>>
>>59800362
Honestly why shill Ada when even the military stopped using it?
>>
>>59800248
The thing I don't like about Unicode is the fact that code points are distinguished from code units even though you still sometimes need multiple code points to represent a grapheme, and some graphemes can be represented in more than one way.

Otherwise it's definitely the best thing we've got. It's extremely unfortunate that Windows uses UTF-16. UTF-32 is kind of worthless because graphemes essentially have a variable-length encoding on top of code points.
>>
>>59800374
>why shill Ada
Cause it's genuinely really good? I don't follow.
>>
>>59800404
The syntax is horrible
>>
>>59800430
It's constant and obvious. I bet you could read a complicated program in it right now and you would follow it easily.
>>
>>59800348
Not an argument.
>>
>>59800470
>end
>>
>>59800470
That's not a good thing anon. That's like saying COBOL is great simply because i can read it even as a layman.
>>
File: 1479747636105.png (12KB, 600x285px) Image search: [Google]
1479747636105.png
12KB, 600x285px
>>
>>59800474
End isn't valid on its own. What are you taking about?

>>59800484
>Clear meaning isn't good
>Muh sekret klub
>>
>>59800518
Do you also think COBOL is great anon?
>>
File: hr.png (88KB, 900x663px) Image search: [Google]
hr.png
88KB, 900x663px
Is it true that IIT produces the best programmers?
>>
>>59800530
I've never used it. But if the only negative you can come up with is 'clear intent', it sounds pretty good.
>>
>>59800530
The biggest problem with COBOL is that it doesn't support local variables or dynamic memory allocation.
>>
File: 1489703537699.png (438KB, 569x486px) Image search: [Google]
1489703537699.png
438KB, 569x486px
>>59800214
Stuck on this gay pancake problem in google code jam.
Doing it in C.
Help me.
>>
File: google-spy.jpg (120KB, 650x489px) Image search: [Google]
google-spy.jpg
120KB, 650x489px
MASSIVE WIKILEAKS HAPPENINGS HAPPENING AT THE SAME TIME RIGHT NOW

HUGE NSA HACKING TOOLS LEAK IN PROTEST OF TRUMP STRIKING SYRIA

https://twitter.com/wikileaks/status/850758438451765253
>Shadow Brokers releases password to NSA hacking tool binaries from 2013 as "protest" over "abandoning base"

https://twitter.com/wikileaks/status/850765624477274112
>Browsable decrypted Shadow Brokers "NSA" hacking tools+docs files corresponding to password released today

https://twitter.com/wikileaks/status/850782274362593280
>Today's #ShadowBrokers NSA dump shows hundreds of NSA attacks on China + pretending to be China when hacking

https://twitter.com/wikileaks/status/850783902616625152
>Today's #ShadowBrokers NSA dump shows hacking attacks on EU states, LatAm, Russia, China, Japan & South East Asia

LEAKED GUCCIFER2.0 CONVERSATION SAYS SETH RICH WAS THE LEAKER
>SETH RICH WAS THE LEAKER

https://twitter.com/wikileaks/status/850692885062139904
>Direct Messages from U.S. alleged Russian spy @GUCCIFER_2 to actress-model @robbin_young (according to the latter) http://g-2.space/sr/dms.html

VAULT 7 PART 4

https://twitter.com/wikileaks/status/850285712696061953
>RELEASE: CIA malware for Windows "Grasshopper" -- which includes its own language

https://twitter.com/wikileaks/status/850323865972596738
>CIA malware "Grasshopper" re-installs itself every 22 hours by corrupting Windows Update--even if is disabled.

https://twitter.com/wikileaks/status/850339013412114432
>CIA docs show that its "Stolen Goods" malware is based on code from "suspected Russian mafia" #Vault7

Julian Assange Press Conference and Q&A on Vault 7, Year Zero and the CIA (03-09-2017)
https://youtu.be/uxmMt4EW3PQ [Embed]

WikiLeaks Julian Assange Press Conference On CIA Hacking "Dark matter"(3/23/2017)
https://www.youtube.com/watch?v=UJdioGzBiY0 [Embed]

https://wikileaks.org/ciav7p1/
https://wikileaks.org/vault7/
>>
I was doing tidy numbers until I came across the test case 111111111111111110 which is going to take literally ages to run through in either direction.

How the fuck am I supposed to turn in the answer in less than 8 minutes?
There's 100 inputs and they're all 10^18 numbers like this.
>>
>>59800573
Go to IHOP, get inspiration.
>>
How do I edit certain parts of an HTML file in C++.
>>
Anyone solved D guys? Is it fucked up? Got meself 65 points and now I am tired
>>
>>59800305
>implying dwm isn't good
it's probably my 2nd favorite WM after CWM
>>
Can someone help me out here? I got a linux box with apache php mysql and wordpress installed. Now clearly i intend to make a website.

Now I want to write the website in java... so do i wipe the box and put tomcat on it? Wordpress makes it look nice and pretty and shit but that uses php.

I am super super confused right now

Yes, I want to write it in java
>>
>>59800573
You are most likely overthinking it a lot
Take a breath and start fresh, it's really easy
>>
>>59800748
You could use a PHP Java interpreter
>>
>>59800296
>lisp
>too verbose
it honestly depends on the dialect
>>
>>59800296
Learn Haskell, then Idris
>>
>>59800693
If it's not too complicated regex should work.
>>
>>59800798
>haskell
>garbage 1gb/s
>>
>>59800801
https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags
>>
>>59800811
>believing memes
>>
>>59800835
>he doesn't know
>>
>>59800845
>implying
>>
>>59800811
>>59800835
>>59800845
>>59800859
WHO ARE YOU QUOTING
>>
File: 1487186880324.jpg (28KB, 606x604px) Image search: [Google]
1487186880324.jpg
28KB, 606x604px
>python developer
>want to learn C++ to get dat hedge fund money
>start Accelerated C++
>supposedly a book for people who can already program
>introduces basic concepts like loops at length with dense, jargon-filled text

I was promised a quick and dirty intro to C++

What the fuck is this
>>
>>59800859
>implying implications
>>
>>59800214
Yo fellas.
I have written a space invaders clone. Now I need to make it so when I press a key it goes in reverse. I am using a stack and I got it to push values on, but I can't figure out how to pop them and have it actually "play" in reverse.
Right now I'm making all the game features into functions, then maybe I will have it simply go backwards if passed certain values. IDK
>>
>>59800877
>python developer
It's too late. Your brain is far too damaged.
>>
>>59800824
kek. Thanks, did not know this.
>>
>>59800877
Typical python "dev"
You're on the same level as people who don't know anything about programming, lmao
>>
>>59800876
You.
>>
>>59800949
Sad but true.

Python babbies always get flustered when I interview them.
>>
>>59800877
You're going to need all the help you can get to de-retardize your brain, pycuck.
>>
>>59800915
Rewrite it in Idris. Then it will pretty much add the feature for you.
>>
>>59800968
>>59800949
>>59800932
Show me your ways, wise C++ jews

How do I convert
>>
>>59800988
Learn a real language like JavaScript

C++ is pretty much never used for new projects now
>>
File: edgy.jpg (67KB, 815x335px) Image search: [Google]
edgy.jpg
67KB, 815x335px
>>59800932
>>
>>59801000
>C++ is pretty much never used for new projects now
Don't say that.
>>
>>59801122
Why? It's true. Most new projects are done in more modern languages.
>>
>learning javascript
https://www.youtube.com/watch?v=XT25JQ6X9OU
>>
>>59801128
Modern C++ is a thing, too.
>>
File: DijkstraNonApprova.png (322KB, 1040x1484px) Image search: [Google]
DijkstraNonApprova.png
322KB, 1040x1484px
>>
>>59801176
I don't know what would Dijkstra love.
>>
>>59801167
Too little, too late. Maybe if C++17 had been C++07 then the language would survive.
>>
Does anyone know why I get this error? I'm trying to auto open an HTML file that was created.
>>
>>59801194
Functional Programming.
>>
>>59801216
So JS?
>>
>>59801212
ShellExecute most likely wants a
const wchar_t
.
>>
>>59801216
>this is what haskeks actually believe
>>
>>59801212
Use ShellExecuteA or prefix your strings with L for wide strings, i.e L"open"
>>
>>59801246
TY, I placed an A after "ShellExecute" and it worked. wtf why though, lol.
>>
>>59801232
>not le argument
>>
>>59801262
the quirks of winapi
>>
>>59801197
It's strong in game development, and wherever you need performance, that's all I care about.
>>
>>59801315
If you want performance you should use FORTRAN.
>>
>>59801262
Windows has two version of most functions taking strings in some form, an ascii and wide char version - ShellExecuteA and ShellExecuteW in this case - and then ShellExecute is a macro which gets defined as one or the other depending on whether _UNICODE is defined (which it is by default in Visual Studio since 2010 if I remember correctly).

Windows fucked up by picking UTF-16 and a wide char type for their unicode solution which broke binary compatibility, requiring two versions of every function dealing with text.
>>
>>59801197
You are out of touch if you think that C++ is dying. It is the third most used language. There is not an obvious replacement for it or the vast ecosystem.
>>
>>59801354
Rust, of course.
>>
>>59800375
>It's extremely unfortunate that Windows uses UTF-16
Oh, the good ol' days when people thought we would solve the codepage problem forever by simply moving to 16bit chars.
>>
>>59801366
Yeah
And Esperanto is an obvious replacement for English
>>
>>59801366
You don't believe that yourself, Anon.
>>
>>59801366
Rust is great but the ecosystem is pretty bare.
>>
>>59801292
>le
You have to go back.

>>59801320
Fortran's performance advantage is specialized in certain types of matrix calculations. And with C's restrict keyword, performance is almost the same.
>>
>>59801510
please explain restrict like I am a retard
>>
I was about to do a project in Elixir
then I saw a youtube video
then another
then another
then another
then another
>>
>>59801539
pointers don't point to the same memory location
>>
>>59801400
Esperanton oni kreis ne por anstataÅ­igo de l'Angla lingvo.
>>
>>59801539
When you mark a pointer restrict, you are promising the compiler that any accesses through it are non-aliased. This enables some minor optimizations, but can be used all over the place so in total you can get a big gain.
>>
>>59801087
What does the original say?
>>
>>59801539
>>59801578
It's pretty much the opposite of volatile, if that helps.
>>
>>59801641
restrict has absolutely nothing to do with volatile.
>>
>>59801662
Volatile says that the memory might be modified more than assumed by default, restrict says it will be modified less than assumed by default.
>>
>>59801629
It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.
>>
>>59801641
>>59801662
>>59801669
Is it allowed to label something both volatile and restrict?
>>
>>59800214
Python scripting project because webdev and (((hybrid))) app devs are mentally damaged.
>>
>>59801670
You could have just said BASIC but thanks anyway.
>>
>>59801682
It's allowed but I'm pretty sure it would be nonsensical.
>>
>>59801669
>Volatile says that the memory might be modified more than assumed by default
Volatile says that reads and writes to it should not be cached.

>>59801682
Probably, but it would be pretty useless. restrict aids optimisation, but volatile hinders it.
>>
>>59801641
False. Volatile is an optimization barrier that says a value might be changed in-between accesses.
>>
>>59801687
Yeah, I just copied and pasted it, because I didn't knew it myself.
Here's an explanation of why he said that: http://programmingisterrible.com/post/40132515169/dijkstra-basic
>>
if all of quake is on github, cant i just compile it or w/e and then have the game? what am i missing?
>>
>>59800545
no

HackerRank doesn't mean shit when you mention "the best"
>>
>>59801714
textures, maps, sounds, and what not
>>
>>59801714
Yes, you can, but you'll be missing the assets.
>>
>>59801700
>>59801701
And restrict hints to the compiler that the value won't be changed except through that pointer, allowing more caching. Restrict and volatile preclude each other and basically have the opposite effect (trading efficiency and volatility in either direction).
>>
>>59801700
volatile restrict is useful. Without restrict a non-volatile point could alias a volatile pointer. Every dereference through the volatile pointer would invalidate all the cached values of that type.

With volatile restrict the compiler knows the volatile overhead is only necessary for this instance of a value, and not all values of the same type.
>>
>>59801784
Ooh, that's right. I wasn't considering that volatile can have effects on other pointers that could be stopped with restrict.
>>
>>59801784
Actually, that's a pretty good point.
I just use volatile so rarely, I don't really think about its consequences very often.
>>
>>59801826
Volatile is confusing. The actual semantics seem to only be useful for IO mapped values
>>
>>59801847
You also need to use it to modify values in signal handlers.
>>
>>59801784
>>59801808
Wait, is it really allowed for a non-volatile pointer to alias a volatile one?
>>
since I had no idea how to use maps I decided to hardcode my HTML files. Like i literally have 151 if statements that creates a new HTML file depending on the Pokemon. Couldn't figure out how to edit an HTML file precisely. :S

Another thing is idk how to make a button from a Web Page to trigger as continuing the program, or would it start a new program? Can I do that in a Web Page, set the button to open up/execute a new program?
>>
>>59801881
Yes, I don't see why you couldn't.
>>
>>59801904
Wouldn't it make more sense to say that volatile pointers must only alias with other volatile pointers?
>>
>>59801904
Should be a compiler warning though.
>>
>>59801883
Holy shit dude. Why don't you start over and do this with static HTML/jquery.
>>
>>59801929
volatile just works like any other qualifier (e.g. const). It's completely find for an unqualified type to have a "pointer to a qualified type" taken of them.
void fn1(const int *ptr)
{
// ...
}

void fn2(volatile int *ptr)
{
// ...
}

void fn3(const int *ptr1, volatile int *ptr2)
{
// ...
}

int main()
{
int a;
int *ptr = &a;

// These are both fine
fn1(ptr);
fn2(ptr);

// Still fine, as it's just doing the same as above
fn3(ptr, ptr);
}
>>
Is there a way to control how many levels you can break; out from in C?
>>
>>59802004
No. Just use goto.
>>
>>59802001
>It's completely find
It's completely fine*
>>
>>59801970
I've never even heard of jquery. :L
>>
File: Edsger_Wybe_Dijkstra.jpg (846KB, 1200x1600px) Image search: [Google]
Edsger_Wybe_Dijkstra.jpg
846KB, 1200x1600px
>>59802010
Excuse me?
>>
Is the tech scene in NYC anything like SIlicon Valley? I live in NYC currently and state schools just became tuition-free but you need to stay in the state for 4 years, so I want to know how badly that'd cripple my job opportunities.
>>
>>59802010
>>59802039
It's alright I just had to add another level to my if statement.
>>
ok, so I did super.equals(obj) and it gave me null pointer exception, how come?
>>
MY PARSER FINALLY WORKED, I'M SO HAPPY I WANT TO CRY
>>
A database of teaching credits for my university.

I am a mechanical engineer.
>>
>>59802039
>>59802063
Despite what dik suckers believe, breaking out of nested loops is a fine place to use goto. Certainly better than declaring unnecessary variables and convoluted if statements.
>>
>>59800296
F#, OCaml with good concurrency model and native ints
>>
>>59802094
Whats a teaching credit?
>>
>>59800588
what is your method, mine is quite simple and completed it instantly
>>
>>59802107
haskell has better currency, rigth?
>>
>>59802115
Each professor needs to teach 4 courses a year.

Since thats not possible, they have a -4 added to an excel sheet that acts as a credit that needs to be filled. some prof's are under teaching and some are over teaching.

Courses with labs and extra shit are worth more than 1 course maybe 1.25 courses depending on the student count.

Currently all this data is tracked and kept in the hands on 1 person on excel sheets.

The university hired me to make a web based database for this information.
>>
>>59802157
Nope, it's worthless.
>>
>>59802223
do they know you're a mechanical engineer?
>>
>>59802243
One of them didn't and everyone I meet assumes im ECE.

Guy who hired me says im doing better than his computer engineers so im just going along with it.
>>
>>59802290
yeah but arent you over your head?
>>
>>59802040
Can someone answer this? May ask in /r/cscareerquestions
>>
>>59801714
you might as well grab one of the forks too since running the old quake executables is an exercise in frustration
>>
>>59802311
I take every opportunity to remind them.

But money is good, they are happy with the work. As far as i'm concerned its all good.

I pray for the soul that needs to pick up the project after its done. And its free on github for everyone to see just how big of a mistake it was hiring a mech eng for a job people usually need 7 courses in.
>>
i didn't know C had string concatenation and its literally this fucking easy
#include <stdlib.h>
#include <stdio.h>

int main()
{
char* str = "hello," " world";
printf("%s\n", str);
return 0;
}


fuck me i'm 100% sure i've done some stuff in C because i didn't know that which looks super retarded
>>
File: x plus i y cubed minus 1.gif (2MB, 360x360px) Image search: [Google]
x plus i y cubed minus 1.gif
2MB, 360x360px
>>
>>59802320
I work for a fintech company in NYC. From what I understand the NYC tech sector is much smaller than the Bay Area, but it's there, certainly bigger than, say, Pittsburgh. More banks, hedge funds, etc. than CA. A lot of companies using JVM languages e.g. Scala, Clojure. In short I don't think you'll be wanting for job opportunities there.
>>
>>59802396
yeah database stuff is later in the 4 year cs program

https://netbeans.org/kb/docs/web/mysql-webapp.html

this is a decent start
i dont think you are gonna get 4 years of cs in a post on 4chan
>>
>>59802525
Currently using peewee as my ORM.

Dosn't matter tho, got 2 weeks left in my contract and ive basically completed the project to my contract requirements.
>>
>>59800214
currently working on a user signup, with html and python.

I cant figure out how the post function is supposed to communicate things back to the get function



class MainHandler(webapp2.RequestHandler):

def get(self):
add_username = """
<form action="/" method="post">
<label>
Username <input type="text" name="user_name" value = ""/>
</label>
</form>
"""
add_password = """
<form action="/" method="post">
<label>
Password <input type="password" name ="password" value = ""/>
</label>
</form>
"""
validate_password = """
<form action="/" method="post">
<label>
Password <input type="password" name ="password" value = ""/>
</label>
</form>
"""
# error = self.request.get("error")
# if error:
# error_esc = cgi.escape(error, quote=True)
# error_element = '<p class="error">' + error_esc + '</p>'
# else:
error_element = ''
password_error = ''


content = page_header + add_username + error_element + add_password + password_error + page_footer
self.response.write(content)
def post(self):
error_element = ''
have_error = False
user_name = self.request.get("user_name")
password = self.request.get("password")
params = dict("")
if not valid_username(user_name):
error_element = "thats not a valid username"
have_error = True
if not valid_password(password):
password_error = "thats not a valid password"
have_error = True

what is supposed to go here?
>>
3 digit palindrome checker
#define ISDERP(n)(\
(n)%10==(n)/100000%10&&\
(n)/10%10==(n)/10000%10&&\
(n)/100%10==(n)/1000%10)
>>
>disable all these defense mechanisms just to exploit a buffer overflow
it seems so impractical, can these attacks actually yield any sort of real result

it seems completely archaic, especially since C is dying anyway and rust is the future
>>
>>59802605
rust is a horrible programming language
>>
>>59802582
>macro
for purpus?
>>
A switch case in C can't work with a """string""" variable, right?
>>
>>59802628
No, switch statements can't work with char*
>>
>>59802605
Buffer overflows potentially let you overwrite the part of the stack frame that determines where in the program to jump to once the function returns. One possibility is to write a bit of assembly that opens a shell. If the program runs with root privileges and you redirect a return address to your shell code, you can get root privileges.
>>
is cs the most stressful job? what job do you need to know like 3000 languages and how all this shit works

shits nuts
>>
>>59802651
get out faggot
>>
File: 1475648148606.jpg (82KB, 400x500px) Image search: [Google]
1475648148606.jpg
82KB, 400x500px
>>59800591
>>59800778
So I wrote this. To the best of my knowledge it's correct. Comparing my results manually I haven't been able to find a case it got wrong.
But code jam says it's incorrect?
What do?

https://pastebin.com/unrmfAkT
I don't have much time left :(
>>
>>59802489
Nice. I'd love to stay in the city anyway. Do you know how aggressively people progress in their careers on average? Also would it be okay if my CS degree were to come from one of the better SUNYs?
>>
>>59802650
yeah i know but people randomize address space, put canaries, make the stack not executable do bounds checking etc.

seems really fucking hard, in practice to actually abuse a buffer overflow - it can still be done, but it doesn't actually happen right
>>
>>59802656
doesnt really answer my question
>>
>>59802624
C isn't well thought out and even with schemes it's not completely safe
>>
>>59802681
Nowadays it's more common for buffer overflows to result in sensitive information being leaked, like with Heartbleed. So it's still a problem.
>>
>>59802039
>>59802100
Even Dijkstra admitted that goto has its uses, and that not all uses of the goto statement can be converted into a "clean" structured style. And cleanness was the main purpose of his anti-goto campaign, because goto-heavy code tends to be difficult for humans to follow (keep in mind that the early languages like BASIC and COBOL had no local variables and often no labeled subroutines, so complex code easily turned into a mess). Indeed, modern languages still have labeled break and continue, which handle some of the common use cases of goto that can't be easily translated into if or while, without giving the programmer total power to mess things up; same reason why most languages don't let you play with raw pointers. I'm not sure if it's been proven that all gotos can be converted into if, while, for, or labeled break/continue, which probably is why languages like D continue to support goto.
>>
Hello my friends. Got an internship but it's web app stuff (ugh). C#, HTML/CSS, Javascript. I've only done shit in C, Java, and Python before. Any recommended learning resources? I tried Udacity but their javascript lesson was slow as shit for retards who've never programmed.
>>
>using goto for complex control flow instead of continuations
>>
>>59802711
>Heartbleed
>2014
i didnt know any cs or programming back then
but that seems more like a shitty bug than something systemic

meaning buffer overflows aren't actually very useful as a general tool
>>
>>59802741
Buffer overflows are always bugs. It's just that sometimes they can be exploited, though much less on modern systems.
>>
>>59800214
Working on a terminal emulator that emulates hardcopy terminals - just got half linefeeds to work, now need to optimize display.
>>
>>59802721
GOTOs are usually limited nowadays, though.
>>
>>59802039
Read "On a somewhat disappointing correspondence".
>>
¯\_(ツ)_/¯
"use strict";
var T, i = 0;
const
regs = [new RegExp("\r", "g"), /[^+-]/g, /-+/g],
input = (fs =>
{
let read = fs.readFileSync(process.argv[2], "utf8")
.replace(regs[0], "").split("\n")
.filter(line => line !== "");
T = read.shift() | 0;
if (T < 1 || T > 100 || T !== read.length)
throw SyntaxError("wrong input");
return read.map(line =>
{
let [S, K] = line.split(" ");
K |= 0;
if (regs[1].test(S)
|| 2 > K || S.length < K
|| 2 > S.length || 1000 < S.length)
throw SyntaxError("wrong input")
return [S, K];
});
})(require("fs"));

for (;i < T;)
{
let S = input[i][0], K = input[i][1],
check, flips = 0, _len;
if (~S.indexOf("-")) {
if ((check = (_len = S.length) - K * 2) < 0
&& S.indexOf("-", _len - K) < _len - K - check)
flips = "IMPOSSIBLE";
else
flips = S.match(regs[2]).length;
}
console.log("Case #" + ++i + ":", flips);
}
>>
>>59802657
check
---------- 10

it gives me impossible from your code, but it's clearly 1
>>
>>59802404
Pretty sure that only works at compile time though, it's mainly to support very long strings without going over the 72-column limit. I'm pretty sure
char *a = "foo";
char *b = *a "bar";

doesn't work, so it's not really useful for actual string handling. I discovered this feature myself while trying to port some ancient BASIC programs which were extremely string heavy (they were mostly games with a lot of "story exposition" at the beginning).

>>59802605
It really depends on whether you can actually get arbitrary data in there in the first place. Buffer flows are only useful if you can trick the user into exploiting them (or you exploit themselves on a system where you have limited privileges), because any compiler allows "arbitrary code execution" already, and it's much easier than buffer overflow exploits. Mainly they're useful when they allow a file to execute as code merely from opening it, because simply tricking someone into downloading an exe disguised as a doc won't do anything unless they actually try to run it as an executable.

>>59802627
Speed.

>>59802649
Is that really true though? Wouldn't they just treat the base address as an integer? Would be useless for "string" operations though, obviously.

>>59802710
What are "schemes"?
>>
if(condition1)
{
if(condition2)
{
statement2;
continue;
}
statement1;
}


In this example, will
 continue 
skip statement1 if condition2 is met?
>>
>>59802728
C doesn't have continuations!

>>59802748
Yeah, C/C++ still has them though, and assembly does obviously.
>>
>>59802796
Have you tried solving D my man?
>>
>>59802814
You are not allowed to switch on a pointer type
>>
File: red.png (28KB, 1125x270px) Image search: [Google]
red.png
28KB, 1125x270px
>5 shades of red
why is this allowed?
>>
>>59802808
Just found that one.
Currently scratching my fucking head desu.
>>
>>59802846
I think you might be colorblind friend.
>>
>>59802814
>"schemes"
non executable stack, canaries, randomizing addresses etc.

rust should be safe from that right?
>>
>>59802808
>>59802796
correction
change
        if ((check = (_len = S.length) - K * 2) < 0

to
        if (~S.indexOf("+") &&
(check = (_len = S.length) - K * 2) < 0

silly mysteak

>>59802832
I just came online bruh
>>
>>59802825
Stupid code, but yes.
>>
>>59802846
What are you talking about?
>>
>>59802796
What the hell is this
>>
why do they say php is so easy to just shit out code?
>>
>>59802866
CPU5-8 are the same shade and CPU2 is a different shade of red.
>>
>>59802875
I've never heard anybody say that, but nothing about PHP is overly complicated and it's well documented and tested.
>>
>>59802889
That's not what i'm seeing
>>
>>59802889
>CPU5-8 are the same shade
you're either trolling or legit colorblind
>>
>>59802907
>on cocaine
>>
>>59802870
JS
C:\ayylmao>type input.txt
4
---+-++- 3
+++++ 4
---------- 10
++-++ 3
C:\ayylmao>node google.js input.txt
Case #1: 3
Case #2: 0
Case #3: 1
Case #4: IMPOSSIBLE
>>
>>59802894
https://youtu.be/_jKylhJtPmI?t=93

>inb4 computerphile
>>
File: object.png (465KB, 1920x1080px) Image search: [Google]
object.png
465KB, 1920x1080px
Found this on
https://en.wikipedia.org/wiki/Mutator_method
>>
File: cpu.png (28KB, 1125x270px) Image search: [Google]
cpu.png
28KB, 1125x270px
>>59802846
Is it not configurable? What happens if you click the rectangles?

Really it should just default to alternating between two colors - green and black maybe.

In fact there is only one shade of red.
>>
>>59802913
you're either trolling or legit colorblind
>>
>>59802092
Good job anon, now create asm
>>
>>59802974
Doing that shit on code you "control" (i.e. internal to program) is just pointless and requires a bunch of useless boilerplate for absolutely no benefit. Just access the variable directly.
I can think of legitimate reasons for a library to do that, though.
>>
>>59802747
So how does backspace work? And does it support curses?
>>
>>59802845
That's stupid, could you at least cast it to an integer? Seems it might be useful if you have a single mutable pointer that can be assigned over time to point to different objects.

>>59802856
Look at the bottom row. All 4 are red, CPU2 on the top row is as well, though I suppose some might argue that it's purple or maroon.

>>59802859
Rust can probably provide a canary, though I'm not 100% sure that it does, but wouldn't NX bit and ASLR have to be provided by the operating system?
>>
>>59803084
>could you at least cast it to an integer
You shouldn't do that and it's most likely would result in UB.

Switch can only be used with constant values to begin with so it makes no sense for pointers. Really it just promotes inproper usage of it like someone trying to do it for strings when in reality you should be doing a streq on each one.
>>
So I wrote this:

https://sstewartgallus.com/git?p=uevents-rs.git;a=tree

Can I get some code review? It's basically the same algorithm as an MCS Queue Lock but edited to work for an event semaphore instead.
>>
File: cpu.png (27KB, 1125x327px) Image search: [Google]
cpu.png
27KB, 1125x327px
>>59802907
>>59802913
Look at pic related. I literally just saved the image from >>59802846 into paint and did a bucket fill on the top area (around the 60% mark) with light blue. Anon is therefore wrong in saying "5 shades of red", at least one shade of whatever color that is is repeated for four CPUs. And note that paint's fill is totally naive, it only matches if the colors (in 24-bit RGB or whatever) match PERFECTLY, none of that "close enough" stuff like photoshop and photostudio have.

>>59802974
>>59803018
Yeah it's main use is when you want to attach additional logic to be called whenever a variable changes (validation, logging, etc).
>>
>>59803127
Well shit maybe I'm colorblind because that's not red for me.
>>
File: helpmewithhomeworkplox.jpg (22KB, 797x125px) Image search: [Google]
helpmewithhomeworkplox.jpg
22KB, 797x125px
I know this isn't really programming but I bet someone here can help me quickly and I don't want to ask my professor and this isn't in my notes for this class or in the book.

What are the a sub k-1 and whatnot supposed to be? How do I know what k is? I figure n is 20 but what is the rest of this stupid shit?
>>
>>59803153
Just specifying I am only confused about what the a's are.
>>
>>59803135
610 is the 14th number
>>
>>59803142
Even if you were, they would still be all one shade.
>>
>>59803196
yeah but it's not red for me is the issue here.
>>
>>59803153
I will help you only if you'll tell your professor that you got help from 4chan.org/g/dpt
>>
>>59803181
What code do i have to add to stop it at the 12th number
>>
>>59803226
Ok.
>>
>>59803204
This is a recolor to blue >>59803127
This is the original red >>59802846

If you don't agree with that you either are confused with what we're taking about or really color blind.
>>
>>59803235
im distracted by try subtracting 2 from num in your if statement

post results
>>
>>59803243
I see the blue one, but the 'red' one looks like yellowish for me
>>
>>59803135
>What needs fixing here?
Your non-use of code tags.

>>59803142
What color does it look like? I'm pretty sure I'm a bit colorblind (though it's usually just that I confuse yellow/green and blue/purple), but the computer says all four are the same color, and even a colorblind person would be expected to see all as the same color.

>>59803153
I'm not familiar with the algorithm, but apparently it's iterative (you repeat it X times, or until some condition is met) and the k is basically index of an array holding one value for each iteration.
>>
>>59803280
>I'm not familiar with the algorithm, but apparently it's iterative (you repeat it X times, or until some condition is met) and the k is basically index of an array holding one value for each iteration.


You have to know what k is before you start, this is the entire thing. I just have no clue how to follow this.

proc
mod exponent(
b
∈
Z, n
= (
a
k
−
1
a
k
−
2
···
a
1
a
0
)
2
, m
∈
Z
+
)
x
:= 1
power :=
b
mod
m
for
i
= 0 :
k
−
1
if
a
i
= 1
then
x
:= (
x
·
power)
mod
m
power := (power
·
power)
mod
m
endfor
return
(
x
)
//
x
=
b
n
mod
m
>>
>>59803278
You might be green or red color blind
>>
File: help2.jpg (49KB, 855x518px) Image search: [Google]
help2.jpg
49KB, 855x518px
>>59803323
fucking pdfs
>>
>>59803153
#include <iostream>

using namespace std;

void modPow(int base, int expo, int mod) {
if (mod == 1) {
return;
}
int c = 1;
for (int i = 0; i <= expo; ++i) {
cout << c << endl;
c = (c * base) % mod;
}
}

int main() {
modPow(11, 20, 50);
}
>>
>>59803352
I guess that is the same algo but what are the a values supposed to represent in my version?
>>
>>59803338
Did you really just try to copy and paste from a pdf into code tags expecting it to work
>>
Started on a text based adventure game. Doing it in Python since that's what my cs course decided to teach us this year.

Haven't done too much yet though, just putting together classes. Trying to think how I want to structure the text input. I figure a simple 'verb preposition noun' would be too easy, so I want to try putting together something that understands more complicated input.

Any ideas?
>>
>>59803387
I consciously thought this will likely fuck up but posting is free and effortless
>>
>>59803397
>Python
Get on my level.
https://hastebin.com/lugijufopu.hs
>>
>>59803278
Post test results, my dude.
>>
File: asnwer.jpg (12KB, 383x203px) Image search: [Google]
asnwer.jpg
12KB, 383x203px
>>59803338
The answer isn't helping me much either.
>>
gay stuff

https://github.com/kirkins/Evil-Chrome-Extension

https://github.com/rickyhan/macintoshplus
>>
>>59803397
Another fun thing to consider in text-based adventures is scenes where typing speed matters; you have to type a basic action really fast...otherwise you die.

Usually things like setting off a trap, etc. You can make it go easy on the player by making it really obvious what's coming up...eg. they know that navigating to the next screen will have an enemy on it now, and a trap that's ready to be set off (usually this is a room they would be re-visiting...forcing a typing speed puzzle on unknown territory is pretty unforgiving).
>>
File: paradigms-chart.png (89KB, 968x724px) Image search: [Google]
paradigms-chart.png
89KB, 968x724px
>>
Let's say you were using a programming language where hash tables could only be used on datasets of a certain (smallish) size. Say 30,000.

You had to compare values in two absolutely huge datasets, with millions of rows.

Are hash tables so much faster that it would be faster overall to iteratively convert subsets of each table to hash tables?
>>
>>59803574
What are you trying to do?
>>
File: images.duckduckgo.com.jpg (81KB, 1000x833px) Image search: [Google]
images.duckduckgo.com.jpg
81KB, 1000x833px
https://github.com/kirkins/HWNDU-4CHAN
>>
>>59803574
Why not just store a hashset of hashsets?
>>
For every number from 1 to 2million:

- If it is a factor of 3, print Fizz
- If it is a factor of 5, print Buzz
- If it is a factor of 3 and 5, print FizzBuzz
- If it is a prime, add it to a prime sum variable
Finally print out the prime sum

Do your best
>>
>>59803616
Where does it ever end tho? Hashsets of Hashsets of Hashsets...
>>
>>59803613
Nothing wrong with being gay, faggot.
>>
File: 2017_04_08_06_17_pm.png (246KB, 1920x1080px) Image search: [Google]
2017_04_08_06_17_pm.png
246KB, 1920x1080px
>>
>>59803637
What DE?
>>
>>59803278
Either you're colorblind, or most other people here are.
>>
>>59803226
I guess ill just tell him that 4chan doesn't know shit about anything.
>>
>>59803647

ZineOS
>>
>>59803535
>forcing a typing speed puzzle on unknown territory is pretty unforgiving
Unforgiving has traditionally been par for the course in text adventures though, to the point that some had "this game can be won without reading the spoilers first" as a selling point.
>>
/g/ can't even implement a monoid in the category of endofunctors in C
>>
>>59803658
>>59803338
literally the algorithm, what else do you need?

>>59803381
bits
>>
>>59803637
my fucking eyes how can you stand that?
>>
>>59803724
>bits
so convert 20 to binary?
>>
Desktop applications or web applications?

JavaScript is retarded but it just werks on all your devices and operating systems instantly.
I hate this decision that comes up again and again.
>>
>>59803625
O-on a whiteboard?
>>
Are the lisps a meme?
>>
>>59803724
WHY DIDN'T SOMEONE JUST FUCKING SAY CONVERT THE EXPONENT INTO BINARY DKLAFJl;jkdsfgh[';kljfhsadg';kldsafh;lewsadkfh
>>
>>59803455
>freetard
>stallman
>neckbear

What the fuck is this?
>>
>>59803592

It boils down to testing if rows of data in two datasets represent data from the same user
>>
qual round google jam analysis is out faam

https://code.google.com/codejam/contest/3264486/dashboard#s=a
>>
File: 1464998874180.jpg (72KB, 720x690px) Image search: [Google]
1464998874180.jpg
72KB, 720x690px
>want to code X
>start coding X in Java
>decide to do it in C++ instead to learn a bit about C++
>begin to hate C++ and go to C instead since I know it already
>within days the project becomes a bore of writing helper stuff and data structures that other languages provide by default
>fuck it maybe I'll try to learn Rust and do ti in that while learning
>immediately turned off by all the different shit it has and inconsistencies
>back to considering just doing it in Java again


I lost nearly 2 weeks by playing the shuffle game.
>>
>>59803838
But anon, implementing your own data structures is fun!
>>
>>59803838
This is why Wayland needs to grow and X11 needs to die.
>>
whats a good cs salary in a city
>>
how the fuck do I program buttons to do things in html. Is this why javascript and php exist?
>>
>>59803637

ZineOS is Love

ZineOS is Life
>>
>>59803873
yes
>>
>>59803873

button.onclick = function() { doThings(); }
>>
>>59803873
Yes. html is not a programming language. php is used for giving stuff to the server, js is usually for client side stuff (ie: wasting cycles, eating up your user's memory and ultimately slowing down their browser)
>>
>>59803018
I should of said, this would be a class library that emulates C++ functionality. Would there be a way to make this a template, or an object-layer for C?
>>
>>59803665
link?

>>59803695
Haskeks can't even explain what a monoid or an endofunctor is.

>>59803777
Looks like someone forgot their null terminator.

>>59803778
Is this your first experience with dank memes?

>>59803838
Just use Python lol.
>>
>>59803838
Just tough it out and use C. Stuff like data structures is something you write once and reuse forever so it'll help on future projects.

or you can just scan the web for people who already did that and use theirs.
>>
>>59803777
bruh

it literally says n = (sfsdfsdfsdfs)_2
>>
starting to like programming thanks to my is&t courses. How do I learn about fun libraries and neat stuff like that?
>>
File: jfjdfjfdjsdfjksdfjk.png (10KB, 924x549px) Image search: [Google]
jfjdfjfdjsdfjksdfjk.png
10KB, 924x549px
Is this state diagram for identifying literals ok? Somehow I feel like it can be reduced but I'm tired and my brain doesn't work
>>
>>59803838
Jesus Christ, C# !
>>
>>59803947
My question was
>What are the a sub k-1 and whatnot supposed to be? How do I know what k is? I figure n is 20 but what is the rest of this stupid shit?

So obviously I didn't know that is what the tiny smaller subscript meant.
So why do you want to make me feel stupid for not knowing that the answer to my question was the answer to my question?
>>
Rust is the future of system programming. Tor is already on board and being rewritten in Rust to avoid the memory dangers of its original C codebase. It won't be long before Linus rewrites the Linux kernel in Rust to seal the fate of C.
>>
>>59803990
dont people learn bases in middle school?
>>
>>59803956
Is "a" not supported?
>>
>>59803956
seems like you could remove q1, otherwise it doesn't accept the empty string
>>
>>59804004
>>59804006
o shit you guys are right, thanks
>>
why is java so shit, I can't even call super.equals() without it giving me null pointer
>>
File: 1410726671692.png (559KB, 1920x1200px) Image search: [Google]
1410726671692.png
559KB, 1920x1200px
Anyone have tips for building a multi date selection calendar/date picker?

Such pain...
>>
File: cute anime pic 0100.png (655KB, 740x720px) Image search: [Google]
cute anime pic 0100.png
655KB, 740x720px
>>59803991
>It won't be long before Linus rewrites the Linux kernel in Rust to seal the fate of C.
>>
>>59804003
Never in my life have I ever written out bases in that syntax.
>>
>>59804037
also I've definitely never seen a programming language handle bits in that syntax
>>
File: DoubleMeme.png (14KB, 1024x768px) Image search: [Google]
DoubleMeme.png
14KB, 1024x768px
>>59803625
This would theoretically work if the current CTFE wasn't poop
>>
>>59804033
Just let the users enter UTC time in seconds since Epoch (1970-01-01)
>>
>>59804066
what the fuck is that
>>
I've improved my integer concatenation program.
Any suggestions?

/**
* SUMMARY: intcat concatenates a series of integers and prints the result.
* NOTICE.: Any negative integers passed will be made unsigned.
* NOTICE.: All decimals points, if existent, will be cut off.
* NOTICE.: Cannot concatentate any zeroes at the moment.
* ........ Will add an option, -z, that will let the user concatenate zeroes
* ........ at the expense of not checking if the input is indeed an integer.
* NOTICE.: Error checking is shit right now. Pls no bully.
*/

#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

// Returns the number of digits in a
int intlen(long a) {
return (int)(floor(log10(a))) + 1;
}

int main(int argc, char *argv[]) {
if (argc < 3) {
puts("Too few arguments");
puts("Usage: intcat <long integer> <long integer>...");
return EXIT_FAILURE;
}

const unsigned Num_Ints = argc - 1;
long lints[Num_Ints];

// Converts the string args to longs
for (int i = 0; i < Num_Ints; i++) {
if ((lints[i] = strtol(argv[i + 1], NULL, 10)) == 0L || \
lints[i] == LONG_MIN || lints[i] == LONG_MAX) {
printf("The argument \"%s\" is out of range or not an integer\n", \
argv[i + 1]);
return EXIT_FAILURE;
}
}

long catint = labs(lints[0]); // Stores the result of the concatentation

// Concatenate
for (int i = 1; i < Num_Ints; i++) {
long b = labs(lints[i]), s = (long)(pow(10, intlen(b)));

// Check if the resulting concatentation will be too big
if (s > (LONG_MAX - b) / catint) {
puts("Concatentation is too large");
return EXIT_FAILURE;
}

catint = catint * s + b; // $500,000 starting salary
}

printf("%ld\n", catint);

return EXIT_SUCCESS;
}

/* Cirno a cute! CUTE!*/



https://pastebin.com/JH3PfL9q
>>
>>59804044
its not a real program
>>
>>59804071
> in seconds

I think users are more used to milliseconds, I'll stick with that. Thanks
>>
>>59804075
D inside of emacs inside of a Gentoo install with no X
>>
>>59804079
and your point is?
>>
>>59804036
Yes they're going to rewrite all 15 million lines of code in a meme.
>>
>>59804115
I was more laughing at the idea of Linus letting any language other than C or asm touch the Linux codebase
>>
>>59803991
>Linus
>rewrite kernel
tough luck, linus hates anything that isn't C
>>
>>59804121
>>59804120
Linus doesn't even code anymore. He mediates merges.
>>
>wake up
>there is an OS written in rust
Jesus, Mary and Joseph
>>
Help me out here; what needs to be adjusted? Attached are the output I'm getting vs. the output I'm supposed to get.

#include <iostream>
#include <string>
#include <iomanip>
#include <math.h>
using namespace std;
int fibonacci(int num)
{
int sum = 1;
int firstNum = 0;
int secondNum = 1;
int fib=0;
int fibnum = 0;

for (int i = 1; i <= num; i++)
{
if (i==1) {
cout << firstNum << " ";
}
if (i==1) {
cout << secondNum << " ";
}
fibnum = firstNum + secondNum;
sum = sum + fibnum;
firstNum = secondNum;
secondNum = fibnum;
cout << fibnum;
if (i < num) {
cout << " ";
}
}
return sum;
}
int main()
{
int num, total;
// ask for number
cout << "Please enter a number between 5 and 22: ";
cin >> num;
cout << num << endl;
if ((num < 5) || (num > 22))
cout << "Please follow the directions!" << endl;
else {
total = fibonacci(num);
cout << endl;
cout << "Fibonacci # " << num << " is " << total << endl;
}
return 0;
}
>>
>>59804132
So
>Hey Linus, I rewrote this part of the kernel in Rust, check it out
>1 hour later we all have a new Linus rant to enjoy
>>
>>59803934

> 59803665
> link?

https://whimsy.space
>>
Why there's no BASIC-based scripting language?
>>
>>59804199
I'd love for this to happen
>>
>>59801883

>Making buttons do things in Web Pages

I think I needed pic related. I wonder how similar Javascript is to C++. :S
>>
>>59804179
it feels like you are returning sum of first n fib numbers
you are supposed to just return fib(n), aren't you
>>
Will defining a function as static prevent me from getting an error of using the same name in another function in another linked file?
>>
File: englishgayman.jpg (16KB, 300x300px) Image search: [Google]
englishgayman.jpg
16KB, 300x300px
Where is our discord
>>
>>59804282
https://discord.gg/5vmSzKU
>>
>>59804281
You do realize you could just try this out in less than a minute instead of asking here, right?
>>
>>59804105
the point is to learn the process
>>
>>59804298
You're right. It didn't. Is there a way to deal with functions and gobal variables of the same name in linked files? Or do you just have to rename them?
>>
how would i rewrite this for loop without && or ||?
for(i=0; i<lim-1 && (c=getchar()) != '\n' && c!=EOF; ++i) s[i] = c;
>>
>>59804303
of knowing what the tiny 2 subscript means?
>>
>>59804148
>wake up
>there is an OS written in Common Lisp
>>
>>59804148
Why not?
>>
>>59804318
Wat? Please try it again
>>
>>59804335
write it in multiple lines like a normal person
for(i=0; i<lim-1; i++) {
c = getchar();
if(c == '\n')
break;
if(c == EOF)
break;
s[i] = c;
}
>>
>>59804335
You can use & instead of &&
:^)
for(i=0; i<lim-1 & (c=getchar()) != '\n' & c!=EOF; ++i) s[i] = c;


That code is not portable to Linux or UNIX by the way. UNIX terminals buffer the input until \n is encountered.
>>
>>59804179
int fibonacci(int num)
{
int sum = 1;

for (int i = 1, firstNum = 0, secondNum = 1, fib = firstNum + secondNum; i < num; i++, fib = firstNum + secondNum, firstNum = secondNum, secondNum = fib)
{
if (i == 1) {
cout << firstNum << " ";
}
cout << secondNum << " ";
sum += firstNum;
}
return sum;
}
>>
>>59804148
Cool anon. Please go use it so we don't have to see you again.
>you're gonna have so many issues you can't waste time browsing dpt
>>
>>59804318
How do you expect the compiler to know what you're referring to if they have the same prototype and same scope?
>>
>>59804441
Windows does that too though. I'm not aware of any widespread PC operating system that uses unbuffered input by default.
>>
>>59804539
I've actually tried it in a VM and it seems decent for something this early in its development. Even seems more stable than ReactOS (though it's Unix-like, so probably easier to implement than a Windows NT clone).
>>
>>59804179
Here's another one

#include <iostream>
#include <string>
using namespace std;

string play(string p1, string p2) {
string result = " ";
if (p1 == "rock") {
if (p2 == "rock") {
result = "Draw!";
}
if (p2 == "scissors") {
cout << "rock breaks scissors" << endl;
result = "Player 1 wins!";
}
if (p2 == "paper") {
cout << "Paper covers rock" << endl;
result = "Player 2 wins!";
}
}

if (p1 == "scissors") {
if (p2 == "scissors") {
result = "Draw!";
}
if (p2=="paper") {
cout << "Scissors cuts paper" << endl;
result = "Player 1 wins!";
}
if (p2 == "rock") {
cout << "Rock breaks scissors" << endl;
result = "Player 2 wins!";
}
}

if (p1 == "paper") {
if (p2 == "paper") {
result = "Draw!";
}
if (p2 == "rock") {
cout << "Paper covers rock" << endl;
result = "Player 1 wins!";
}
if (p2 == "scissors") {
cout << "Scissors cuts paper" << endl;
result = "Player 2 wins!";
}
}

return result;
}

int main() {
string p1, p2;
cout << "Play rock, paper, scissors\n";
string goOn = "yes";
while (goOn == "yes") {
cout << "Player 1: ";
cin >> p1;
cout << p1 << endl;
cout << "Player 2: ";
cin >> p2;
cout << p2 << endl;
cout << play(p1, p2) << endl;
cout << "Do you want to continue? (yes or no): ";
cin >> goOn;
cout << goOn << endl;
}

return 0;
}


What am I dong wrong here? Someone give me a solution, I need to get this in soon.
>>
>>59804282
>>59804287
If you're going to indulge in faggotry at least use mumble or IRC.
>>
>>59804538
Thanks am
>>
>>59804350
of knowing how the algorithm works
>>
>>59804652
So the third test failed?
>>
>>59804404
oh, thought it wanted some cool trick i didnt know
>>
>>59804749
Yes
>>
>>59804689
the only part in the way of that was knowing to convert it into binary
>>
>>59804764
Give me the instructions for this problem.
>>
>>59804775
Play the rock paper scissors game. Two players enter either rock, paper, or scissors and the winner is determined as follows:

paper covers rock
rock breaks scissors
scissors cut paper.
Ask the user if s/he wants to play again. BE SURE to include a function called play as shown in the template.

Sample run:

Play rock, paper, scissors
Player 1: rock
Player 2: paper
Player 2 wins -- Paper covers rock

Do you want to continue? (yes or no): yes
Player 1: scissors
Player 2: rock
Player 2 wins -- Rock breaks scissors

Do you want to continue? (yes or no): no
>>
>>59804779
(cont)
NOTE: You must include a function called play which plays the game and returns
>>
>tfw meme degree freshman
>tfw one of my classmates has done loads of cool projects and knows loads of programming trivia
>tfw I can't do shit
Wat do?

Pic unrelated.
>>
>>59804801
>>
>>59804806
(new)
>>
String s = "/r <someWord> text"
how do i get someWord into its own string and remove it from s?
>>
>>59804793
>>59804779
Show me the template.
>>
Today i found out that DotNetCore 1.1.1 doesn't work with VS2015.


ahhhhhhhhhhhh!!!!!!!!!!
>>
>>59804779
>>59804793
#include <iostream>
#include <string>

using namespace std;

string play(string p1, string p2) {
string result = " ";

if (p1 == "rock") {
if (p2 == "rock") {
result = "Draw!";
}
if (p2 == "scissors") {
result = "Player 1 wins -- Rock breaks scissors";
}
if (p2 == "paper") {
result = "Player 2 wins -- Paper covers rock";
}
}

if (p1 == "scissors") {
if (p2 == "scissors") {
result = "Draw!";
}
if (p2=="paper") {
result = "Player 1 wins! -- Scissors cuts paper";
}
if (p2 == "rock") {
result = "Player 2 wins -- Rock breaks scissors";
}
}

if (p1 == "paper") {
if (p2 == "paper") {
result = "Draw!";
}
if (p2 == "rock") {
result = "Player 1 wins -- Paper covers rock";
}
if (p2 == "scissors") {
result = "Player 2 wins -- Scissors cuts paper";
}
}

return result;
}

int main() {
string p1, p2;

cout << "Play rock, paper, scissors\n";

string goOn = "yes";

while (goOn == "yes") {
cout << "Player 1: ";
cin >> p1;

cout << "Player 2: ";
cin >> p2;

cout << play(p1, p2) << "\n";

cout << "Do you want to continue? (yes or no): ";
cin >> goOn;

cout << goOn << "\n";
}

return 0;
}
>>
>>59804377
There is
>>
new thread pls
>>
>>59805288
>>59804801
Thread posts: 340
Thread images: 35


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

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


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