[SOLVED]Do you creates algorithm?

click_here

Joined Sep 22, 2020
471
In that case I would suggest studying some algorithms and learning about the (N) notation

https://en.m.wikipedia.org/wiki/Sorting_algorithm

However, solving problems on Project Euler is a great way to discover algorithms and explore computer science :)
https://projecteuler.net/

You are given problems to solve, starting off easy, and getting more and more difficult.

It doesn't matter what language you choose, or if you program a PIC/Arduino, you just have to find the answer!
 

sparky 1

Joined Nov 3, 2018
647
You do make an algorithm. Not just algebra but theorems and postulates in geometry and higher math.
Simply put a word problem can be written carefully as a mathmatical expression.
An algorithm can manipulate an expression something like the mechanical part of solving an equation.
The use of operators, conversions, loops if and when are to me all extensions of mathematics.
The programmer gets a unique and elequent view of a data structure that can be satisfying.
 

Beau Schwabe

Joined Nov 7, 2019
110
If they're simple enough, you can do them in your head.

I find it easier to check all boundary conditions if I create a flow chart. I have chronic pain that prevents me from being able to sit for more than an hour or so, so a flow chart relieves me of the burden of keeping track of all of the conditions in my head. When I could code for 8-12 hours at a sitting, I didn't use flow charts as much.
Flow charts are a must! In my line of work A flow chart makes it so much easier to make changes to code a week, a month a year, etc. At any given time I might have 5 different projects for 5 different clients. A flow chart also keeps things straight from one project to the next.
 

atferrari

Joined Jan 6, 2004
4,506
Flow charts are a must! In my line of work A flow chart makes it so much easier to make changes to code a week, a month a year, etc. At any given time I might have 5 different projects for 5 different clients. A flow chart also keeps things straight from one project to the next.
The way I use them, writing code is just clerical work.
I keep charts handy when debugging. Find them a real help too.
 
I did a lot of software design. The coders whipped out the code.

Here's an easy one, sort of. You need x and y co-ordinates from 1-80- rows and 1 to 25 columns, You have to present these to the ESC sequence for dirct cursor addressing for a CRT terminal. Might be ESC '[" and something else + 3,45.
ESC is a 27, the left bracket is a "[" and the other stuff can be looked up.

So, how do you turn 3,45 into "0030045"

Some nuances you have to know is num$(1) changes numbers to strings, but you get either " 1 " or "-1 ". You always get a leading space or a "-" and a trailing space, I think.

The language had print using "###", and I think there was a way to make it have leading zeros, but there was no way to combine format and change to a string.

--

The language I used had a neat function, rarely used, called "Change a$ to a%" and "Change a% to a%". It doesn't do what you expect. $ is a string, % is a 16 bit integer. So change "000" to a% would create an array:
a%(a) =3
a%(1)=48
a%(2)=48
a%(3)=48

A%(0) is the length of the string. Then the ASCII values of each letter.

The language that had this statement was basic-Plus that ran on a PDP-11 under the OS RSTS-11.

Here https://vt100.net/docs/vt100-ug/chapter3.html#VT52CUP is the vt52 sequences:

Direct Cursor Address
ESC Y line column

Move the cursor to the specified line and column. The line and column numbers are sent as ASCII codes whose values are the number plus 0378; e.g., 0408 refers to the first line or column, 0508 refers to the eighth line or column, etc.

I found the vt100, and it's dfferent than I remember:

https://vt100.net/docs/vt100-ug/chapter3.html

CUP – Cursor Position
ESC [ Pn ; Pn H default value: 1

The CUP sequence moves the active position to the position specified by the parameters. This sequence has two parameter values, the first specifying the line position and the second specifying the column position. A parameter value of zero or one for the first or second parameter moves the active position to the first line or column in the display, respectively. The default condition with no parameters present is equivalent to a cursor to home action. In the VT100, this control behaves identically with its format effector counterpart, HVP. Editor Function

The numbering of lines depends on the state of the Origin Mode (DECOM).

But yea, sometimes you have to make a number like 1 to be the string "001".
 

MrChips

Joined Oct 2, 2009
24,992
Oh, there are so many. Here is another.

You have to draw a straight line from (x1,y1) to (x2,y2) on a graphics screen.
Find the location of each pixel that need to be accessed in between the two endpoints.
The pixels must be the same when the line is drawn in the opposite direction, i.e. drawing from (x2,y2) to (x1,y1).
Only integer arithmetic is allowed.
 
I can sort of see how to do that. Normally, you might use Y = Int(y*10+0.5)/10; INT only works for positive values.
You can make believe 10.5 is 100 + 5 and adding 0.5 is 105 and go from there. INT is the greatest integer in x function which does wierd things for negative values, so FIX() is better.

You want to round, but rounding has to be integer, so you have to trick it.

==

Learning about ASCII and assembly language programming, I see myself seeing those fundamental concepts combined with digital logic.
Setting and clearing a bit can be easy or difficult.
 
Last edited:
How about this eaxmple. I'll use toilet paper, one a supply roll and one a take-up roll. You want to expose 1 sheet every 3 minutes. The application could be a VCR tape. The application was the toilet paper was clear Teflon that had to be refreshed to a clear piece every 3 minutes or the reaction with UV light got limited. The rolls were in a vacuum and there was no way of linearly measuring the material.

I anticipated that tension control woud be necessary, but it wasn;t. I did not anticipate, that the magnetic clutch needed to go slightly reverse current at extremely low tensions. If it required tension control, the clutch current would change based on diameter.

the basic relationship is s=rθ where s is the linear distance, r is the radius and θ is the radian angle. We mounted a turns counting dial that could be reset. We knew the initial diameter of the take up reel and we knew the thickness of the Teflon around 0.002". Now how far to move the motor and what motor to use to advance the teflon one "sheet".

I used a whole LSI-11 to do this. The IBM PC wasn't up for it. Take-up wasn't perfect like it would be in a VCR, but it didn;t matter. The software had to take the initial turns-count and have the thickness, length and motor RPM (A synchronous timing motor) and an interval clock to figure out how to move the motor. The program actually had to do two motors at the same time.

I forget exactly how it was done, but the computer ran RT11 and the timing may have been done in assembly code.
How well it worked would show up on the difference on what the computer thought the number of turns was and the actual number of turns.

Fun project. Later though the process was done using a PC and some hardware. The PC did the 3 minute clock and the hardware did the advance clock. It was part of the automation process.

So, yep it's an algorithm.

In high school, I was provided with a number of master padlocks to try to open. I had taken combination locks apart to know how they worked. I then developed an algorithm where I could generally open the padlock in about 20 minutes. It might take me about 10 more minutes to actually get the combination.

I opened a safe for my mom's friend who's husband passed away. She didn't want the combo, jut the save open. It took me about 20 minutes.

That's developing an algorithm knowing just about nothing. I had plenty of locks to test the algorithm on, so it's like clinical trials. So for a simple Left-Right-left or R-L-R lock, the numbers are related to clicks. The last number is easy within about 4. The other 2 are matematically related within 4 or so. It takes some trials to test those combinations. Then you have to verify the combination.
 
Top