Category Archives: Programming (en)
Golang. Pythagoras Theorem
Continue practicing Go and remembering the school curriculum “Pythagoras pants are equal on all sides!” Or to paraphrase in a more boring version: the square of the length of the hypotenuse of a right triangle is equal to the sum … Continue reading
Golang. Character string into a numeric slice
Let’s write a simple program in Go that will take a string, break it down into slice elements, and convert each element into a number. First, all the code, and I will break it down in detail below:
Golang. Number into words
Let’s write a program that prints numbers as text. Let’s limit it to a range of 1 to 1000. Here is the first example of code, a fuzzy one:
Golang: Newton’s algorithm
Task number 8 in golang tour… Cycles and functions To play with functions and loops, let’s implement the square root function: Given a number x, we want to find the number z for which z² is closest to x. Computers … Continue reading
Golang. The average of the numbers entered in the string
Let’s write a program that reads N numbers separated by a space (in one line) and calculates their average value. The task seems to be simple, but it can be solved in different ways. Here is my version:
Golang. Median
Today let’s remember what the median is and how to find it. The median is a number exactly in the middle of an ordered list. It is a very useful thing in statistics and it helps to see the real … Continue reading
Golang. Number of letters in a sentence
Calculate the number of characters in the text – how many which letter occurs how many times. You can do this with maps, but there is another, C-style way: character arithmetic:
Golang. Funny basic example of `if/else`
There is a resource for newcomers to the Go language – “A Tour of Go“. There’s a funny example in the beginning by number 7..
Golang. Simple programs for beginners
The Go language is very similar to C. Here are some simple programs. Let’s begin… Calculate 2 to the 12th power.
What do you program in Python? Real-world applications with library examples
When I started learning Python, I got curious about what people write in this language. If you look at it from a general perspective, it seems like Python is used everywhere – it’s such a super universal language that you … Continue reading
Top 3 programming languages for beginners. Which first programming language should I choose?
As a beginner programmer you have probably already racked your brains thinking about which programming language to choose. I have chosen three options, and now I will explain which one is right for you. Three of the best first … Continue reading
Assembly cheatsheet
Assembler is a low-level programming language. Below it there is only machine code (zeros and ones). Why learn assembler? To understand how a computer works. Any programmer must know C. Any programmer who knows C must know Assembler. The ability … Continue reading
Hello World in Assembly x86
Hello World in assembly language. How much fun is in that! For starters, here’s what we’re going to dig into in asm, the classics: #include <stdio.h> int main(void) { printf(“Hello, world\n”); return 0; } On GNU assembly it would be … Continue reading
C language: “can’t bind to the port” problem (Windows)
Sometimes your program process can stuck and trigger error like this: Couldn’t bind to the port Ok, we have such check in out sockets C code: if (bind (socket_desc, (struct sockaddr*)&server_addr, sizeof(server_addr)) < 0) printf(“Couldn’t bind to the port\n”); And … Continue reading
C language: NCURSES basics
NCURSES – it is a C library which control process of sending a series of bytes by terminal. It’s quite oldschool approach, but it’s widely used even right now as internet works the same way: packets sending just series of … Continue reading
C language: compile and run in Notepad++
In top menu press “Run” and enter there… Example: cmd /c cd “C:\Users\n\Desktop\” && gcc 1.c -o 1.exe && 1.exe There we say to Notepad++: cmd – run terminal /c means to close cmd terminal after program finished; you can … Continue reading
Python: string generation with concatenation
Task is to generate 50 strings of such kind: hello 1 world hello 2 world hello 3 world hello 4 world … Tried such clumsy way (I forgot Python really):