Two Plus Two Publishing LLC
Two Plus Two Publishing LLC
 

Go Back   Two Plus Two Poker Forums > >

Notices

Programming Discussions about computer programming

Reply
 
Thread Tools Display Modes
Old 10-17-2015, 10:43 PM   #701
Roonil Wazlib
veteran
 
Roonil Wazlib's Avatar
 
Join Date: Feb 2014
Location: ᕕ( ᐛ )ᕗ
Posts: 3,333
Re: Programming homework and newbie help thread

I'm hoping that's what intern-level interview questions are like, seeing as how entry level position questions in these parts amount to 'make a person class, make a calendar/planner class'
Roonil Wazlib is offline   Reply With Quote
Old 10-19-2015, 08:02 PM   #702
skario
enthusiast
 
Join Date: Jan 2007
Posts: 84
Re: Programming homework and newbie help thread

CyberShark passes.

Others go make a datagrid.
skario is offline   Reply With Quote
Old 10-23-2015, 06:23 PM   #703
Roonil Wazlib
veteran
 
Roonil Wazlib's Avatar
 
Join Date: Feb 2014
Location: ᕕ( ᐛ )ᕗ
Posts: 3,333
Re: Programming homework and newbie help thread

general data structures real use question:

as we're learning about various abstract data types, it seems like most of them are best suited to things such as, say, operating system operations or perhaps situations that mimic real life, like a queue to buy concert tickets online or log on to a full server.

Are there other real world applications for some of these (real world in this case meaning the business world) that I'm not thinking of?
Roonil Wazlib is offline   Reply With Quote
Old 10-23-2015, 10:51 PM   #704
Wolfram
Carpal \'Tunnel
 
Wolfram's Avatar
 
Join Date: Jan 2006
Location: You can be my wingman any time
Posts: 14,733
Re: Programming homework and newbie help thread

could you vague that up a bit?
Wolfram is offline   Reply With Quote
Old 10-24-2015, 04:32 AM   #705
adios
Carpal \'Tunnel
 
Join Date: Sep 2002
Location: Russian Troll
Posts: 21,389
Re: Programming homework and newbie help thread

Quote:
Originally Posted by Roonil Wazlib View Post
general data structures real use question:

as we're learning about various abstract data types, it seems like most of them are best suited to things such as, say, operating system operations or perhaps situations that mimic real life, like a queue to buy concert tickets online or log on to a full server.

Are there other real world applications for some of these (real world in this case meaning the business world) that I'm not thinking of?
Using a queue as an example, the first in/first out (FIFO) nature of this data structure lends itself to using it in satisfying various programming requirements that arise. Basically it provides an organized and consistent way that one programming entity be it an object, thread, function, middleware layer, OS layer, etc. to communicate with another programming entity. I guess the take away for you would be that you will encounter programming requirements where particular data structures will be necessary and helpful in fulfilling. Think in the abstract with these is my advice.
adios is offline   Reply With Quote
Old 10-25-2015, 08:47 AM   #706
Roonil Wazlib
veteran
 
Roonil Wazlib's Avatar
 
Join Date: Feb 2014
Location: ᕕ( ᐛ )ᕗ
Posts: 3,333
Re: Programming homework and newbie help thread

Quote:
Originally Posted by Wolfram View Post
could you vague that up a bit?
Well I am talking about abstract data types

Quote:
Originally Posted by adios View Post
Using a queue as an example, the first in/first out (FIFO) nature of this data structure lends itself to using it in satisfying various programming requirements that arise. Basically it provides an organized and consistent way that one programming entity be it an object, thread, function, middleware layer, OS layer, etc. to communicate with another programming entity. I guess the take away for you would be that you will encounter programming requirements where particular data structures will be necessary and helpful in fulfilling. Think in the abstract with these is my advice.
Is it usually pretty obvious then what the preferred solution should be?

Like if I'm writing software that handles ticket requests for a concert company, I clearly want the first order to be the first one processed, not the last one.
Roonil Wazlib is offline   Reply With Quote
Old 10-25-2015, 10:03 AM   #707
catsec
centurion
 
catsec's Avatar
 
Join Date: Apr 2014
Location: hunting shells
Posts: 179
Re: Programming homework and newbie help thread

Roonil Wazlib,

I haven't started studying data structures and algorithms in depth yet, but I studied them a little bit in an Operating Systems class in the context of process scheduling in multi-programming environments where ideally a process is running at all times. Algorithms covered included first come first serve, shortest job first, and round robin. In this context, they each had pros on cons, so I think it's essentially a case by case basis, and in many cases you may have multiple candidates for algorithms and data structures to use.

I haven't gotten deep into the programming and computer science aspects of my studies at uni yet though, being still primarily in the networking fields, so I don't know a lot about data structures and algorithms.
catsec is offline   Reply With Quote
Old 10-26-2015, 12:50 AM   #708
ChrisV
Carpal \'Tunnel
 
ChrisV's Avatar
 
Join Date: Jul 2004
Location: Adelaide, Australia
Posts: 40,134
Re: Programming homework and newbie help thread

What's important isn't specific data structures but rather thinking about how to model things in a computer sciencey way. "How should I implement some sort of FIFO queue of objects" is a solved problem. If I want to use one in C# and don't know what it is, 5 seconds of Googling "C# FIFO queue" will reveal System.Collections.Queue. It's then just an abstraction to me and I don't particularly care how it works. This doesn't mean that learning about data structures is a waste of time however - being familiar with them enables you to break complicated systems down into component parts.

In the example of a ticketing system, that isn't at heart a complicated system and it closely models an actual real-world queue. For something slightly more complex, suppose you have a web app where people can choose video elements and your app renders them into a video with subtitles (something like xtranormal). Suppose the video rendering turns out to be computationally expensive. A naive step 1, step 2, step 3 way of doing things could result in a bottleneck where people wait for their video to render. In order to reduce bottlenecking, you might implement a FIFO queue with a callback and, while that is processing, get the user to write in their subtitles for each sequence. That's a situation where the need for a queue might not be so obvious on first glance. So while you're right that the answer to "I need some sort of queue structure, I should use a queue" it's rarely so clear that an app should be structured a certain way as it is in the example of ticketing. The heavy lifting is figuring out the structure.
ChrisV is offline   Reply With Quote
Old 10-26-2015, 11:36 AM   #709
Roonil Wazlib
veteran
 
Roonil Wazlib's Avatar
 
Join Date: Feb 2014
Location: ᕕ( ᐛ )ᕗ
Posts: 3,333
Re: Programming homework and newbie help thread

Quote:
This doesn't mean that learning about data structures is a waste of time however
please don't think this is what I'm trying to say. I think it's a very interesting topic, I'm just trying to convey that I'm not 100% clear on what the real world uses are, aside from various OS functions which I'll probably never work on.

I suppose you all get tired of hearing it from me, but thanks as usual for all the great responses.
Roonil Wazlib is offline   Reply With Quote
Old 10-26-2015, 02:06 PM   #710
Alobar
Born Ready
 
Alobar's Avatar
 
Join Date: Nov 2003
Location: 3rd turtle from the bottom
Posts: 41,296
Re: Programming homework and newbie help thread

learning them and making them besides teaching you what they are, also helps you learn how to program stuff. So while you may never implement your own queue in the real world, you probably will need to understand polymorphism and linked lists and interfaces and all the stuff you need to know in order to make those data structures and you will I assume use that stuff frequently for all kinds of things.
Alobar is offline   Reply With Quote
Old 10-26-2015, 08:20 PM   #711
adios
Carpal \'Tunnel
 
Join Date: Sep 2002
Location: Russian Troll
Posts: 21,389
Re: Programming homework and newbie help thread

Quote:
Originally Posted by Roonil Wazlib View Post
Well I am talking about abstract data types



Is it usually pretty obvious then what the preferred solution should be?

Like if I'm writing software that handles ticket requests for a concert company, I clearly want the first order to be the first one processed, not the last one.
Chris gave a good answer, can't add much to that. They come in handy in multi-threaded implementations.

This is from a clowntable post that might need a worker thread implementing a queue:
Quote:
I'm also losing the occasional tweet because write to disk can't keep up with the incoming stream. Didn't have the issue when writing to the internal SSD, the USB drive might be a tad too slow. It's something I might investigate (pretty sure I could squeeze out some extra trickery) but for now dropping a couple of tweets per day is fine with me.
Have a separate worker thread to manage a queue that actually does the system calls to write the data to disk, USB drive, whatever. Yeah the queue can back up but there is almost certainly enough idle time that when nothing else is happening the worker thread can empty the queue. I am just guessing at whether or not this is feasible with clowntable's program but this is a classic way queues are used. Of course you'll have to make adding entries to the queue thread safe but that isn't too hard.

Last edited by adios; 10-26-2015 at 08:35 PM.
adios is offline   Reply With Quote
Old 10-26-2015, 11:47 PM   #712
daveT
S.A.G.E. Master
 
daveT's Avatar
 
Join Date: Jun 2005
Location: La La Land
Posts: 23,134
Re: Programming homework and newbie help thread

About the only thing I remember from SICP is that computers are just layers of abstractions. At the base-level, you have a bunch of wires that take input and give output, you can call these queues.

At the higher level, you wrap this is a black box and call it Q, call it when you need to then to.

You can then combine these Qs together and you end up with a map.

You then combines these maps into M.

Take these Ms and you can then create an object.

Take these objects and combine them together, and you have a system of objects.

Take these objects, combine them, and call them O.

take these Os and...
daveT is offline   Reply With Quote
Old 10-27-2015, 05:41 AM   #713
adios
Carpal \'Tunnel
 
Join Date: Sep 2002
Location: Russian Troll
Posts: 21,389
Re: Programming homework and newbie help thread

Quote:
Originally Posted by daveT View Post
About the only thing I remember from SICP is that computers are just layers of abstractions. At the base-level, you have a bunch of wirestransistors that take input and give output, you can call these queuescircuits.
Quote:
At the higher level, you wrap this is a black box and call it Qa sequential machine, calluse it when you need to then to.
Quote:
You can then combine these Qs together use this as an abstraction to define a system and you end up with a map flexible tool that you can create among other things a map.

You then combines these maps into M.

Take these Ms and you can then create an object.

Take these objects and combine them together, and you have a system of objects.

Take these objects, combine them, and call them O.

take these Os and...

...
adios is offline   Reply With Quote
Old 10-27-2015, 10:04 AM   #714
daveT
S.A.G.E. Master
 
daveT's Avatar
 
Join Date: Jun 2005
Location: La La Land
Posts: 23,134
Re: Programming homework and newbie help thread

He did say "abstract."

But yes, pay attention to the edits.
daveT is offline   Reply With Quote
Old 10-27-2015, 02:58 PM   #715
econophile
Carpal \'Tunnel
 
econophile's Avatar
 
Join Date: Jul 2005
Location: (X'X)^(-1)X'Y
Posts: 11,318
Re: Programming homework and newbie help thread

Speaking of abstract vs. concrete, I strongly recommend Code: The Hidden Language of Computer Hardware and Software by Charles Petzold.

It starts off simple with switches and explains how switches can be combined into relays (essentially mechanical versions of transitors); how relays can be combined into logic gates (AND, OR, XOR, etc.); how logic gates can be combined into circuits that can add, subtract, multiply and divide (ALUs) and circuits that store information (RAM); and how these components can be combined into a simple computer with switches for inputs and light bulbs for outputs. Along the way, he also touches on Morse code, Braille, barcodes, machine language, 86x assembly language, high level languages, ASCII, simple operating systems, and computer graphics, all within 400 pages.

It's simply one of the best books on any subject that I have read in a while. And for me it was really helpful to start from the bottom and build up each layer of complexity. Modern computers so often just seem to work like magic, so it can be a little mind-blowing to see how everything they do results from incredibly simple operations being performed over and over again according to specific patterns and at incredible speeds.

This may have been easier to grasp with older computers when you typed a command and then had time to think about what was going on inside the computer while it calculated the output. I remember my dad showing me how to write a simple BASIC program on his monochrome luggable IBM-compatible in the mid 80s. Those machines seem much simpler than the ones we use today, although they are still exceedingly complicated.

At any rate, gaining some understanding of how the complex behavior of computers emerges from layer upon layer of simple rules and instructions makes it easier to think about how the same thing can happen with neurons. (I also think it was helpful to read this book before trying to learn C.)
econophile is offline   Reply With Quote
Old 10-27-2015, 07:50 PM   #716
Roonil Wazlib
veteran
 
Roonil Wazlib's Avatar
 
Join Date: Feb 2014
Location: ᕕ( ᐛ )ᕗ
Posts: 3,333
Re: Programming homework and newbie help thread

working with java and oracle sql, use a file to input data to the database and ran into an issue with mismatched date formats.

one is of the format "day-month-year", the other is "month/day/year". (month being 3 letter text in each)

I'm supposed to be looping over this, so whatever I write I assume should be able to handle either. I tried to_date, but that didn't work so well.

I'm getting a sql error of "a non-numeric character was found where a numeric was expected" when I loop over the wonky-formatted one.

I've extracted each field into its own variable, like int for any Numbers and String for any names (using single quote wrappers of course).

Suppose there could be a way to verify in java if a string is in a certain format, but I thought to_date would handle this, which it doesn't.
Roonil Wazlib is offline   Reply With Quote
Old 10-27-2015, 09:04 PM   #717
ChrisV
Carpal \'Tunnel
 
ChrisV's Avatar
 
Join Date: Jul 2004
Location: Adelaide, Australia
Posts: 40,134
Re: Programming homework and newbie help thread

Data integrity should be verified before you try to insert it in a database. Convert the input to a date in Java then insert it. I'm not sure if you're using some API and can insert a date directly. A good portable date format to use if you need to convert it back to a string is yyyy-MM-dd, which works with both US and UK locales and is understood by pretty much everything.
ChrisV is offline   Reply With Quote
Old 10-27-2015, 09:24 PM   #718
Roonil Wazlib
veteran
 
Roonil Wazlib's Avatar
 
Join Date: Feb 2014
Location: ᕕ( ᐛ )ᕗ
Posts: 3,333
Re: Programming homework and newbie help thread

The db I'm putting it into prefers dd-mon-yyyy. I'll have to see if there's a Java date format similar to that. Thanks for the tip!

*edit*

took the lowbrow way out and just yanked out the data I need and rearranged it.

reusable? No way in hell!

Last edited by Roonil Wazlib; 10-27-2015 at 09:51 PM.
Roonil Wazlib is offline   Reply With Quote
Old 10-27-2015, 09:55 PM   #719
daveT
S.A.G.E. Master
 
daveT's Avatar
 
Join Date: Jun 2005
Location: La La Land
Posts: 23,134
Re: Programming homework and newbie help thread

If Oracle, I'm guessing there is a CAST() function you can use that will convert the date for you.

In fact, since I know the magic word, I managed to find this: http://stackoverflow.com/questions/1...n-yy-to-yyyymm

I'm thinking this should work directly in your Java code (please use paramaterized values!), but if not, you'd have to do some other silly trick to get it to work, but I can't imagine how Oracle can't do this. Let me know and I'll give you a few ideas.
daveT is offline   Reply With Quote
Old 10-28-2015, 04:03 PM   #720
Alobar
Born Ready
 
Alobar's Avatar
 
Join Date: Nov 2003
Location: 3rd turtle from the bottom
Posts: 41,296
Re: Programming homework and newbie help thread

Does anyone here know MIPS assembly and the PIC32?

I'm trying to write a program in assembly that gets the time between 2 presses of a button. I have zero ****ing clue how to do this and I've spent the last several hours googling. I'd post on the microchip forums but they are admin approved

I've been reading the reference manuals, but its like gibberish to me. Ive found some stuff about the registers that are associated with I/O (TRIS, PORT, LAT), but I dont understand it. If the button is on pin 4 of my board, does that corespond to TRIS4, PORT4, LAT4? In the spec sheet of the actual board tho it says the pic32 signal is SOSCO/T1CK/CN0/RC14, but wtf is that, I don't find anything about any of that in the pic32 ref manual

How do I go from being able to read those registers and see when a button has been pressed, to getting a time at press? I've seen some **** about ICxBUF but I don't understand it at all.

It's a special project, so its nothing thats covered in our book or lectured on by the teacher. I havent even been able to find a good resource that explains anything, so even if you just know of one that would be a tremendous help.

thanks!!
Alobar is offline   Reply With Quote
Old 10-29-2015, 08:10 AM   #721
adios
Carpal \'Tunnel
 
Join Date: Sep 2002
Location: Russian Troll
Posts: 21,389
Re: Programming homework and newbie help thread

Quote:
Originally Posted by Alobar View Post
Does anyone here know MIPS assembly and the PIC32?

I'm trying to write a program in assembly that gets the time between 2 presses of a button. I have zero ****ing clue how to do this and I've spent the last several hours googling. I'd post on the microchip forums but they are admin approved

I've been reading the reference manuals, but its like gibberish to me. Ive found some stuff about the registers that are associated with I/O (TRIS, PORT, LAT), but I dont understand it. If the button is on pin 4 of my board, does that corespond to TRIS4, PORT4, LAT4? In the spec sheet of the actual board tho it says the pic32 signal is SOSCO/T1CK/CN0/RC14, but wtf is that, I don't find anything about any of that in the pic32 ref manual

How do I go from being able to read those registers and see when a button has been pressed, to getting a time at press? I've seen some **** about ICxBUF but I don't understand it at all.

It's a special project, so its nothing thats covered in our book or lectured on by the teacher. I havent even been able to find a good resource that explains anything, so even if you just know of one that would be a tremendous help.

thanks!!
Depends on clock speeds of the processor for one. Two, if you are running on an OS like Linux or Windows they can affect your timing possibly. Many other things can and will. Pretty sure what you are supposed to is this:

1. Code the detection of the button press and the wait loop.

2. Look in your reference manual at the instructions you use and add up the clock cycles for all the instructions you use.

3. Take the clock speed of the processor and determine the period of one clock cycle and multiply the number of cycles your assembly language code takes to execute. Multiply the number of cycles your program uses by the period of one clock cycle.

It is admittedly kind of a dumb assignment. In the "real world" nobody does precise timing in this manner.
adios is offline   Reply With Quote
Old 10-29-2015, 11:10 AM   #722
Alobar
Born Ready
 
Alobar's Avatar
 
Join Date: Nov 2003
Location: 3rd turtle from the bottom
Posts: 41,296
Re: Programming homework and newbie help thread

Well this is on an microcontroller so there is no OS. I don't need precise timing, if its off by milliseconds I don't care. I just need to be able to read the correct register so that I know a button was pressed, I just can't find what register to read
Alobar is offline   Reply With Quote
Old 10-29-2015, 11:59 AM   #723
adios
Carpal \'Tunnel
 
Join Date: Sep 2002
Location: Russian Troll
Posts: 21,389
Re: Programming homework and newbie help thread

Quote:
Originally Posted by Alobar View Post
Well this is on an microcontroller so there is no OS. I don't need precise timing, if its off by milliseconds I don't care. I just need to be able to read the correct register so that I know a button was pressed, I just can't find what register to read
Well how is the button interfaced to the micro controller? I would guess on some digital input. If it is how do you address digital inputs? Post the microcontrollers you are using including specific model numbers and we'll take it from there.
adios is offline   Reply With Quote
Old 10-29-2015, 12:20 PM   #724
Alobar
Born Ready
 
Alobar's Avatar
 
Join Date: Nov 2003
Location: 3rd turtle from the bottom
Posts: 41,296
Re: Programming homework and newbie help thread

Quote:
Originally Posted by adios View Post
Well how is the button interfaced to the micro controller? I would guess on some digital input. If it is how do you address digital inputs? Post the microcontrollers you are using including specific model numbers and we'll take it from there.
Its a PIC32MX795F512L

all the documentation is here

http://www.microchip.com/wwwproducts...#documentation

this part deals specifically with the I/O and registers

http://ww1.microchip.com/downloads/e...Doc/61120D.pdf

and this talks about input capture

http://ww1.microchip.com/downloads/e...Doc/61122F.pdf

The button is read through on pin 4 of the board which is here

http://www.digilentinc.com/Data/Prod...T_Max32_RM.pdf (page 11).


I've spent a good number of hours now reading all this stuff and I'm still hugely confused, so I appreciate any help!
Alobar is offline   Reply With Quote
Old 10-29-2015, 01:43 PM   #725
daveT
S.A.G.E. Master
 
daveT's Avatar
 
Join Date: Jun 2005
Location: La La Land
Posts: 23,134
Re: Programming homework and newbie help thread

Quote:
Originally Posted by econophile View Post
Speaking of abstract vs. concrete, I strongly recommend Code: The Hidden Language of Computer Hardware and Software by Charles Petzold.

It starts off simple with switches and explains how switches can be combined into relays (essentially mechanical versions of transitors); how relays can be combined into logic gates (AND, OR, XOR, etc.); how logic gates can be combined into circuits that can add, subtract, multiply and divide (ALUs) and circuits that store information (RAM); and how these components can be combined into a simple computer with switches for inputs and light bulbs for outputs. Along the way, he also touches on Morse code, Braille, barcodes, machine language, 86x assembly language, high level languages, ASCII, simple operating systems, and computer graphics, all within 400 pages.

It's simply one of the best books on any subject that I have read in a while. And for me it was really helpful to start from the bottom and build up each layer of complexity. Modern computers so often just seem to work like magic, so it can be a little mind-blowing to see how everything they do results from incredibly simple operations being performed over and over again according to specific patterns and at incredible speeds.

This may have been easier to grasp with older computers when you typed a command and then had time to think about what was going on inside the computer while it calculated the output. I remember my dad showing me how to write a simple BASIC program on his monochrome luggable IBM-compatible in the mid 80s. Those machines seem much simpler than the ones we use today, although they are still exceedingly complicated.

At any rate, gaining some understanding of how the complex behavior of computers emerges from layer upon layer of simple rules and instructions makes it easier to think about how the same thing can happen with neurons. (I also think it was helpful to read this book before trying to learn C.)
This looks really interesting. Have you tried out NAND to Tetris yet? I've been meaning to get to that one for years.
daveT is offline   Reply With Quote

Reply
      

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Forum Jump


All times are GMT -4. The time now is 12:54 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright 2008-2017, Two Plus Two Interactive
 
 
Poker Players - Streaming Live Online