teleren/devto huggingface dataset:
1823. Find the Winner of the Circular Game
Tags: php, leetcode, algorithms, programming
Published: 2024-07-08 18:09:43

1823\. Find the Winner of the Circular Game

Medium

There are `n` friends that are playing a game. The friends are sitting in a circle and are numbered from `1` to `n` in **clockwise order**. More formally, moving clockwise from the <code>i<sup>th</sup></code> friend brings you to the <code>(i+1)<sup>th</sup></code> friend for <code>1 <= i < n</code>, and moving clockwise from the <code>n<sup>th</sup></code> friend brings you to the <code>1<sup>st</sup></code> friend.

The rules of the game are as follows:

1. **Start** at the <code>1<sup>st</sup></code> friend.
2. Count the next `k` friends in the clockwise direction **including** the friend you started at. The counting wraps around the circle and may count some friends more than once.
3. The last friend you counted leaves the circle and loses the game.
4. If there is still more than one friend in the circle, go back to step `2` **starting** from the friend **immediately clockwise** of the friend who just lost and repeat.
5. Else, the last friend in the circle wins the game.

Given the number of friends, `n`, and an integer `k`, return _the winner of the game_.


**Example 1:**

![ic234-q2-ex11](https://assets.leetcode.com/uploads/2021/03/25/ic234-q2-ex11.png)

- **Input:** n = 5, k = 2
- **Output:** 3
- **Explanation:** Here are the steps of the game:
  1. Start at friend 1.
  2. Count 2 friends clockwise, which are friends 1 and 2.
  3. Friend 2 leaves the circle. Next start is friend 3.
  4. Count 2 friends clockwise, which are friends 3 and 4.
  5. Friend 4 leaves the circle. Next start is friend 5.
  6. Count 2 friends clockwise, which are friends 5 and 1.
  7. Friend 1 leaves the circle. Next start is friend 3.
  8. Count 2 friends clockwise, which are friends 3 and 5.
  9. Friend 5 leaves the circle. Only friend 3 is left, so they are the winner.

**Example 2:**

- **Input:** n = 6, k = 5
- **Output:** 1
- **Explanation:** The friends leave in this order: 5, 4, 6, 2, 3. The winner is friend 1.

**Constraints:**

- `1 <= k <= n <= 500`


**Follow up:**

Could you solve this problem in linear time with constant space?


**Solution:**

```
class Solution {

    /**
     * @param Integer $n
     * @param Integer $k
     * @return Integer
     */
    function findTheWinner($n, $k) {
        $winner = 0;
        for ($i = 1; $i <= $n; $i++) {
            $winner = ($winner + $k) % $i;
        }
        return $winner + 1; // +1 because array index starts from 0
    }
}
```



**Contact Links**

If you found this series helpful, please consider giving the **[repository](https://github.com/mah-shamim/leet-code-in-php)** a star on GitHub or sharing the post on your favorite social networks 😍. Your support would mean a lot to me!

If you want more helpful content like this, feel free to follow me:

- **[LinkedIn](https://www.linkedin.com/in/arifulhaque/)**
- **[GitHub](https://github.com/mah-shamim)**
3 Amazing Productivity Apps for Linux
Tags: linux, ubuntu, productivity, beginners
Published: 2024-07-08 18:59:20

I use Ubuntu 24.04 as my daily driver on my main laptop and these are some of the best native Linux apps that I use on a daily basis.

## 1. Iotas
Iotas is a note taking application for Linux distributions that is available in the Ubuntu repositories or as a Flatpak that you can download from Flathub.

It's the Linux equivalent of Apple Notes for me, it doesn't have all of the features but is enough for me. Iotas allows you to write in plain text as well as markdown and offers an editing and viewing mode to see how your text looks.

Iotas allows you to categorize your notes using category which you can add to a note by right clicking on it and Iotas will create a new folder and store the note in it. 

> Iotas also offers syncing to Nextcloud but I haven't used it since I don't use Nextcloud.


![Screenshot of Iotas on Flathub](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n6aycza0muee6j68ma5r.png)

## 2. Foliate
Foliate is an epub reader for Linux distributions available as a Flatpak and in some distro's repositories as well. Foliate offers a great reading experience with multiple viewing options, themes and font options so that you can customize your reading experience.

Foliate is a great epub reader but is not limited to only E-pub files, Foliate can open Mobipocket, Kindle, PDFs, and CBZ files that makes it a all-one-solution for reading books and files. 

Foliate's features don't end there, it also has bookmarks, dictionary lookup, progress slider with chapter marks and much more.


![Screenshot of Foliate on Flathub](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lhh24bjf9jsa4xcjssca.png)

## 3. Only office
Ubuntu and other Linux distributions comes with an office suite pre-installed which is known as LibreOffice. Although it's a solid option but it's not a replacement for Microsoft Office 365 for me.

I use Apache Only office as my desktop office suite of choice, It has _Waaay_ better compatibility with office 365 documents the Libreoffice and also has a nice PDF editor as well.

Only office is available on Windows and Mac as well and is not a Linux only application so you can try it as well on your computer and see if its worth switching over from office 365.


![Screenshot of Only office on Flathub](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2mwch5mnx53e8iiaz58l.png)

---

Which of these apps you liked the most? Share your thoughts in the comments and let me know how you plan to use any of them yourself. Don't forget to like and share if you found this helpful!
Showing more Article info on Daily.dev
Published: 2024-07-08 18:31:50

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/08up666l3xy6cjmtm404.png)

Daily.dev is a very good extension that helps us aggregate news from several sources.

When browsing news, I usually scan the `Title -> Thumbnail -> Description`. However, the current view of Daily.dev has only `Title` and `Thumbnail` in Grid view and only `Title` in Listing view. This requires me to click on an article to read more in a popup, which consumes more reading time.

Fortunately, Daily.dev is open source, so we can submit feature requests or even customize the design to suit our needs.

In this case, I have submitted a feature request on the [dailydev/apps](github.com/dailydotdev/apps) repository and also implemented a new design that can serve my needs. You can review my pull request here: [pull/2060](https://github.com/dailydotdev/apps/pull/2060).

They have mentioned that they need to pass this request to the Design team before reviewing my merge request or implementing a new UI.

In the meantime, you can pull my request, build it, and install it locally using these easy steps:

### Step 1: Clone my code
```bash
git clone --branch feat/show-more-metadata git@github.com:huantt/daily-dot-dev-apps.git
```

### Step 2: Build
```shell
pnpm install

cd packages/extension

pnpm run build:chrome
```

The output will be located at `packages/extension/dist/chrome`.

### Step 3: Install
- Open Chrome.
- Click the Extension button > Manage Extensions. Alternatively, you can enter the following URL directly: [chrome://extensions](chrome://extensions/).

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9kv6vmzkhdq116iv3nrp.png)

- Enable `Developer Mode`.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9dnk3z5gwvpedhgblcfp.png)

- Click on `Load unpacked`.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dl2aj7i12nnkl5zkyy68.png)

- Point to `packages/extension/dist/chrome`.

Open a new tab, and you will see that all articles in Grid view or Listing View now have a Title, Description, and Thumbnail.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sq18fyzsadi5rrm4uls2.png)

I hope that it's helpful for you, and I also hope that Daily.dev releases a new UI soon.
{% github: github.com/huantt/daily-dot-dev-apps %}
Colecciones y bases de dinámicas en base a campos de tipo fecha
Published: 2024-07-08 19:38:13

En algunas ocasiones deseamos generar bases de datos y colecciones dinámicas en base a una fecha.

Por ejemplo generar una base datos para cada año y las colecciones por mes y por cada empresa. De manera que contamos con una mejor clasificación de los documentos , lo que genera un mejor desempeño de la aplicación al distribuir los documentos en varias bases de datos y colecciones.

En el ejemplo hipotético asuma que cuenta con un modelo como el siguiente:

```
@Entity 
public class Venta{
  @Id(autogeneratedActive =AutogeneratedActive.ON )
  private Long idventa;

  @Column
  private Long idempresa;

  @Column
  private Double total;


}

```


Ejemplo:

* Bases de dato: **ventas_2024db**

Colecciones:  
```
      transaccion_1_enero  
      transaccion_2_enero  
      transaccion_1_febrero  
      transaccion_2_febrero  
```

* Bases de dato: **ventas_2024db**

Colecciones:  
```
      transaccion_1_enero  
      transaccion_2_enero  
      transaccion_1_febrero  
      transaccion_2_febrero  
```
Data Science? Never Heard Of It.
Tags: datascience, beginners
Published: 2024-07-12 13:00:00

So, the truth is, last year when I first picked up Data Science, I had no idea what it was.

I always wanted to take programming more seriously. I tried a little HTML and CSS a few years back but stopped and I did some simple robotics coding during secondary (high) school.

Anyway, last year I had some time on my hands, and my Aunt suggested I take this course my cousins did. She couldn’t remember the specifics, but she knew they were teaching Python.

We contacted them, and that was the first time I heard about Data Science. So, what is Data Science, and should you learn it?

I like to define it as “finding the meaning behind data”. Whether you should learn it might depend on the kind of person you are.

Although I’m sure there are other branches when it comes to programming, I mainly consider these four when someone tells me that they are interested in getting into tech, specifically programming: Data Science, Web/Software Development (yes, I group them together — sue me), Game development and Cybersecurity.

Usually it’s always Web/Software Dev that they are thinking about, but I always try to mention both Data Science and Web/Software dev so they at least have another option to consider.

So, which should you pick?

First, ask yourself: are you An Explorer or A Builder?

An explorer loves diving into the unknown, uncovering hidden insights, and searching for answers in uncharted territories. If that sounds like you, then you might be drawn to Data Science, where you’ll analyze data to discover patterns and meanings.

A builder, on the other hand, thrives on creating and constructing. Whether you're starting from scratch, collaborating on existing projects, or finding solutions on Stack Overflow, you love bringing ideas to life. If this resonates with you, then Web/Software Development might be your ideal path.

I use the word “might” because it’s not set in stone. Personally, I have interests in all four branches, although some more than others. I’m currently focusing on Data Science, but I do plan on exploring Web/Software Dev later down the line.

This is tech. Don’t be afraid to pivot and explore. There’s so much of it to see.

Stay Curious.
Trying Kotlin Multiplatform for the First Time: Step by Step Building an App with KMP
Tags: kotlin, kmp, android, mobile
Published: 2024-07-08 19:06:27

After getting inspired by KotlinConf, I decided to try Kotlin Multiplatform (KMP) for the first time and build an app with this technology. KMP is a technology developed by JetBrains that allows developers to write code together for various platforms using the Kotlin programming language. The main goal is to reduce code duplication and increase productivity by sharing business logic across multiple platforms, while still providing flexibility for platform-specific implementations where needed.

### Key Aspects of Multiplatform Kotlin:

1. **Code Sharing:** You can write common code once and use it on different platforms such as Android, iOS, web, and desktop.
   
2. **Platform-Specific Code:** KMP allows you to write platform-specific code if needed, providing optimal flexibility and performance.

3. **Supported Platforms:** KMP supports a wide range of platforms including Android, iOS, JVM, JavaScript, and native desktop applications.

4. **Gradle-based:** KMP projects use Gradle for build automation, making it easy to manage dependencies and build processes.

5. **Interoperability:** Multiplatform Kotlin code can easily interact with existing platform-specific code, such as Java for Android and Swift for iOS.

### Benefits of Using Multiplatform Kotlin:

1. **Reduced Development Time:** By sharing code across multiple platforms, you can significantly reduce development and maintenance time.

2. **Consistency:** Shared business logic ensures consistency across various platform-specific applications.

3. **Flexibility:** You can still use platform-specific libraries and frameworks if needed.

4. **Kotlin features:** You can use modern features of the Kotlin language on all platforms.

5. **Growing Ecosystem:** There are more and more multiplatform libraries available for common tasks.

### Getting to Know Multiplatform Kotlin

In this first step, I started by understanding the basic concepts of KMP and its advantages. I learned how KMP enables efficient application development by reducing code duplication and ensuring consistency across multiple platforms. KMP provides flexibility in writing platform-specific code

This is the first chapter of my journey to learn Multiplatform Kotlin. In the next article, I'll talk about how to set up your development environment with KMP, including practical steps on using Gradle for build automation and dependency management and Building an App with KMP. 

Be sure to follow next topics: "Setting Up Your Development Environment," where we'll go into more detail about how to get started with your KMP project and set up all the necessary tools for multiplatform development. Thank you for reading, and I hope this article about learn Kotlin Multiplatform (KMP) for the first time and build an app gives you a clear picture of the potential of Kotlin Multiplatform in app development. Leave question and Stay tuned for the next discussion!
Trying Kotlin Multiplatform for the First Time: Step by Step Building an App with KMP
Tags: kotlin, kmp, android, mobile
Published: 2024-07-08 19:14:17

After getting inspired by KotlinConf, I decided to try Kotlin Multiplatform (KMP) for the first time and build an app with this technology. KMP is a technology developed by JetBrains that allows developers to write code together for various platforms using the Kotlin programming language. The main goal is to reduce code duplication and increase productivity by sharing business logic across multiple platforms, while still providing flexibility for platform-specific implementations where needed.

### Key Aspects of Multiplatform Kotlin:

1. **Code Sharing:** You can write common code once and use it on different platforms such as Android, iOS, web, and desktop.
   
2. **Platform-Specific Code:** KMP allows you to write platform-specific code if needed, providing optimal flexibility and performance.

3. **Supported Platforms:** KMP supports a wide range of platforms including Android, iOS, JVM, JavaScript, and native desktop applications.

4. **Gradle-based:** KMP projects use Gradle for build automation, making it easy to manage dependencies and build processes.

5. **Interoperability:** Multiplatform Kotlin code can easily interact with existing platform-specific code, such as Java for Android and Swift for iOS.

### Benefits of Using Multiplatform Kotlin:

1. **Reduced Development Time:** By sharing code across multiple platforms, you can significantly reduce development and maintenance time.

2. **Consistency:** Shared business logic ensures consistency across various platform-specific applications.

3. **Flexibility:** You can still use platform-specific libraries and frameworks if needed.

4. **Kotlin features:** You can use modern features of the Kotlin language on all platforms.

5. **Growing Ecosystem:** There are more and more multiplatform libraries available for common tasks.

### Getting to Know Multiplatform Kotlin

In this first step, I started by understanding the basic concepts of KMP and its advantages. I learned how KMP enables efficient application development by reducing code duplication and ensuring consistency across multiple platforms. KMP provides flexibility in writing platform-specific code

This is the first chapter of my journey to learn Multiplatform Kotlin. In the next article, I'll talk about how to set up your development environment with KMP, including practical steps on using Gradle for build automation and dependency management and Building an App with KMP. 

Be sure to follow next topics: "Setting Up Your Development Environment," where we'll go into more detail about how to get started with your KMP project and set up all the necessary tools for multiplatform development. Thank you for reading, and I hope this article about learn Kotlin Multiplatform (KMP) for the first time and build an app gives you a clear picture of the potential of Kotlin Multiplatform in app development. Stay tuned for the next discussion!
The Best 5 Free IP Geolocation APIs for Programmers
Tags: api, geolocation, programmer
Published: 2024-07-08 19:15:28

Free IP geolocation APIs play a crucial role in enabling developers to integrate location-based services into their applications effortlessly. These APIs provide accurate geographical information based on IP addresses, making them invaluable for a variety of applications, from targeted advertising to fraud prevention. Here's a look at some of the top free IP geolocation APIs that developers can leverage:

## 1. IPstack
IPstack offers a comprehensive **[free IP geolocation API](https://ipstack.com/product)** with features like timezone information, currency details, and even security insights. It's widely used for e-commerce applications and content personalization due to its rich data set and reliability.

## 2. GeoJS
GeoJS provides a straightforward geolocation API that developers can use without any registration or API keys. It offers basic geolocation data like country and region code, making it ideal for quick integrations where simplicity is key.

## 3. IP-API
IP-API is renowned for its accuracy and reliability in IP geolocation lookup. It supports multiple formats including JSON, CSV, XML, and plain text, making it versatile for different integration needs. Its free tier offers sufficient requests per minute, suitable for moderate to heavy usage.

## 4. FreeGeoIP
FreeGeoIP is another popular free geolocation API that provides country, region, city, and ISP information based on IP addresses. It's known for its ease of use and quick response times, making it ideal for applications requiring real-time location data.

## 5. IPinfo
IPinfo offers a robust free IP geolocation API that provides details such as city, region, country, and even company data associated with an IP address. Developers appreciate its simplicity and comprehensive documentation, making integration straightforward across various platforms.

## Choosing the Right API for Your Project
When selecting a free **[IP geolocation API](https://ipstack.com/documentation)**, consider factors such as data accuracy, rate limits, ease of integration, and additional features like timezone or currency information. Assess your project's specific needs and choose an API that aligns best with your technical requirements and scalability goals.

## Conclusion
Free IP geolocation APIs empower developers to enhance their applications with location-based services without the overhead costs. Each of the APIs mentioned—IPinfo, GeoJS, IP-API, FreeGeoIP, and IPstack—offers unique features and benefits, catering to diverse development needs. Whether you're building a mobile app, e-commerce platform, or analytics tool, integrating a reliable geolocation API can significantly enrich user experience and operational efficiency. Explore these APIs, experiment with their capabilities, and choose the one that best fits your project's demands for accurate and timely geolocation data.
Why Jenkins is still MVP among CI/CD tools?
Tags: devops, cicd, jenkins
Published: 2024-07-08 19:20:53


Jenkins is a powerful, open-source automation server used for continuous integration and continuous delivery. It allows developers to automate the building, testing, and deployment of applications, facilitating rapid development cycles. Jenkins supports a vast array of plugins, making it highly customizable and adaptable to various development environments and workflows. Its strong community support ensures continuous improvements and updates, keeping Jenkins relevant and robust in the ever-evolving DevOps landscape.

Other top CI/CD tools include CircleCI, GitLab CI, TeamCity, and Bamboo. CircleCI is known for its ease of use and seamless integration with GitHub, making it a favorite among small to medium-sized projects. GitLab CI, part of the GitLab ecosystem, offers integrated version control and CI/CD capabilities, providing a cohesive environment for development. TeamCity, developed by JetBrains, is known for its powerful feature set and extensive integrations, particularly beneficial for large enterprise environments. Bamboo, by Atlassian, integrates well with other Atlassian products like Jira and Bitbucket, making it ideal for organizations already using Atlassian's suite of tools.

Jenkins' standout features include its vast plugin ecosystem, which offers unparalleled flexibility and extensibility. It supports distributed builds across multiple machines, allowing for efficient resource utilization and faster build times. Jenkins' pipeline-as-code capability, using Groovy scripts, provides powerful automation and version control for CI/CD pipelines. Additionally, its strong community and comprehensive documentation make troubleshooting and customization more accessible.

When comparing the main advantages between these solutions, Jenkins' flexibility and extensive plugin library are significant strengths, allowing it to cater to diverse project needs and environments. While CircleCI and GitLab CI excel in user-friendliness and integration with specific platforms, Jenkins' ability to adapt to various workflows and environments makes it a more versatile choice. TeamCity and Bamboo offer robust enterprise features and integrations, but Jenkins' open-source nature and community-driven development keep it at the forefront of innovation, ensuring it remains the MVP among CI/CD tools.

mcieciora