12 Topics

Member Avatar for
Member Avatar for krieg

The GitHub Repo is [here](https://github.com/apkrieg/foovm). This was part of a contest with someone I met on Omegle. The goal was to see who's VM could run a set of example app the fastest, the catch: We had about 24 hours to implement the solution. My language of choice was Golang, …

0
1K
Member Avatar for vegaseat

Just a couple of number tricks to check Go's mathematical abilities. If you have more, let's show them here.

Member Avatar for vegaseat
2
419
Member Avatar for vegaseat

The story has it that a few hundred years ago the ruler of a big country wanted to reward the creator of the chess game. The creator of the game simply wanted one grain of rice put on the first square of the chessboard, two grains on the second, then …

Member Avatar for vegaseat
2
859
Member Avatar for vegaseat

Again, calculate the minimum number of bills or coins required for a given amount of money (change). This time we will use a Go map instead of a csv string converted to a structure.

0
407
Member Avatar for vegaseat

This Go snippet calculates the minimum number of bills or coins needed for a given amount of money (change) requested. The program also gives the denomination and number. US curency is used in this example, but can be changed to another currency.

1
451
Member Avatar for vegaseat

Another translation of one of my Python snippets. This function will return a slice of consecutive prime numbers from 2 to a given value limit. In Go the 'int' type (int32) will go as high as 2147483647, but you can replace 'int' with 'uint64' and go as high as 18446744073709551615.

1
1K
Member Avatar for vegaseat

Generators are rather familiar objects in Python. Generators supply data on demand. Using Go you can create a generator with a goroutine and a channel. Here the goroutine is an anonymous function within a function, simple to implement.

Member Avatar for vegaseat
0
1K
Member Avatar for vegaseat

Another little adventure into Go coding. This time a slice (a Go open ended array) of structures is used as a record for some data processing. For those who miss the ; at the end of a line of code, you can use them, but the lexer of the compiler …

Member Avatar for vegaseat
1
3K
Member Avatar for vegaseat

This time just a simple example of grading scores (0 - 100) with letters (A - F). Two approaches are presented, one using switch/case in an "on the fly" function, and the other uses the score as an index to a string of letters F through A.

Member Avatar for vegaseat
1
797
Member Avatar for vegaseat

Reading the content of a web page with a given URL is pretty simple with Go. Here we defer the closing of the response body (at an early point, so we won't later forget) until the program exits.

0
22K
Member Avatar for vegaseat

Use Google's modern Go language (aka. golang) to convert a denary number (base 10) to a roman numeral. Just a good exercise to explore Go's map, slice, sort and for loop features. Note that in Go the **:=** is shorthand for assigning a type (by inference) and a value to …

2
577
Member Avatar for vegaseat
Member Avatar for vegaseat
0
237

The End.