teleren/devto huggingface dataset:
[Golang] How to Implement Bubble Sort Algorithm
Tags: go, algorithms, tutorial, beginners
Published: 2021-10-11 10:11:11

Today we are going to work on bubble sort implementation.

## What is Bubble Sort?

Bubble sort is a sorting algorithm that works by repeatedly stepping through lists that need to be sorted, comparing each pair of adjacent items and swapping them if they are in the wrong order. This passing procedure is repeated until no swaps are required, indicating that the list is sorted. Bubble sort gets its name because smaller elements bubble toward the top of the list.

Bubble sort is also referred to as sinking sort or comparison sort.

## Explanation

Bubble sort has a worst-case and average complexity of O(n2), where n is the number of items sorted. Unlike the other sorting algorithms, bubble sort detects whether the sorted list is efficiently built into the algorithm. Bubble sort performance over an already sorted list is O(n).

The position of elements in bubble sort plays an important role in determining performance. Large elements at the beginning do not pose a problem as they are easily swapped. The small elements toward the end move to the beginning slowly. As such, these elements are called rabbits and turtles.

The bubble sort algorithm can be optimized by placing larger elements in the final position. After every pass, all elements after the last swap are sorted and do not need to be checked again, thereby skipping the tracking of swapped variables. 

So now we know what bubble sort is, So let's start writing code

Code:

```
	arr := []int{5, 3, 4, 9, 6, 8, 0, 1, 2}
	fmt.Println(arr)

	// Way 1 next index checking with current index
	// 1. x pointer is on index 0
	// 2. y pointer in on index 1
	// each time whenever y execution finishes it increment values for both
	// whenever x starts again for next index
	for x := range arr {
		var swapped bool
		y := x + 1
		for y = range arr {
			if arr[x] < arr[y] {
				arr[x], arr[y] = arr[y], arr[x]
				swapped = true
			}
		}
		if !swapped {
			break
		}
	}

	
```

Checkout Here for more methods on bubble sort implementation:
https://kdsingh4.blogspot.com/2021/10/golang-how-to-sort-array-slice-using.html

Checkout More Algorithms Solutions: https://kdsingh4.blogspot.com/search/label/algorithm?&max-results=5/feed/

Don't Forget To Subscribe My Youtube Channel as well:
https://www.youtube.com/channel/UCXhmNqWQ50zitqIdTgS7s8Q
Don't write HTML page, I will tell you why.
Tags: programming, webdev
Published: 2021-10-11 10:07:03

Instead of encourage people, I am here to discourage you a guy, who started / want to start web development. 

## The start
At the start your journey, you install either sublime or vscode or notepad++, then you start to make a website using HTML and know that HTML is a HyperText Markup Language. You feel proud of yourself as your HTML page is displayed in google chrome. Then, you color your page with CSS and make your page interactive with alert() and document.write().


## framework hell
Slowly, you think you are very good, then you heard of React or Angular and you immediately jump into it. In the blink of an eye, you are overwhelmed. What the hell is Webpack? What is JSX? What is Nodejs? What is typescript? What is npm? What is Sass? Why a simple website need so much technology with weird names?

## server-side programing
At the verge of giving up, you heard of database and server. You install XAMPP or WAMPP and then start poking around with PHP. You also play around with expressjs. Then, you are once again overwhelmed. What is composer? What is a session? What is phpMyAdmin and MySQL? 

## game development
After you learn one or two things, you think desktop application and game development is cool, so you install Unity. Oh my, Object-Oriented Programming in C# (pain in general). You think that ElectronJS is easier and want to give it a shot but because everyone critisize that it is less performant so you give up.

## linux
Then, you heard that people keep telling you "I use Arch, btw" and "Vim is the best editor". You watch a few shitpost from Mental Outlaw (on youtube) and decided to install gentoo linux. You are once again overwhelmed. Why so much command (cd, touch, ls, emerge, time, ifconfig, vim and etc.)? Systemd called as soystemd? OpenRC? Init system? GNU and Linux is different? Display server? X.org vs Wayland? dwm vs bloated Gnome?

## lower-level programming
Then as you get used to the tty and know how to edit some text in vim. You start to do some C and C++ programming. Although the OOP from C# or Java helps, you still feel overwhelmed. CMake, Ninja, gcc, tcc, clang, llvm and etc.
Maybe you also step on some assembly language and suffers. 


Ok I will stop now. All these painful learning + failing + imposter syndrome + mental illness is all because of you decided to install sublime /  vscode to create a HTML page. 

In conclusion, don't create your first HTML page.
Aggregate data imported form an Excel file.
Tags: excel, spreadsheet, stream, batch
Published: 2021-10-11 09:58:59

---
title: Aggregate data imported form an Excel file.
published: true
description: Best strategy to aggregate data imported form an spreadsheet.
tags: excel, spreadsheet, stream, batch
---

The users of an application make requests, identified by an id, relative one or more subjects.

The application produce a spreadsheet: the list of subjects and the id of the request.

The operators populate the spreadsheet with additional data for every subject and the import the file in the application.

The software has to aggregate the subject data in the requests identified by the request id and send the data to the users.

What is the best strategy to aggregate the spreadsheet data in requests?

This is at the moment my best solution.

![Strategy to aggregate spreadshhet data](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/isrw55og1hajbo13w7wp.png)

Suggestions are welcome!
Using a virtual camera to avoid moiré patterns in pictures of screens
Published: 2021-10-11 09:46:29

Photographing a computer screen produces inevitable [moiré patterns](https://en.wikipedia.org/wiki/Moir%C3%A9_pattern) – visual artifacts of camera sensor/display interference.

A remedy for this is to use what amounts to a specialized virtual camera – essentially an interactive 3D scene capable of imitating the desired properties of photography while eliminating distortions like moiré.

An example...

With a real camera:
![Before](https://i.ibb.co/BL8GkQz/before.jpg)

With virtual camera (using the online tool: [Screenstab](https://www.screenstab.com)):
![After](https://i.ibb.co/P1j2FqY/after.png)

Until next time.


– Mikael Åsbjørnsson-Stensland
Cut Ribbon
Tags: codeforces, math, array, bruteforce
Published: 2021-10-11 09:32:43


Problem Link :- [https://codeforces.com/problemset/problem/189/A]

Polycarpus has a ribbon, its length is _n_. He wants to cut the ribbon in a way that fulfils the following two conditions:

- After the cutting each ribbon piece should have length _a_, _b_ or _c_.
- After the cutting the number of ribbon pieces should be maximum.

Help Polycarpus and find the number of ribbon pieces after the required cutting.

> Input

> The first line contains four space-separated integers _n_, _a_, _b_ and _c_ (1 ≤ _n_, _a_, _b_, _c_ ≤ 4000) — the length of the original ribbon and the acceptable lengths of the ribbon pieces after the cutting, correspondingly. The numbers _a_, _b_ and _c_ can coincide.

> Output

> Print a single number — the maximum possible number of ribbon pieces. It is guaranteed that at least one correct ribbon cutting exists.

Examples

Input

```
5 5 3 2
```

Output

```
2
```

Input

```
7 5 5 2
```

Output

```
2
```

Hint:-

In the first example Polycarpus can cut the ribbon in such way: the first piece has length 2, the second piece has length 3.

In the second example Polycarpus can cut the ribbon in such way: the first piece has length 5, the second piece has length 2.

**Solution:-**

To run the code [Click here](https://onlinegdb.com/CK22sMulS)

```
import java.util.*;

public class Main
{
  public static void main (String[]args)
  {
    Scanner sc = new Scanner (System.in);
    int n = sc.nextInt ();
    int a = sc.nextInt ();
    int b = sc.nextInt ();
    int c = sc.nextInt ();
    int count = 0;
    int arr[] = { a, b, c };
    Arrays.sort (arr);

if (arr[0] >= n)
      {
 System.exit (0);
      }
    else
      {
 for (int i = 0; i < 2; i++)
   {
       
     if(n > 0)
       {
  n = n - arr[i];
  count++;
       }
   }
   System.out.println(count);
      }
  }
}
```
Next.js Dynamic Routes With Contentful's GraphQL API — with Jason Lengstorf
Tags: nextjs, javascript, jamstack, graphql
Published: 2021-10-11 09:31:03

I sat down with [Jason Lengstorf](https://twitter.com/jlengstorf) to talk about [Next.js](https://nextjs.org/docs) and teach him how to generate dynamic routes powered by the [Contentful GraphQL API](https://graphql.contentful.com/).

In this video, we cover:

- [Intro and a bit about my background](https://youtu.be/OWgeN6O707s?t=6)
- [What I like about Next.js and Contentful](https://youtu.be/OWgeN6O707s?t=172)
- [Thoughts on GraphQL vs REST](https://youtu.be/OWgeN6O707s?t=414)
- [GraphQL is more environmentally friendly than REST and making tech more accessible to hobby developers](https://youtu.be/OWgeN6O707s?t=735)
- [Planning today's project](https://youtu.be/OWgeN6O707s?t=866)
- [Setting up the content model in Contentful](https://youtu.be/OWgeN6O707s?t=1231)
- [Adding entries to Contentful](https://youtu.be/OWgeN6O707s?t=1610)
- [Installing the GraphQL Playground app in Contentful](https://youtu.be/OWgeN6O707s?t=1894)
- [Building the GraphQL query in the GraphQL playground](https://youtu.be/OWgeN6O707s?t=2074)
- [Creating a new Next.js application and using the GitHub CLI and Netlify CLI to set up environment variables to deploy](https://youtu.be/OWgeN6O707s?t=2154)
- [Using getStaticProps to fetch data for the home page via the Contentful GraphQL API](https://youtu.be/OWgeN6O707s?t=2557)
- [Building a list of client-side anchor links using next/link](https://youtu.be/OWgeN6O707s?t=3049)
- [Using getStaticPaths to create dynamic routes at build-time](https://youtu.be/OWgeN6O707s?t=3172)
- [Using getStaticProps to fetch data for individual dynamic routes with GraphQL](https://youtu.be/OWgeN6O707s?t=3744)
- [Styling the front end](https://youtu.be/OWgeN6O707s?t=4161)
- [Deploying the site to Netlify](https://youtu.be/OWgeN6O707s?t=4946)

I had a great time on Learn with Jason — and learned a few things along the way, too! I'm excited to speed up my development and deployment process using the [Netlify CLI](https://cli.netlify.com/) next time I launch a new project.

Thanks for having me, Jason!

{% youtube OWgeN6O707s %}

## Resources and links

- [https://graphql.contentful.com/](https://graphql.contentful.com/)
- [https://jamstackconf.com/2021-videos](https://jamstackconf.com/2021-videos)
- [https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation](https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation)
https://twitter.com/jamstackconf/status/1446132787480649735](https://twitter.com/jamstackconf/status/1446132787480649735)
- [https://github.com/whitep4nth3r/nextjs-contentful-blog-starter](https://github.com/whitep4nth3r/nextjs-contentful-blog-starter)
- [https://jamstack-memories.netlify.app](https://jamstack-memories.netlify.app/)
- [View the video transcript](https://www.learnwithjason.dev/next-js-dynamic-routes-with-contentful-s-graphql-api)
Sum of Non-Prime Number
Tags: arrays, functionalprogrammin, primenumbers, mathematics
Published: 2021-10-11 09:23:28

We are taking a number N as a input which and we have to find the sum of all non prime numbers in digits of N i.e. if N=789 then 8 and 9 are not prime so print 8+9.

Example:

Input

```
579
```

Output

```
9
```

Input

```
467
```

Output

```
10
```

Solution :- [https://onlinegdb.com/4wofh-j8y](https://onlinegdb.com/4wofh-j8y)

```
import java.util.*;
public class Main
{

static int countDigit (long n)
  {
    int count = 0;
    while (n != 0)
      {
 n = n / 10;
 ++count;
      }
    return count;
  }

public static int prime (int n)
  {

if (n == 1 || n == 0)
      return 0;

else if (n == 2)
      return 0;

else if (n % 2 == 0)
      return n;

for (int i = 3; i <= Math.sqrt (n); i += 2)
      {
 if (n % i == 0)
   return n;
      }
    return 0;
  }

public static void main (String[]args)
  {
    int sum = 0;
    int arr[] = new int[100];
    Scanner sc = new Scanner (System.in);
    int n = sc.nextInt ();
    int size = countDigit (n);
    for (int i = 0; i < size; i++)
      {
 if (n > 0)
   {
     arr[i] = n % 10;
     n = n / 10;
   }
      }
    for (int i = 0; i < size; i++)
      {
 sum += prime (arr[i]);
      }
    System.out.println (sum);
  }
}
```
React JS, Instagram NFT app prototype
Tags: react, ux, javascript
Published: 2021-10-11 08:52:25

NFT instagram app prototype based on React JS. Images may load slowly since they are quite big. Random images that i could find online, are used. Did not check for copyrights :).

Link to app,
https://instagram-nft-app-c1yfmg5x1-benjamin-c.vercel.app/
Introduction to programming
Tags: beginners, programming
Published: 2021-10-11 08:50:39

> ## Program

A **program** is a set of instructions given to computer to perform a specific task. Creating those instructions is programming by a *programmer*.

---
> ### Programming language 

A __programming language__ is a computer language that is used by programmers(_developers_) to communicate with computers. For example _C++_, _java_, _python_ etc...

---
> ### There is a difference between "Coding" & "Programming":
---

### _Coding_:
    **Definition**: Transformation of natural language into a machine-level program
    **Skills**: Basic knowledge of programming languages such as C, C++, C#
    **Outcome**: An application, software or websites.

### _Programming_: 
    **Definition**: Development of a fully functioning software.
    **Skills**: Analytical skills, writing complex program, data structures and algorithms.
    **Outcome**: A functional code.
### Etc...

#### *That was all I wanted to tell you*

#### *I will write my new post soon, thank you for reading till the end!!!*
Taman Simalem Resort
Tags: tamansimalemresort, paketwisatatamansimalemresort, pakettourtamansimalemresort
Published: 2021-10-11 08:24:17

Taman Simalem Resort adalah salah satu destinasi wisata yang sebenarnya eksis di kitaran 10 tahun terakhir dan menjadi salah satu titik terbaik untuk menikmati keindahan Danau Toba dari bagian utara danau.

<a href="https://aurorawisata.com/products/detail/31/taman_simalem_resort_berastagi_fullday_tour/">Taman Simalem Resort</a> merupakan salah satu theme park yang unik karena berlatar Danau Toba, salah satu danau kaldera terbesar di dunia yang terjadi oleh karena letusan gunung api 74 ribu tahun yang lalu. Selain taman dengan aneka ragam tumbuhan bermanfaat, Taman Simalem juga memiliki hotel mewah berstandard hotel resort bintang 4.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jc269t0dxl5ovc99dkph.jpg)

Travel agent medan mendisain <a href="https://aurorawisata.com/products/detail/31/taman_simalem_resort_berastagi_fullday_tour/">paket tour taman simalem resort</a> yang nyaman untuk para pelancong yang ingin mengunjungi lokasi ini dari Medan melalui Kota Berastagi yang dimulai dengan penjemputan tamu di Bandara Kuala Namu Medan biasanya pada pagi atau siang hari.

<a href="https://aurorawisata.com/products/detail/31/taman_simalem_resort_berastagi_fullday_tour/">Paket wisata taman simalem resort</a> biasanya memasukkan program makan siang dan malam juga menjadi bagian yang tak terpisahkan dari program tour taman simalem. Selain itu, program <a href="https://aurorawisata.com/products/detail/31/taman_simalem_resort_berastagi_fullday_tour/">tour taman simalem resort</a> juga biasanya diikuti oleh paket tour danau toba serta paket tour medan. Dengan demikian, sekali merencanakan program wisata, semua destinasi terdepan di Sumatera Utara dapat dilalui.
Would you like to create your own NFT of Blog?
Tags: discuss, webdev, programming
Published: 2021-10-11 08:48:36

Recently i stumbled upon above idea and created my own app 
https://blogtonft.com/

This App even got featured at product hunt 
https://www.producthunt.com/posts/blogtonft

Would love to know feedback of all the people here

PS: This is a free app and I won't be making any money out of this.
This is just an app for the community. So everyone at Dev.to is most welcome to create their own NFT 
 <a id="dfC1Ji59YlekytqXDMqPrnMCRjh1" href="https://blogtonft.com"><img src= https://img.shields.io/static/v1?label=Minted%20At&message=BlogToNFT&color=7c3aed&logo=leaflet&logoColor=green/></a>
Bukit Sibeabea Samosir
Published: 2021-10-11 08:13:43

Danau Toba secara terus-menerus berbenah diri seiring dengan ambisi Pemerintah Republik Indonesia untuk membuat Danau Toba sebagai "Monaco of Asia". Atas dukungan Pemerintah Pusat sejak tahun 2016 di mana Danau Toba masuk ke dalam 10 destinasi wisata khusus binaan Pemerintah Pusat untuk dikembangkan. Banyak hal telah dilaksanakan mulai dari perbaikan infrastruktur jalan, pembangunan Bandara Silangit dan lain-lain.

Yang sedang hot saat ini adalah pembangunan jalan di Bukit Sibea-bea yang berhasil menyingkap satu rahasia bahwa lokasi ini adalah sebuah tempat terbaik untuk menyaksikan Danau Toba. Oleh karena itu <a href="https://aurorawisata.com/products/detail/14/paket_tour_medan_danau_toba_4hari_3_malam/">paket wisata samosir</a> dewasa ini wajib menyertakan kunjungan ke tempat ini. Walau tidak gampang untuk mencapai lokasi ini yakni di daerah Kecamatan Harian Boho, namun animo masyarakat untuk mencapai lokasi ini sangat tinggi.

Dalam <a href="https://aurorawisata.com/products/detail/14/paket_tour_medan_danau_toba_4hari_3_malam/">paket tour samosir</a> reguler, program mengunjungi Bukit Sibea-bea belum ada. Alasannya bahwa sampai hari ini jalan di Sibea-bea ini belum diresmikan pemakaiannya dan baru akan diresmikan pada tahun 2022 mendatang. Meskipun demikian tour samosir dianggap kurang sempurna bila tidak sampai ke lokasi ini.

https://auror.jouwweb.nl/tambahan
A Little Bit About Myself
Tags: webdev, beginners, javascript, programming
Published: 2021-10-11 08:05:55

Six months have passed since I quit my job and jumped into this whole new world. Never had I thought of owning a MacBook and spending a whole day gazing on the screen.

I majored in psychology and sociology at college in the States and started teaching English to children back in my country. Children are energetic and eager to learn, and that's how they acquire a new skill so quickly. As I saw them growing up and making their dreams come true, I stopped and asked myself, "What is my dream?" And here I am. I became a student again here in Canada.

I'm taking classes, reading reference books, watching YouTube videos, studying W3School, MDN, and freeCodeCamp, and Googling.
Some worked for me and others didn't, probably because I had (and still have) too little knowledge to make the most of them. So, hopefully, I can get your experience and advice to grow together. Also, I like the learning method: "To teach what we learn", so I'll become a teacher again to teach myself when writing this blog.
Bukittinggi Kota Wisata
Tags: pakettourbukittinggi, paketwisatabukittinggi, citytourbukittinggi
Published: 2021-10-11 08:05:52

Sekali lagi kami ingin membahas tentang indahnya <a href="https://aurorawisata.com/products/detail/33/4_hari_3malam_paket_tour_bukittinggi_padang_minang_kabau_tour/">paket tour bukittinggi</a> kepada anda. Anda tahu kenapa kami merasa ini sangat penting? Perlu anda ketahui bahwa Bukittinggi pernah menjadi pemenang wisata halal di Indonesia pada saat pertama program wisata halal di-launching di Indonesia.

Tidak mengherankan kemudian program <a href="https://aurorawisata.com/products/detail/33/4_hari_3malam_paket_tour_bukittinggi_padang_minang_kabau_tour/">paket tour bukittinggi padang</a> menjadi idola bagi para wisatawan terlebih dari kalangan muslim yang selama ini banyak meragukan kehalalan makanan di Indonesia. Kita sebutlah Jepang, Vietnam dan Korea yang telah sukses meraih prestasi meningkatkan wisatawan dari negara Islam seperti Timur Tengah pasca implementasi wisata halal. Kita belajar dari mereka dan terbukti sukses.

Meskipun terbukti sukses, kita masih mengalami kendala dalam implementasi wisata halal di daerah lain khususnya daerah-daerah wisata yang mayoritas berpenduduk non-muslim. Respon mereka cenderung negatif dan merasa bahwa wisata halal adalah sebuah ancaman bagi mereka. Berbeda dengan <a href="https://aurorawisata.com/products/detail/33/4_hari_3malam_paket_tour_bukittinggi_padang_minang_kabau_tour/">paket wisata bukittinggi</a> yang memang daerahnya didominasi oleh penduduk beragama Islam.

Tingginya permintaan wisata ke Sumatera Barat pasca penerapan wisata halal, tentu saja berdampak positif bagi penduduk setempat selain insan pariwisata seperti hotel, travel agent, restoran, souvenir dan lain-lain. Masyarakat luas akan kebagian efek positif dari implementasi wisata halal ini. Itulah yang dikenal dalam ilmu pemasaran sebagai multi effect dari sebuah terobosan.
How to talk with strangers on Omegle?
Published: 2021-10-11 04:32:56

This is a variant of the Freemium Website of Power, in which more incorrect video conversation is simple and free. Currently, proceed as a conversation for free from outsiders Young Lady Lady or Kid Any Association without exceptional access via this Site Measurers. An irregular video conversation according to strange and charming character is helping on the power site. This site works on an irregular video conversation technology, on which each foreigner can join the correspondence channel as any client. With two business cards webcam business cards, irregular foreigners are one with others on <a href="https://omegle-br.com">omegle brasile</a>.

To use our foundation, enter the date of birth, direction of the meeting, name and phone number and publish the image. Every time you first use the application, Jean will not have the opportunity to determine with which sexual orientation conversation. From now on "two" target are clearly selected until you receive a sufficient number of parts to change the frame. Now you are associated with another client via video. Both meetings can leave each time each time. The site with a comparable name offers more decisions (for example, a region with adult content and a selection of spies to check other), but they do not seem to be connected to any capacity.
The ephemeral miniconf - The roaar flyer !
Tags: perl, raku
Published: 2021-10-11 08:00:52

Earlier today I took my best drawing software (Gimp), gathered all my skills and it's finally time to unveil **the ephemeral miniconf** flyer! 

![The ephemeral miniconf flyer](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5klghup0d0k9l24ekbot.png)

Spread the word with this flyer!