-
-
Notifications
You must be signed in to change notification settings - Fork 27
Added Josephus Problem in Every Language Article #331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
48dce8e
Added Josephus Problem article index.md
AakashBelide 35228ef
Update projects/josephus-problem/index.md
AakashBelide 24932b0
Update projects/josephus-problem/index.md
AakashBelide 74f5c66
Update projects/josephus-problem/index.md
AakashBelide f31e304
Added myself (Belide Aakash) in authors.yml file
AakashBelide 5996e98
Updated index.md based on suggested changes
AakashBelide 5b3ab45
Update projects/josephus-problem/index.md
AakashBelide 7fa6f51
Update projects/josephus-problem/index.md
AakashBelide 3de2631
Added example
AakashBelide 004675d
Update projects/josephus-problem/index.md
AakashBelide File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,44 @@ | ||
--- | ||
title: Josephus Porblem in Every Language | ||
layout: default | ||
date: 2020-10-03 | ||
AakashBelide marked this conversation as resolved.
Show resolved
Hide resolved
|
||
last-modified: 2020-10-03 | ||
AakashBelide marked this conversation as resolved.
Show resolved
Hide resolved
|
||
featured-image: | ||
tags: [recursion] | ||
AakashBelide marked this conversation as resolved.
Show resolved
Hide resolved
|
||
authors: | ||
--- | ||
AakashBelide marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
In this article, we'll tackle the even/odd project, its requirements, and how to test each solution. | ||
|
||
## Description | ||
|
||
There are n people standing in a circle waiting to be executed. The counting out begins at some point in the circle and proceeds around the circle in a fixed direction. In each step, a certain number of people are skipped and the next person is executed. The elimination proceeds around the circle (which is becoming smaller and smaller as the executed people are removed), until only the last person remains, who is given freedom. Given the total number of persons n and a number k which indicates that k-1 persons are skipped and kth person is killed in circle. The task is to choose the place in the initial circle so that you are the last one remaining and so survive. | ||
|
||
## Requirements | ||
|
||
Create a file called "Josephus problem" using the naming convention appropriate for your language of choice. | ||
|
||
Write a sample program which accepts an integer n (total number of people in the circle) and k (k-1 number of people to be skipped to kill next person) and provide the output integer of the last person alive. | ||
|
||
## Testing | ||
|
||
Some tests for your program are: | ||
|
||
|
||
| Description | Input (n, k) | Output | | ||
| :---------- | :---- | :----- | | ||
| No Input | | "Usage: please input the total number of people and number of people to skip." | | ||
| Empty Input | "" | "Usage: please input the total number of people and number of people to skip." | | ||
| Invalid Input: not a number | word | "Usage: please input the total number of people and number of people to skip." | | ||
| Sample Input: 0, 1 (0 people in circle) | 0, 1 | "Usage: please input the total number of people and number of people to skip." | | ||
AakashBelide marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Sample Input: 5, 2 | 5, 2 | 3 | | ||
| Sample Input: 7, 3 | 7, 3 | 4 | | ||
| Sample Input: 41, 4 | 41, 4 | 11 | | ||
|
||
## Articles | ||
|
||
{% include article_list.md collection=site.categories.[name of project] % } | ||
AakashBelide marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Further Reading | ||
|
||
- Fill as needed |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.