-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6ab252b
commit 1d499bf
Showing
101 changed files
with
1,172 additions
and
778 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
Here's a possible solution to the "Onboarding" challenge on CodinGame using C++: | ||
|
||
```c++ | ||
#include <iostream> | ||
#include <string> | ||
|
||
using namespace std; | ||
|
||
int main() | ||
{ | ||
while (true) { | ||
string enemy1; | ||
int dist1; | ||
string enemy2; | ||
int dist2; | ||
|
||
cin >> enemy1 >> dist1 >> enemy2 >> dist2; | ||
|
||
// Determine which enemy is closer and print its name | ||
if (dist1 < dist2) { | ||
cout << enemy1 << endl; | ||
} else { | ||
cout << enemy2 << endl; | ||
} | ||
} | ||
|
||
return 0; | ||
} | ||
``` | ||
|
||
In this solution, we use a `while` loop to continuously read input from the standard input until the program is terminated. In each iteration of the loop, we read the name and distance of two enemies using `cin`, and then determine which one is closer based on their distances. Finally, we print the name of the closer enemy using `cout`. Note that we use `endl` to add a newline character at the end of each output line. |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
This Go code uses a `for` loop to continuously read input from standard input and print the name of the closest enemy. | ||
|
||
In each iteration of the loop, we use the `Scan` function from the `fmt` package to read in the name and distance of the first enemy into the `enemy1` and `dist1` variables, respectively. We do the same for the second enemy, storing their name and distance in the `enemy2` and `dist2` variables. | ||
|
||
We then compare the distances of the two enemies, and print the name of the one that is closest. The `Scan` function reads input from standard input and automatically parses the input into the specified variable types. | ||
|
||
```go | ||
package main | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
for { | ||
var enemy1, enemy2 string | ||
var dist1, dist2 int | ||
fmt.Scan(&enemy1, &dist1, &enemy2, &dist2) | ||
|
||
if dist1 < dist2 { | ||
fmt.Println(enemy1) | ||
} else { | ||
fmt.Println(enemy2) | ||
} | ||
} | ||
} | ||
``` |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
# Conway Sequence | ||
|
||
The task is to display the last line of a conway sequence. | ||
## Problem Description | ||
|
||
Conway's Sequence is a sequence of numbers, starting with a 1, such that each subsequent number is a description of the previous number. | ||
|
||
To generate a member of Conway's Sequence from the previous member, read off the digits of the previous member, counting the number of digits in groups of the same digit. For example, 1 is read off as "one 1" or 11, 11 is read off as "two 1s" or 21, 21 is read off as "one 2, then one 1" or 1211, and so on. | ||
|
||
Your task is to implement a function that generates the nth member of Conway's Sequence. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Unary | ||
|
||
"Unary" is a beginner-level coding challenge available on the CodinGame platform. In this challenge, the player is given a string of characters representing a unary number, and is asked to convert it to decimal notation. | ||
|
||
A unary number is a number system in which each integer is represented by a corresponding number of symbols or characters. In this challenge, the unary number is represented by a string of the same character, and the value of the number is equal to the length of the string. | ||
|
||
The challenge consists of writing a program that takes as input a string of characters representing a unary number and outputs the corresponding decimal notation. |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Horse Racing Duals | ||
|
||
You have a list of N horses, each with a strength value, represented by an integer. You need to find the minimum difference in strength between two horses out of all possible pairs of horses. In other words, you need to find the two horses with the closest strength values. | ||
|
||
For example, given the following list of horses with their corresponding strength values: | ||
|
||
5 8 9 14 21 | ||
|
||
The minimum difference in strength between two horses is 1, which is the difference between 5 and 8. | ||
|
||
The input for the problem consists of two lines. The first line contains an integer N, the number of horses. The second line contains N space-separated integers, representing the strength values of the N horses. | ||
|
||
The output should be a single integer, the minimum difference in strength between two horses. | ||
|
||
The solution to this problem involves sorting the list of horses in ascending order, and then computing the difference between adjacent horses in the sorted list. The minimum difference is the smallest of these computed differences. |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Here's a possible solution to the "Onboarding" challenge on CodinGame using JavaScript: | ||
|
||
```javascript | ||
while (true) { | ||
const enemy1 = readline(); // name of enemy 1 | ||
const dist1 = parseInt(readline()); // distance to enemy 1 | ||
const enemy2 = readline(); // name of enemy 2 | ||
const dist2 = parseInt(readline()); // distance to enemy 2 | ||
|
||
// Determine which enemy is closer and print its name | ||
if (dist1 < dist2) { | ||
console.log(enemy1); | ||
} else { | ||
console.log(enemy2); | ||
} | ||
} | ||
``` | ||
|
||
In this solution, we use a `while` loop to continuously read input from the standard input until the program is terminated. In each iteration of the loop, we read the name and distance of two enemies, and then determine which one is closer based on their distances. Finally, we print the name of the closer enemy using `console.log()`. |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Sure, here is a modified version of the documentation for `ascii-art.kt` without the license section: | ||
|
||
# ASCII Art | ||
|
||
ASCII Art is a Kotlin program that takes in a string of characters and outputs a stylized version of the input using ASCII art. The program works by converting the input string into a series of characters and then replacing each character with a corresponding ASCII art representation. | ||
|
||
## Usage | ||
|
||
To use ASCII Art, you need to provide a string of characters and a font size. The font size specifies the height of the ASCII art characters in rows. Here is an example usage of the program: | ||
|
||
```kotlin | ||
fun main() { | ||
val input = "HELLO" | ||
val fontSize = 5 | ||
val asciiArt = AsciiArt(input, fontSize) | ||
println(asciiArt) | ||
} | ||
``` | ||
|
||
This will output the ASCII art representation of the string "HELLO" with a font size of 5. |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
|
||
# Conway Sequence | ||
|
||
This is the Kotlin implementation for the "Conway Sequence" puzzle on CodinGame. | ||
|
||
## Problem Description | ||
|
||
Conway's Sequence is a sequence of numbers, starting with a 1, such that each subsequent number is a description of the previous number. | ||
|
||
To generate a member of Conway's Sequence from the previous member, read off the digits of the previous member, counting the number of digits in groups of the same digit. For example, 1 is read off as "one 1" or 11, 11 is read off as "two 1s" or 21, 21 is read off as "one 2, then one 1" or 1211, and so on. | ||
|
||
Your task is to implement a function that generates the nth member of Conway's Sequence. | ||
|
||
## Solution | ||
|
||
The solution to this problem is to generate each member of the sequence, starting from 1, until we reach the nth member. To generate each member, we need to read off the digits of the previous member, counting the number of digits in groups of the same digit. | ||
|
||
We can do this using two nested loops. The outer loop generates each member of the sequence, while the inner loop reads off the digits of the previous member and counts the number of digits in groups of the same digit. |
File renamed without changes.
Oops, something went wrong.