• Welcome to the new Internet Infidels Discussion Board, formerly Talk Freethought.

advent of code

I pseudo-coded this one out already:

Code:
if(beingPaidToDoThis)
    finishPuzzles()
else
    go to #end_program
endif

:D

More seriously I'm the kind of programmer who doesn't do any type of coding unless it has some kind of relationship to me making money. But I know a lot of programmers who'd enjoy this.
 
I pseudo-coded this one out already:

Code:
if(beingPaidToDoThis)
    finishPuzzles()
else
    go to #end_program
endif

:D

More seriously I'm the kind of programmer who doesn't do any type of coding unless it has some kind of relationship to me making money. But I know a lot of programmers who'd enjoy this.

Did you just write pseudocode in Visual Basic?
 
Without using canned routines write code to

1. Find the max and min numbers in an unsorted list.
2. Sort a list of numbers.
3. Sort an array of strings containing first and last names by last naame. If there are identical last names sort them in the list by first names.

A harder but practical problem

Write code to parse a math string expression. Be able to process an arbitrary string with [] and ().

'[ (a + b)/c] * [x]
a = 2 b - 3 c = 4 x = 5

When you are able to process the first string add all the standard math functions like sin log, and add divide by zero protection and string error checking. If there is a string error display the number of the character. .

'[ (a + b)/c] * [x * sin(x)] - [log( 2 * x)]'

And then after all that write a GUI to take a string from a window or command line and display the result.
 
I pseudo-coded this one out already:

Code:
if(beingPaidToDoThis)
    finishPuzzles()
else
    go to #end_program
endif

:D

More seriously I'm the kind of programmer who doesn't do any type of coding unless it has some kind of relationship to me making money. But I know a lot of programmers who'd enjoy this.

Did you just write pseudocode in Visual Basic?

Lately my if statements come from Cerner CCL. I don't like it either but it's what's currently engraved in my head.
 
Without using canned routines write code to

1. Find the max and min numbers in an unsorted list.
2. Sort a list of numbers.
3. Sort an array of strings containing first and last names by last naame. If there are identical last names sort them in the list by first names.

A harder but practical problem

Write code to parse a math string expression. Be able to process an arbitrary string with [] and ().

'[ (a + b)/c] * [x]
a = 2 b - 3 c = 4 x = 5

When you are able to process the first string add all the standard math functions like sin log, and add divide by zero protection and string error checking. If there is a string error display the number of the character. .

'[ (a + b)/c] * [x * sin(x)] - [log( 2 * x)]'

And then after all that write a GUI to take a string from a window or command line and display the result.

These were the type of problems we were given during the first term of six in our programming diploma. They offer a good way to get comfortable with basic syntax, data structures, and the like.

By third term we were building iterative, tiered applications in .NET. In fourth and fifth we got into some slightly funkier stuff. By 6th they'd say 'here's your technology, build an app by this date'.
 
I pseudo-coded this one out already:

Code:
if(beingPaidToDoThis)
    finishPuzzles()
else
    go to #end_program
endif

:D

More seriously I'm the kind of programmer who doesn't do any type of coding unless it has some kind of relationship to me making money. But I know a lot of programmers who'd enjoy this.

What a life :D

I'm more the hobbyist coder who gets paid for some of his code kind of programmer.
 
I pseudo-coded this one out already:

Code:
if(beingPaidToDoThis)
    finishPuzzles()
else
    go to #end_program
endif

:D

More seriously I'm the kind of programmer who doesn't do any type of coding unless it has some kind of relationship to me making money. But I know a lot of programmers who'd enjoy this.

What a life :D

I'm more the hobbyist coder who gets paid for some of his code kind of programmer.

I tinkered with React a bit this year, but these days read more business and leadership books than anything. I've got the technical side pretty much in the bag, so any gains I make these days are more in the arena of soft skills.

But there are a lot of 'unbalanced' coders out there who live and breath software, attend meetups, consistently code in their spare time, yadda yadda. I learned how to code so I can spend my free time doing things that are more interesting than coding. And counter-intuitively that probably makes me a better developer than the die-hard techies.

You'll get the really tech-oriented person masterfully crafting a solution to the wrong problem, etc.
 
Without using canned routines write code to

1. Find the max and min numbers in an unsorted list.
2. Sort a list of numbers.
3. Sort an array of strings containing first and last names by last naame. If there are identical last names sort them in the list by first names.

A harder but practical problem

Write code to parse a math string expression. Be able to process an arbitrary string with [] and ().

'[ (a + b)/c] * [x]
a = 2 b - 3 c = 4 x = 5

When you are able to process the first string add all the standard math functions like sin log, and add divide by zero protection and string error checking. If there is a string error display the number of the character. .

'[ (a + b)/c] * [x * sin(x)] - [log( 2 * x)]'

And then after all that write a GUI to take a string from a window or command line and display the result.

These were the type of problems we were given during the first term of six in our programming diploma. They offer a good way to get comfortable with basic syntax, data structures, and the like.

By third term we were building iterative, tiered applications in .NET. In fourth and fifth we got into some slightly funkier stuff. By 6th they'd say 'here's your technology, build an app by this date'.


It is what separates coders from software engineers. A bubble sort or a min max question would-be something I'd ask interviewing a software engineer. Fail that and it is the rejection gong. I'd ask the last problem depending on experience. Plus others

It is expensive these days, Knuth's Semi Numerical Algorithms is a stand reference.
 
I pseudo-coded this one out already:

Code:
if(beingPaidToDoThis)
    finishPuzzles()
else
    go to #end_program
endif

:D

More seriously I'm the kind of programmer who doesn't do any type of coding unless it has some kind of relationship to me making money. But I know a lot of programmers who'd enjoy this.

Did you just write pseudocode in Visual Basic?

Lately my if statements come from Cerner CCL. I don't like it either but it's what's currently engraved in my head.

Code:
Dim Rousseau As Programmer.Target(Mockery As Text)
 
The OP's link, titled: Advent of Code 2018 -- currently in its 9th puzzle.

Without using canned routines write code to

1. Find the max and min numbers in an unsorted list.
2. Sort a list of numbers.
3. Sort an array of strings containing first and last names by last naame. If there are identical last names sort them in the list by first names.
1. Easy. In pseudocode:
args: xlst
xmin = first(xlst)
xmax = first(xlst)
for x in xlst do:
. if x < xmin: xmin = x
. if x > xmax: xmax = x
end for
return xmin, xmax

2. More difficult. Off the top of my head, I can do it with bubblesort, shellsort, and mergesort. I'd have to research heapsort and quicksort.

3. Be sure to have a sort function that will accept arbitrary data types and a comparison function.

If one has already parsed a name into (first name, last name, extras like middle name and title), the one creates a sort function that looks like this:

args: name1, name2

lastname1 = name1[1]
lastname2 = name2[1]
cmp = string_compare(lastname1,lastname2)
if cmp != 0: return cmp

firstname1 = name1[0]
firstname2 = name2[0]
cmp = string_compare(firstname1,firstname2)
return cmp

Assumes zero-based indexing.

A string-compare function would go something like this:

Symbolic constants:
LESS = -1
GREATER = 1
EQUAL = 0

args: str1, str2
len1 = length(str1)
len2 = length(str2)
ix = 0

while(true):
. if ix >= len1:
. . if ix >= len2: return EQUAL
. . else: return GREATER
. else if ix >= len2: return LESS

. c1 = str1[ix]
. c2 = str2[ix]
. if c1 > c2: return GREATER
. if c1 < c2: return LESS

. ix += 1
end while

Assumes that a shorter string comes before a longer string, all else being equal.
 
Write code to parse a math string expression. Be able to process an arbitrary string with [] and ().

'[ (a + b)/c] * [x]
a = 2 b - 3 c = 4 x = 5

When you are able to process the first string add all the standard math functions like sin log, and add divide by zero protection and string error checking. If there is a string error display the number of the character. .

'[ (a + b)/c] * [x * sin(x)] - [log( 2 * x)]'
The output is something presumably much easier to generate code from, like prefix form. What LISP is already in: LISP is List Processing or Lots of Irritating Superfluous Parentheses.

(* (/ (+ a b) c) x)
(= a (- (* 2 b) (* 3 (= c (4 (= x 5))))))
(* (* (/ (+ a b) c) (* x (sin x))) (log (* 2 x)))

And then after all that write a GUI to take a string from a window or command line and display the result.
That would depend on the GUI-widget set. I've used several of them over the years. I've done GUI coding in MacOS Classic, OSX Cocoa, Java, Python/TK, HTML/CSS/JavaScript, Mathematica, and Matlab.

Here is some pseudocode for that:

Definitions:
InputTextField - a text field
OuptutTextField - a text field
ParseButton - a button
In a GUI window, one may want some text labels that describe each of the two text fields.

Code:
ParseButton runs function Parse(), defined as follows:
intext = InputTextField.getText()
outtext = Parse(intext)
OutputTextField.setText(outtext)

Parse() would accept a text string and return a text string.
 
It is more complicated then that.

If it were production code the first pass would be enduring an even number of parenthesis and syntax of text like sin, error checking.

Next create variables for sub calculations. Embedded parentheses. Parsing embedded parentheses in a general solution that is without potential errors is difficult when you actually try to code it. It is the same problem writing a parser in a compiler, assembler, or interpreter. You need to create stacks.

Writing a Reverse Polish Notaion calculator is not much easier.

To add complexity post fix and in fix.

My math tool I settled on was Scilab . It has a Pascal-c like language.

I used HP RPN for decades. I wrote a calculator that could store and retrieve equations like a calculator. Plot functions. I kept a window open and stopped using hand calculators. It has a nice GUI set of gunctions to dvelop an interface and use a mouse within a window.

I always did a project like that once in a while to enhance skills and stay fresh.

Getting from pseudo code to working code without using canned functions may be found more difficult than you might think. I sm one of those with a lot of curiosity and who likes difficult challenges. It was more satisfying then video games.

General apps today are easy. Internet code and libraries come with MS tools. Visual C++ has GUI tools. All the hard work is done. I did hardware work for a software entrepreneur who developed a math tool oriented to banks and fiancé, made him a lot of money. The tool ran about $20k, but then he did not need to hire software engineers.
 
Back
Top Bottom