Add files via upload

This commit is contained in:
Dom Sec 2023-03-23 21:38:35 -04:00 committed by GitHub
parent 1179e569ee
commit 1720b662e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 1188 additions and 0 deletions

View File

@ -0,0 +1,28 @@
# Magic Sigil Generator
A magic sigil is a glyph which represents a desire one wishes to manifest in their lives. There are many ways to create a sigil, but the most common is to write out a specific desire (e.g. "I HAVE WONDERFUL FRIENDS WHO LOVE ME"), remove all vowels, remove any duplicate letters (keeping the last occurence), and then design a glyph from what remains.
Using the sentence above as an example, we would remove duplicate letters:
```text
AUFRINDSWHLOVME
```
And then remove all vowels, leaving us with:
```text
FRNDSWHLVM
```
Create a function that takes a string and removes its vowels and duplicate letters. The returned string should not contain any spaces and be in uppercase.
## Examples
```text
sigilize("i am healthy") ➞ "MLTHY"
sigilize("I FOUND MY SOULMATE") ➞ "FNDYSLMT"
sigilize("I have a job I enjoy and it pays well") ➞ "HVBJNDTPYSWL"
```
## Notes
- For duplicate letters the last one is kept.

View File

@ -0,0 +1,42 @@
# Create a Dice Roller
I love playing D&D with my friends, and my favorite part is creating character sheets (my DM is notorious for killing us all off by level 3 or so). One major part of making character sheets is rolling the character's stats. Sadly, I have lost all my dice, so I'm asking for your help to make a dice roller for me to use!
## Input description
Your input will contain one array/vector of strings, where each entry will be in the form of "NdM"; for example:
```text
["3d6", "4d12", "1d10", "5d4"]
```
If you've ever played D&D you probably recognize those, but for the rest of you, this is what those mean:
The first number is the number of dice to roll, the d just means "dice", it's just used to split up the two numbers, and the second number is how many sides the dice have. So the above example of "3d6" means "roll 3 6-sided dice". Also, just in case you didn't know, in D&D, not all the dice we roll are the normal cubes. A d6 is a cube, because it's a 6-sided die, but a d20 has twenty sides, so it looks a lot closer to a ball than a cube.
The first number, the number of dice to roll, can be any integer between 1 and 100, inclusive.
The second number, the number of sides of the dice, can be any integer between 2 and 100, inclusive.
## Output description
You should output the sum of all the rolls of that specified die, each on their own line. so if your input is "3d6", the output should look something like:
```text
14: 6 3 5
```
You rolled 3 6-sided dice, and they added up to 14 and you print out the result of each roll on the same line.
## Notes/Hints
A dice roll is basically the same as picking a random number between 1 and 6 (or 12, or 20, or however many sides the die has). You should use some way of randomly selecting a number within a range based off of your input. Many common languages have random number generators available, but at least a few of them will give the same "random" numbers every time you use the program. In my opinion that's not very random. If you run your code 3+ times with the same inputs and it gives the same outputs, that wouldn't be super useful for a game of D&D, would it? If that happens with your code, try to find a way around that. I'm guessing for some of the newer folks, this might be one of the trickier parts to get correct.
Don't just multiply your roll by the number of dice, please. I don't know if any of you were thinking about doing that, but I was. The problem is that if you do that, it eliminates a lot of possible values. For example, there's no way to roll 14 from 3d6 if you just roll it once and multiply by 3. Setting up a loop to roll each die is probably your best bet here.
## Examples
```text
14: 6 3 5
22: 10 7 1 4
9: 9
11: 3 2 2 1 3
```

View File

@ -0,0 +1,16 @@
# Perfectly balanced
Given a string containing only lowercase letters, find whether every letter that appears in the string appears the same number of times. Don't forget to handle the empty string ("") correctly!
## Examples
```text
balanced_bonus("xxxyyyzzz") => true
balanced_bonus("abccbaabccba") => true
balanced_bonus("xxxyyyzzzz") => false
balanced_bonus("abcdefghijklmnopqrstuvwxyz") => true
balanced_bonus("pqq") => false
balanced_bonus("fdedfdeffeddefeeeefddf") => false
balanced_bonus("www") => true
balanced_bonus("x") => true
balanced_bonus("") => true
```

View File

@ -0,0 +1,35 @@
# A Game of Threes
Back in middle school, I had a peculiar way of dealing with super boring classes. I would take my handy pocket calculator and play a "Game of Threes". Here's how you play it:
First, you mash in a random large number to start with. Then, repeatedly do the following:
- If the number is divisible by 3, divide it by 3.
- If it's not, either add 1 or subtract 1 (to make it divisible by 3), then divide it by 3.
The game stops when you reach "1".
While the game was originally a race against myself in order to hone quick math reflexes, it also poses an opportunity for some interesting programming challenges. Today, the challenge is to create a program that "plays" the Game of Threes.
## Challenge Description
The input is a single number: the number at which the game starts. Write a program that plays the Threes game, and outputs a valid sequence of steps you need to take to get to 1. Each step should be output as the number you start at, followed by either -1 or 1 (if you are adding/subtracting 1 before dividing), or 0 (if you are just dividing). The last line should simply be 1.
## Input Description
The input is a single number: the number at which the game starts.
```text
100
```
## Output Description
The output is a list of valid steps that must be taken to play the game. Each step is represented by the number you start at, followed by either -1 or 1 (if you are adding/subtracting 1 before dividing), or 0 (if you are just dividing). The last line should simply be 1.
```text
100 -1
33 0
11 1
4 -1
1
```

View File

@ -0,0 +1,28 @@
# Write a Web Crawler
Most of us are familiar with web spiders and crawlers like GoogleBot - they visit a web page, index content there, and then visit outgoing links from that page. Crawlers are an interesting technology with continuing development.
Web crawlers marry queuing and HTML parsing and form the basis of search engines etc. Writing a simple crawler is a good exercise in putting a few things together. Writing a well behaved crawler is another step up.
For this challenge you may use any single shot web client you wish, e.g. Python's httplib or any of a number of libcurl bindings; you may NOT use a crawling library like Mechanize or whatnot. You may use an HTML parsing library like BeautifulSoup; you may NOT use a headless browser like PhantomJS. The purpose of this challenge is to tie together fetching a page, reassembling links, discovering links and assembling them, adding them to a queue, managing the depth of the queue, and visiting them in some reasonable order - while avoiding duplicate visits.
Your crawler MUST support the following features:
- HTTP/1.1 client behaviors
- GET requests are the only method you must support
- Parse all links presented in HTML - anchors, images, scripts, etc
- Do not visit the same link more than once per session
Optional features include HTTPS support, support for robots.txt, support for domains to which you restrict the crawler, and storing results (for example how wget does so).
Be careful with what you crawl! Don't get yourself banned from the Internet. I highly suggest you crawl a local server you control as you may trigger rate limits and other mechanisms to identify unwanted visitors.
## Input Description
Take at least two parameters:
- a starting (seed) URL
- a maximum depth to recurse to (e.g. "1" would be fetch the HTML page and all resources like images and script associated with it but don't visit any outgoing anchor links; a depth of "2" would visit the anchor links found on that first page only, etc ...)
## Output Description
Array/vector of DISCOVERED URLs.

View File

@ -0,0 +1,46 @@
# Funny plant
Scientist have discovered a new plant. The fruit of the plant can feed 1 person for a whole week and best of all, the plant never dies. Fruits needs 1 week to grow, so each weak you can harvest it fruits. Also the plant gives 1 fruit more than the week before and to get more plants you need to plant a fruit.
Now you need to calculate after how many weeks, you can support a group of x people, given y fruits to start with.
## Input Description
The input gives you 2 positive integers x and y, being x the number of people needed to be fed and y the number of fruits you start with.
## Output Description
The number of weeks before you can feed the entire group of people.
## Explanation
Here you have a table that shows the growth when starting with 1 fruit. It shows when the plant came into existence (is planted) and how may fruit it bears each week:
```text
Plant 1 2 3 4 5 6 7 8 9 10 11 12 13 Total # of fruits in a harvest
Week
1 0 - - - - - - - - - - - - 0
2 1 0 - - - - - - - - - - - 1
3 2 1 0 0 0 - - - - - - - - 3
4 3 2 1 1 1 0 0 0 0 0 0 0 0 8
5 4 3 2 2 2 1 1 1 1 1 1 1 1 21
```
At week 1 we have 1 plant giving 0 fruits, because it has just been planted.
When week 2 comes along we have 1 plant that gives off a fruit and then we use that fruit to plant plant 2.
Then in week 3 we have 2 fruits from plant 1, 1 from plant 2, so we can plant 3 new plants.
## Examples
```text
input: 200, 15
output: 5
input: 50000, 1
output: 14
input: 150000, 250
output: 9
```

View File

@ -0,0 +1,81 @@
# The rabbit problem
Rabbits are known for their fast breeding, but how soon will they dominate the earth?
Starting with a small population of male and female rabbits we have to figure out how long it will take for them to outnumber humans 2:1.
Every month a fertile female will have 14 offspring (5 males and 9 females).
A female rabbit is fertile when it has reached the age of 4 months, they never stop being fertile.
Rabbits die at the age of 8 years (96 months).
## Input Description
You will be given a list of numbers as following:
```text
Male_rabbits Female_rabbits Rabbits_needed_alive
```
The initial rabbits will always be 2 months old and fertile females will always produce 14 offspring (5 male, 9 female)
Every month that passes things should be done in this order:
Fertile female reproduce (so 7 year & 11 months old will reproduce)
rabbits age (except newborn) (and rabbits reaching 8 years will die, the 7 year & 11 months old will die)
fx:
```text
2 4 1000000000
```
## Output Description
You output how many months it took for world domination.
## Example
Looking just at the female population:
```text
we start with 1 female with the given starting age of 2 months
the index is their age (0-index is 0 months old)
[ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0] Month 0
[ 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0] Month 1
[ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0] Month 2
[ 9, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0] Month 3
[ 9, 9, 0, 0, 0, 0, 1, 0, 0, 0, 0] Month 4
[ 9, 9, 9, 0, 0, 0, 0, 1, 0, 0, 0] Month 5
[ 9, 9, 9, 9, 0, 0, 0, 0, 1, 0, 0] Month 6
[ 9, 9, 9, 9, 9, 0, 0, 0, 0, 1, 0] Month 7
[90, 9, 9, 9, 9, 9, 0, 0, 0, 0, 1] Month 8
```
## For inspiration
[The rabbit problem](http://go-here.nl/the-rabbit-problem.html)
**Challenge input(s)**
```text
2 4 1000000000
```
```text
2 4 15000000000
```
**Challenge output(s)**
```text
32
```
```text
36
```
**Bonus**
Tell how many dead rabbits there are when they dominate earth.

View File

@ -0,0 +1,28 @@
# First Recurring Character
Write a program that outputs the first recurring character in a string.
## Input Description
A string of alphabetical characters. Example:
```text
ABCDEBC
```
## Output Description
The first recurring character from the input. From the above example:
```text
B
```
## Note
What is exactly the definition of 'first recurring character'?
- It is the character that recurs first (B in the series ABBA)
## Examples
```text
ABCDEBC ➞ B
ABBA ➞ B
```

View File

@ -0,0 +1,20 @@
# ISBN Validator
ISBN's (International Standard Book Numbers) are identifiers for books. Given the correct sequence of digits, one book can be identified out of millions of others thanks to this ISBN. But when is an ISBN not just a random slurry of digits? That's for you to find out.
## Rules
Given the following constraints of the ISBN number, you should write a function that can return True if a number is a valid ISBN and False otherwise.
An ISBN is a ten digit code which identifies a book. The first nine digits represent the book and the last digit is used to make sure the ISBN is correct.
To verify an ISBN you :
- obtain the sum of 10 times the first digit, 9 times the second digit, 8 times the third digit... all the way till you add 1 times the last digit. If the sum leaves no remainder when divided by 11 the code is a valid ISBN.
For example :
0-7475-3269-9 is Valid, because
(10 * 0) + (9 * 7) + (8 * 4) + (7 * 7) + (6 * 5) + (5 * 3) + (4 * 2) + (3 * 6) + (2 * 9) + (1 * 9) = 242 which can be divided by 11 and have no remainder.
For the cases where the last digit has to equal to ten, the last digit is written as X. For example 156881111X.

View File

@ -0,0 +1,11 @@
# ISBN Generator
ISBN's (International Standard Book Numbers) are identifiers for books. Given the correct sequence of digits, one book can be identified out of millions of others thanks to this ISBN.
**Objective**
Write an ISBN generator.
## Rules
- Follow the ISBN rules of **day-65 challenge** (**ISBN Validator**), **use this validator** to check the generated identifiers on **your tests**.

View File

@ -0,0 +1,191 @@
# Color maze
Today we are going to do something colorfull and amazing. Yes it is a color maze :D (you can downvote me now, it was totally worth it).
You traverse a color by following a sequence of colors. For example this maze can be solved by the sequence 'orange -> green':
<p align="center">
<img src="../../assets/maze_color_1.png" alt="maze color">
</p>
Then you would have something like this (paint skills):
<p align="center">
<img src="../../assets/maze_color_2.png" alt="maze color solution">
</p>
For the mazes you always pick a spot on the bottom, in the starting color and try to get to the first row. Once you reach the first row, you are out of the maze. The sequence does not have to be complete.
You can move horizontally and vertically, but not diagonally. It is also allowed to move on the same node more then once.
## Objective
Write a function with **two input parameters**:
- Sequence of colors to follow as a array/vector of chars
- The maze as a array/vector of chars
## Output
The path in the maze as coordinates x, y.
## Example
```text
COLOR SEQUENCE: R W
MAZE:
[
R O G
W R W
G O R
O R W
]
SOLUTION:
(1, 3)
(2, 3)
(2, 2)
(2, 1)
(1, 1)
(0, 1)
(0, 0)
--------------------------------------------------------------------------------
COLOR SEQUENCE: R W
MAZE:
[
R O G
W R W
G O O
O R W
]
SOLUTION: NO SOLUTION!
--------------------------------------------------------------------------------
COLOR SEQUENCE: O G
MAZE:
[
C O R O Y
O R V G R
G O G O G
Y G B Y G
R O R B R
]
SOLUTION:
(1, 4)
(1, 3)
(1, 2)
(2, 2)
(3, 2)
(3, 1)
(3, 0)
--------------------------------------------------------------------------------
COLOR SEQUENCE: O G
MAZE:
[
B O R O Y
O R B G R
B O G O Y
Y G B Y G
R O R B R
]
SOLUTION:
(1, 4)
(1, 3)
(1, 2)
(2, 2)
(3, 2)
(3, 1)
(3, 0)
--------------------------------------------------------------------------------
COLOR SEQUENCE: O G
MAZE:
[
G O R O Y
O R B C R
G O G O G
Y G B Y G
R O R B R
]
SOLUTION:
(1, 4)
(1, 3)
(1, 2)
(0, 2)
(0, 1)
(0, 0)
--------------------------------------------------------------------------------
COLOR SEQUENCE: R O Y P O
MAZE:
[
R R B R R R B P Y G P B B B G P B P P R
B G Y P R P Y Y O R Y P P Y Y R R R P P
B P G R O P Y G R Y Y G P O R Y P B O O
R B B O R P Y O O Y R P B R G R B G P G
R P Y G G G P Y P Y O G B O R Y P B Y O
O R B G B Y B P G R P Y R O G Y G Y R P
B G O O O G B B R O Y Y Y Y P B Y Y G G
P P G B O P Y G B R O G B G R O Y R B R
Y Y P P R B Y B P O O G P Y R P P Y R Y
P O O B B B G O Y G O P B G Y R R Y R B
P P Y R B O O R O R Y B G B G O O P B Y
B B R G Y G P Y G P R R P Y G O O Y R R
O G R Y B P Y O P B R Y B G P G O O B P
R Y G P G G O R Y O O G R G P P Y P B G
P Y P R O O R O Y R P O R Y P Y B B Y R
O Y P G R P R G P O B B R B O B Y Y B P
B Y Y P O Y O Y O R B R G G Y G R G Y G
Y B Y Y G B R R O B O P P O B O R R R P
P O O O P Y G G Y P O G P O B G P R P B
R B B R R R R B B B Y O B G P G G O O Y
]
SOLUTION:
(3, 19)
(3, 18)
(3, 17)
(3, 16)
(4, 16)
(4, 15)
(4, 16)
(5, 16)
(5, 15)
(5, 14)
(6, 14)
(6, 13)
(6, 12)
(6, 11)
(6, 10)
(7, 10)
(7, 9)
(8, 9)
(8, 8)
(9, 8)
(9, 7)
(9, 6)
(10, 6)
(10, 5)
(10, 4)
(10, 3)
(10, 4)
(9, 4)
(8, 4)
(8, 3)
(8, 2)
(8, 1)
(8, 0)
```

View File

@ -0,0 +1,45 @@
# Clarence the Slow Typist
Clarence is a data entry clerk who works at an internet service provider. His job is to manually enter the IP addresses of all of the ISP's customers into the database. He does this using a keypad which has the following layout:
```text
1 2 3
4 5 6
7 8 9
. 0
```
The distance between the centre of horizontally or vertically adjacent keys is exactly one centimetre. For instance, the distance between the centres of 3 and 9 would be two centimetres. The distance between the centres of 3 and 5 would be sqrt 2cm. The Pythagoras theorem is sufficient to calculate the distance between any two keys.
Clarence, as you might expect from one who works in an ISP, uses a very slow and inefficient system of typing. He uses a single finger and searches for the key, and then moves his finger to the key, then presses it, and repeats for all of the digits in the number. You might know of this style as the "eagle search system" since the finger searches above the keyboard for the correct key before plunging down for the keypress, like an eagle plunging down for a kill.
For example, here is how Clarence would type out the number 7851:
He starts his finger at 7 and pushes the key.
He moves his finger to the right 1cm to 8 and pushes the key.
He moves his finger upwards 1cm to 5 and pushes the key.
He moves his finger diagonally upwards and left sqrt 2cm to 1 and pushes the key.
Therefore the total distance that Clarence moved his finger to type in 7851 is 1 + 1 + sqrt 2 which is about 3.41cm.
## Objective
Your task is to write a program that calculates the distance Clarence must move his finger to type in arbitrary IP addresses.
## Input
Input is a string that will be in the form
**().().().()**
where each () is an integer in the range 0 - 999. This represents the IP address that Clarence must type in. An example input might be:
**219.45.143.143**
I would also like to point out that inputs such as **0.42.42.42** or **999.999.999.999** are still valid inputs, despite the fact that they are invalid IP addresses. **So you don't need to include any IP address verification code in your program**.
## Output
Output the distance that Clarence must move his finger in order to type in the specified IP address.

View File

@ -0,0 +1,56 @@
# Garage Door Opener
You just got a new garage door installed by the Automata™ Garage Door Company. You are having a lot of fun playing with the remote clicker, opening and closing the door, scaring your pets and annoying the neighbors.
The clicker is a one-button remote that works like this:
If the door is **OPEN** or **CLOSED**, clicking the button will cause the door to move, until it completes the cycle of opening or closing.
_Door: Closed -> Button clicked -> Door: Opening -> Cycle complete -> Door: Open._
If the door is currently opening or closing, clicking the button will make the door stop where it is. When clicked again, the door will go the opposite direction, until complete or the button is clicked again.
We will assume the initial state is **CLOSED**.
## Input
Array/vector of a series of commands (can be hard coded, no need to parse):
```text
button_clicked
cycle_complete
button_clicked
button_clicked
button_clicked
button_clicked
button_clicked
cycle_complete
```
## Output
Output should be the state of the door and the input commands, such as:
```text
Door: CLOSED
> Button clicked.
Door: OPENING
> Cycle complete.
Door: OPEN
> Button clicked.
Door: CLOSING
> Button clicked.
Door: STOPPED_WHILE_CLOSING
> Button clicked.
Door: OPENING
> Button clicked.
Door: STOPPED_WHILE_OPENING
> Button clicked.
Door: CLOSING
> Cycle complete.
Door: CLOSED
```
## Notes
- This is an example of a simple [Finite State Machine](https://en.wikipedia.org/wiki/Finite-state_machine) with 6 States and 2 inputs.

View File

@ -0,0 +1,36 @@
# Broken Keyboard
Help! My keyboard is broken, only a few keys work any more. If I tell you what keys work, can you tell me what words I can write?
(You should use the trusty **dictionary1.txt** file, located at _assets_ folder).
## Input
A string of letters representing the keys that work on the keyboard, example:
```text
abcd
```
```text
qwer
```
```text
hjklo
```
## Output
Your program should emit the longest valid English language word you can make for each keyboard configuration.
## Challenge Output
```text
longestWord("abcd") ➞ "abaca"
longestWord("edcf") ➞ "deeded"
longestWord("bnik") ➞ "bikini"
longestWord("poil") ➞ "lollipop"
longestWord("vybu") ➞ "bubby"
longestWord("subtoxymerhlac") ➞ "carboxymethylcelluloses"
```

View File

@ -0,0 +1,26 @@
# How long has the light been on?
There is a light in a room which lights up only when someone is in the room (think motion detector). You are given a set of intervals in entrance and exit times as single integers, and expected to find how long the light has been on. When the times overlap, you need to find the time between the smallest and the biggest numbers in that interval.
## Input Description
You'll be given a array/vector of array/vector of size two per line telling you the time points that someone entered and exited the room, respectively. Each line is a visitor, each block is a room. Example:
```text
[[1,3],[2,3],[4,5]]
```
## Output Description
Your program should report the number of hours the lights would be on. From the above example:
```text
3
```
## Examples
```text
lightOn([[2,4],[3,6],[1,3],[6,8]]) ➞ 7
lightOn([[6,8],[5,8],[8,9],[5,7],[4,7]]) ➞ 5
```

View File

@ -0,0 +1,42 @@
# L33tspeak Converter
L33tspeak - the act of speaking like a computer hacker (or hax0r) - was popularized in the late 1990s as a mechanism of abusing ASCII art and character mappings to confuse outsiders. It was a lot of fun. One popular comic strip in 2000 showed just how far the joke ran.
<p align="center">
<img src="../../assets/L33tspeak.gif" alt="L33tspeak">
</p>
In **L33Tspeak** you substitute letters for their rough outlines in ASCII characters, e.g. symbols or numbers. You can have 1:1 mappings (like E -> 3) or 1:many mappings (like W -> `//). So then you wind up with words like this:
```text
BASIC => 6451C
ELEET => 3L337 (pronounced elite)
WOW => `//0`//
MOM => (V)0(V)
```
## Mappings
For this challenge we'll be using a subset of American Standard Leetspeak:
```text
A -> 4
B -> 6
E -> 3
I -> 1
M -> (V)
N -> (\)
O -> 0
S -> 5
T -> 7
V -> \/
W -> `//
```
Your **challenge**, should you choose to accept it, is to **translate to L33T**.
## Example
```text
storm -> 570R(V)
```

View File

@ -0,0 +1,8 @@
# L33tspeak Translator
Based on the **L33tspeak Converter** of _day-72 challenge_ rules and mapping, develop now a **Translator** FROM **L33tspeak** input to **traditional** text.
## Example
```text
570R(V) -> storm
```

View File

@ -0,0 +1,108 @@
## CATTLEMETER
Researchers say bot networks exist that number in the hundreds of thousands, with accounts that share similar characteristics, suggesting someone is using them for a specific purpose. The Russian troll factory known as the Internet Research Agency reportedly used large networks of fake accounts to distribute misinformation in an attempt to destabilize the US election.
An analysis by researchers at Oxford University showed more than a third of pro-Trump tweets and nearly a fifth of pro-Clinton tweets between the first and second debates came from automated accounts, which produced more than 1 million tweets. Many of these same trolls and bot networks were also reportedly active in the Virginia state elections, amplifying race-baiting tweets by Donald Trump.
Bot networks are also used in some cases to attack journalists by flooding their accounts with suspicious activity, which often results in their accounts being suspended or banned.
The same problem happens in Brazil, where the current president (far-right) has very close ties with bot farms and there is enough profs to link one of his sons to a leader of a group called "the hate cabinet", which is responsible for milions of fake accounts and to spread fake news all the time to favor the president or discredit the opponents.
People who still supports the current Brazil president are knowed as "cattle", as they just follow whatever the president spits.
In order to contain the advance of this bot practices, you need to create an algorithm that given a twitter account, it tells if it's fake or not, using a scale from 0 (not a bot) to 100 (definetily a bot).
The current constrains must be taken into account:
### An Egghead
<p align="left">
<img src="../../assets/twitter-egghead.png" alt="egg head">
</p>
By egghead, I am referring to the Twitter user in question not taking the time to upload a profile image. Most real people will upload some sort of profile image. While not every egghead is a fake or bot account, this is typically a sign of a lazy person. Or a bot.
### Stock Profile Images
<p align="left">
<img src="../../assets/Twitter-Stock-Image-Profile.png" alt="stock image avatar">
</p>
While this move might be a step up from being an egghead, most fake accounts get this wrong. They either use stock images or a profile image shared by other fake accounts.
**[PRO TIP]** Use Google to find out if a profile image has been used by others. To do this you can right click on the profile image and copy the link location. Then simply go to Google Images and search by URL. Paste the URL and find out if others are using this same image.
**[BONUS TIP]** Narrow down your search to just Twitter results by added “site:twitter.com”
### No Bio
An empty Twitter bio is almost a dead giveaway that the profile you are looking at is a dud. This underutilized real estate is key to informing your followers (or potential followers) who you are and what youre about. Skipping over this is typically a sign of not only laziness, but a tell-tale sign the account is almost certainly fake.
### Excessive Duplicate Tweets
While this does not run rampant like it previously did, if you see a profiles stream that is all the exact same or very similar tweets, chances are that you are viewing a fake account.
Most notably, if the tweets are all @replies with the same text, you have found a bot account. While there is no doubt some excessive self promotion on Twitter, some accounts constantly tweet the same thing. Odds are a human is not behind each of those tweets, and better yet it is a sign of someone who does not use automation effectively.
### Confusing Screen Name / URL Combination
<p align="left">
<img src="../../../assets/Confusing-Screen-Name.png" alt="confusing screen name">
</p>
This is an easy one. There are multiple things to look for in a screen name. The first is if you see the profile URL as something like “twitter.com/john-smith” but when you view the profile, the first and last name listed above the bio has no relation to the URL. For example, it would say something like “Sarah Jones” which obviously has no direct relation to “John Smith” that is in the URL.
The other red flag regarding screen names and URL combinations is if you see an incoherent URL like “twitter.com/kaywhyeleenq”. Viewing this URL you will see that while this profile has many red flags, the first and last name listed in the profile has no direct relation to the URL. While, not all profiles will have a direct relation, most of the time if the URL does not even contain legitimate words or phrases, it is a common sign the profile was automatically generated via software and not a human.
### Incoherent Tweets
<p align="left">
<img src="../../../assets/Incoherent-Tweets.png" alt="incoherent tweets">
</p>
Most of the time fake Twitter accounts simply spew off tweets that directly benefit themselves, like linking directly to their site. However, there are many fake accounts that simply post gibberish or random incoherent thoughts that make absolutely no sense.
### Has Not Tweeted in Years
<p align="left">
<img src="../../../assets/Has-Not-Tweeted-In-Years.png" alt="not tweeted in years">
</p>
Back in the earlier, wild-west days of Twitter, automation was manipulated quite a bit. However, as Twitter has evolved their API access and rules, previous bots and some of their automation no longer work. An easy way to spot this is in accounts that have not tweeted in months or even years. Looking at the time stamp of the most recent tweets, you can get a good idea of the Twitter account is no longer active. For example, the Twitter account in the image above has not tweeted since 2011.
### Follows 2,001 People
Twitter has limits on certain things you can do. For example, how many people you can follow. This limit is set to 2,000. Once you follow 2,001 people, you must have at least 2,000 people following you back before you can exceed the 2,001 limit. A common limitation of bots is that they are not smart enough to manage their following restrictions to get around this limitation. Therefore, many fake accounts get stuck on following 2,001 users.
Once an account gets past the 2,001 following limitation, then I believe the unwritten rule is that you can follow 10% more than are following you. So if your account has 2,000 users following it, then theoretically you can follow approximately 2,200 users.
### No Interaction With Others
Accounts that show no signs of interaction with others are often fake accounts. Social media is meant to be a two-way conversation. Those accounts who simply do not interact with others is often a sign of a bot account.
The quick way to find out if there is interaction with other users is to simply view recent tweets by the user. If you can see that within their last 20-30 tweets there are no @replies or retweets, chances are the account you are looking at is automated/fake.
### No or Low Follower Counts
Another common sign of a bot account is an account that does not tend to have anyone following the account back. This is commonly seen with accounts that are following 2,001 users but only have a handful of accounts following back. While there are a number of reasons someone may not want to follow an account, chances are in this case it is due to the account not being worth one to follow. Twitter users are becoming smarter at whether or not someone deserves to be followed back.
### An Unrealistic Amount of Tweets
<p align="left">
<img src="../../../assets/An-Insane-Amount-of-Tweets.png" alt="insane amount of tweets">
</p>
No doubt automation has its place in Twitter when used responsibly. However, a sure sign of an automated/fake account is typically an insane amount of tweets that is more than likely not humanly possible. I mean, who has the time to tweet 123,684 times? In the image above you can see how tweeting this often did wonders for increasing the amount of followers for this account.
## The Cattle Scale
For each of the above items that an account triggers, add 10 to the score. The output should consider the following scale:
- 0 - 20 - Not a cattle
- 21 - 80 - Sounds like a cattle (muhhhh)
- 81 - 100 - It's definetely a cattle ! Avoid it !
- 100+ - Too much cattle! 🐮
## Input example
```
input: @DaniloGentili
output: Too much cattle! 🐮
```

View File

@ -0,0 +1,39 @@
## Minesweeper
Minesweeper is a game where the objective is correctly identify the location of all mines in a given grid. You are given a uniform grid of gray squares in the beginning of the game. Each square contains either a mine (indicated by a value of 9), or an empty square. Empty squares have a number indicating the count of mines in the adjacent squares. Empty squares can have counts from zero (no adjacent mines) up to 8 (all adjacent squares are mines).
If you were to take a complete grid, for example, you can see which squares have mines and which squares are empty:
```
0 0 0 0 0
0 0 0 0 0
1 1 1 0 0
1 9 1 0 0
1 2 2 1 0
0 1 9 1 0
0 1 1 1 0
```
The squares with "2" indicate that there 2 mines adjacent to that particular square.
Gameplay starts with a user un-hiding a square at random. If the square contains a mine, the game ends. If it is a blank, the number of adjacent mines is revealed.
Exposing a zero means that there are no adjacent mines, so exposing all adjacent squares is guaranteed safe. As a convenience to the player, the game continues to expose adjacent squares until a non-zero square is reached.
For example, if you click on the top right corner you get this ('-' means hidden):
```
0 0 0 0 0
0 0 0 0 0
1 1 1 0 0
- - 1 0 0
- - 2 1 0
- - - 1 0
- - - 1 0
```
Write functions to construct the playing field given the size and number of mines.
### Tip
An important part of this problem is figuring out a way to place the mines. The most naive implementation is to pick two random numbers (row and column) and place a mine there, but this will cause the board to have less mines than expected if the same coordinates are picked twice. Re-trying if the picked coordinates already have a mine fixes the immediate problem, but will take a very long time for cases such as a 100x100 board with 9999 mines.

View File

@ -0,0 +1,33 @@
## The Cake Thief
You are a renowned thief who has recently switched from stealing precious metals to stealing cakes because of the insane profit margins. You end up hitting the jackpot, breaking into the world's largest privately owned stock of cakes—the vault of the Queen of England.
While Queen Elizabeth has a limited number of types of cake, she has an unlimited supply of each type.
Each type of cake has a weight and a value, stored in a tuple with two indices:
- An integer representing the **weight** of the cake in kilograms
- An integer representing the **monetary value** of the cake in British shillings
For example:
```
// weighs 7 kilograms and has a value of 160 shillings
CakeType cakeType = {7, 160};
// weighs 3 kilograms and has a value of 90 shillings
CakeType cakeType = {3, 90};
```
You brought a duffel bag that can hold limited weight, and you want to make off with the most valuable haul possible.
Write a function `maxDuffelBagValue()` that takes **an array of cake type structures** and a **weight capacity**, and returns **the maximum monetary value the duffel bag can hold**.
For example:
```
cakes = [(7, 160), (3, 90), (2, 15)]
capacity = 20
max_duffel_bag_value(cake_tuples, capacity)
# Returns 555 (6 of the middle type of cake and 1 of the last type of cake)
```

View File

@ -0,0 +1,36 @@
## Bot saves princess
In this version of "Bot saves princess", Princess Peach and bot's position are randomly set. Can you save the princess?
### Task
Create a function nextMove which takes in 4 parameters - an integer N, integers r and c indicating the row & column position of the bot and the character array grid - and outputs the next move the bot makes to rescue the princess.
### Input Format
The first input parameter is N (<100), the size of the board (NxN). The second and third parameters of the input represents the position of the bot.
Grid is indexed using Matrix Convention
The position of the princess is indicated by the character 'p' and the position of the bot is indicated by the character 'm' and each cell is denoted by '-' (ascii value: 45).
### Output Format
Output the shortest path you take to rescue the princess. Valid moves are LEFT, RIGHT, UP or DOWN
#### Sample Input
```
5,2,3
-----
-----
p--m-
-----
-----
```
#### Sample Output
```
LEFT, LEFT, LEFT
```

View File

@ -0,0 +1,5 @@
## A number without numbers
Now that it's (almost) 2021, it's time for a code question involving the number 2021.
Your task is to make a program that prints the number 2021, without using any of the characters 0123456789 in your code, and independently of any external variables such as the date or time or a random seed.

View File

@ -0,0 +1,38 @@
## Analog Clock
Write a program which displays the current system time as an analog clock, using ASCII graphics. The clock must show at least the hour and minute pointers, and must have enough resolution of at least 5 minutes.
The display can be as small and as ugly as you wish, but the shown time should be easily recognizable.
The program has to run continuously and update its status. If your system can clear the screen, use it, otherwise it's enough to repaint the clock when its state changes.
### Examples
```
+- 10:10 - - - - - - - + - 12:30 - - - - - - - + - 09:15 - - - - - - - +
| . . 12. . | . . 12. . | . . 12. . |
| 11 1 | 11 H 1 | 11 1 |
| 10 2 | 10 H 2 | 10 2 |
|. H M . | . H . | . . |
|. H H H M M M . | . H . | . . |
|9 3 | 9 3 | 9 H H H H M M M M 3 |
|. . | . M . | . . |
|. . | . M . | . . |
| 8 4 | 8 M 4 | 8 4 |
| 7 5 | 7 M 5 | 7 5 |
| . . 6 . . | . . 6 . . | . . 6 . . |
+- - - - - - - - - - - + - - - - - - - - - - - + - - - - - - - - - - - +
+- 15:00 - - - - - - - + - 06:00 - - - - - - - + - 16:40 - - - - - - - +
| . . 12. . | . . 12. . | . . 12. . |
| 11 M 1 | 11 M 1 | 11 1 |
| 10 M 2 | 10 M 2 | 10 2 |
|. M . | . M . | . . |
|. M . | . M . | . . |
|9 H H H H 3 | 9 3 | 9 3 |
|. . | . H . | . M M M H H H . |
|. . | . H . | . M H . |
| 8 4 | 8 H 4 | 8 4 |
| 7 5 | 7 H 5 | 7 5 |
| . . 6 . . | . . 6 . . | . . 6 . . |
+- - - - - - - - - - - + - - - - - - - - - - - + - - - - - - - - - - - +
```

View File

@ -0,0 +1,17 @@
## Make it look like you are working
Often, we find ourselves running a script or query that will take a significant amount of time to run. usually, you can leave that script open and enjoy some guilt-free procrastination.
Now, what if you could write a script that seems to be one of the above scripts to any onlookers, but in looks only? You could put it up on a screen and enjoy days of kitten livestreams before anyone realised that all the complicated rigmarole on the screen didn't have anything to do with your actual job.
Your challenge is to write this script !
## A good solution will:
- Make something appear on the screen that looks like a script is doing work. "Screen" can be terminal, browser, etc.
- Be fairly original (yes, we've all seen the neverending progress bar programs)
- Survive cursory examination by a technical person
## A bad solution will:
- Get you fired

View File

@ -0,0 +1,21 @@
## Draw the “G” Logo
Write a program or function that takes in a positive integer N, and outputs an N×N pixel image of Google's "G" logo according to this\* construction:
<p align="left">
<img src="../../assets/google_logo.png" width=600 height=600 alt="google logo">
</p>
For example, if N is 200, a 200×200 pixel logo should be output, with correct dimensions and colors:
<p align="left">
<img src="../../assets/google_logo_2.png" width=200 height=200 alt="google logo">
</p>
- It should look accurate regardless of how large or small N is.
- Your code should not need to connect to the internet. For example, scaling an externally hosted svg is not allowed. (Scaling an svg encoded in your code would be fine though.)
- Anti-aliasing may be used or not. It's up to you.
- Notice that the horizontal bar of the "G" does not extend all the way to the right edge of the image. The circle curves normally inward on the right edge before it is cut off.

View File

@ -0,0 +1,41 @@
## Tidy Numbers
Tatiana likes to keep things tidy. Her toys are sorted from smallest to largest, her pencils are sorted from shortest to longest and her computers from oldest to newest. One day, when practicing her counting skills, she noticed that some integers, when written in base 10 with no leading zeroes, have their digits sorted in non-decreasing order. Some examples of this are 8, 123, 555, and 224488. She decided to call these numbers tidy. Numbers that do not have this property, like 20, 321, 495 and 999990, are not tidy.
She just finished counting all positive integers in ascending order from 1 to **N**. What was the last tidy number she counted?
### Input
The first line of the input gives the number of test cases, **T. T** lines follow. Each line describes a test case with a single integer N, the last number counted by Tatiana.
### Output
For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is the last tidy number counted by Tatiana.
### Limits
Time limit: 20 seconds per test set.
Memory limit: 1 GB.
1 ≤ **T** ≤ 100.
Dataset
1 ≤ N ≤ 1018.
Sample
```
Input
4
132
1000
7
111111111111111110
Output
Case #1: 129
Case #2: 999
Case #3: 7
Case #4: 99999999999999999
```

View File

@ -0,0 +1,51 @@
## Bathroom Stalls
A certain bathroom has **N** + 2 stalls in a single row; the stalls on the left and right ends are permanently occupied by the bathroom guards. The other **N** stalls are for users.
Whenever someone enters the bathroom, they try to choose a stall that is as far from other people as possible. To avoid confusion, they follow deterministic rules: For each empty stall S, they compute two values LS and RS, each of which is the number of empty stalls between S and the closest occupied stall to the left or right, respectively. Then they consider the set of stalls with the farthest closest neighbor, that is, those S for which min(LS, RS) is maximal. If there is only one such stall, they choose it; otherwise, they choose the one among those where max(LS, RS) is maximal. If there are still multiple tied stalls, they choose the leftmost stall among those.
**K** people are about to enter the bathroom; each one will choose their stall before the next arrives. Nobody will ever leave.
When the last person chooses their stall S, what will the values of max(LS, RS) and min(LS, RS) be?
### Input
The first line of the input gives the number of test cases, **T. T** lines follow. Each line describes a test case with two integers **N** and **K**, as described above.
### Output
For each test case, output one line containing Case #x: y z, where x is the test case number (starting from 1), y is max(LS, RS), and z is min(LS, RS) as calculated by the last person to enter the bathroom for their chosen stall S.
### Limits
1 ≤ **T** ≤ 100.
1 ≤ **K****N**.
Time limit: 30 seconds per test set.
Memory limit: 1GB.
#### Test set
1 ≤ N ≤ 1018.
### Sample
```
Input Output
5
4 2 Case #1: 1 0
5 2 Case #2: 1 0
6 2 Case #3: 1 1
1000 1000 Case #4: 0 0
1000 1 Case #5: 500 499
```
In Sample Case #1, the first person occupies the leftmost of the middle two stalls, leaving the following configuration (O stands for an occupied stall and . for an empty one): O.O..O. Then, the second and last person occupies the stall immediately to the right, leaving 1 empty stall on one side and none on the other.
In Sample Case #2, the first person occupies the middle stall, getting to O..O..O. Then, the second and last person occupies the leftmost stall.
In Sample Case #3, the first person occupies the leftmost of the two middle stalls, leaving O..O...O. The second person then occupies the middle of the three consecutive empty stalls.
In Sample Case #4, every stall is occupied at the end, no matter what the stall choices are.
In Sample Case #5, the first and only person chooses the leftmost middle stall.

View File

@ -0,0 +1,60 @@
## Vestigium
Vestigium means "trace" in Latin. In this problem we work with Latin squares and matrix traces.
The trace of a square matrix is the sum of the values on the main diagonal (which runs from the upper left to the lower right).
An **N-by-N** square matrix is a Latin square if each cell contains one of **N** different values, and no value is repeated within a row or a column. In this problem, we will deal only with "natural Latin squares" in which the N values are the integers between 1 and **N**.
Given a matrix that contains only integers between 1 and N, we want to compute its trace and check whether it is a natural Latin square. To give some additional information, instead of simply telling us whether the matrix is a natural Latin square or not, please compute the number of rows and the number of columns that contain repeated values.
### Input
The first line of the input gives the number of test cases, T. T test cases follow. Each starts with a line containing a single integer **N**: the size of the matrix to explore. Then, **N** lines follow. The i-th of these lines contains N integers **Mi,1, Mi,2 ..., Mi,N. Mi,j** is the integer in the i-th row and j-th column of the matrix.
### Output
For each test case, output one line containing Case #x: k r c, where x is the test case number (starting from 1), k is the trace of the matrix, r is the number of rows of the matrix that contain repeated elements, and c is the number of columns of the matrix that contain repeated elements.
### Limits
Test set 1 (Visible Verdict)
Time limit: 20 seconds per test set.
Memory limit: 1GB.
1 ≤ T ≤ 100.
2 ≤ N ≤ 100.
1 ≤ Mi,j ≤ N, for all i, j.
### Sample
```
Input Output
3
4
1 2 3 4
2 1 4 3
3 4 1 2
4 3 2 1
4 Case #1: 4 0 0
2 2 2 2 Case #2: 9 4 4
2 3 2 3 Case #3: 8 0 2
2 2 2 3
2 2 2 2
3
2 1 3
1 3 2
1 2 3
```
In Sample Case #1, the input is a natural Latin square, which means no row or column has repeated elements. All four values in the main diagonal are 1, and so the trace (their sum) is 4.
In Sample Case #2, all rows and columns have repeated elements. Notice that each row or column with repeated elements is counted only once regardless of the number of elements that are repeated or how often they are repeated within the row or column. In addition, notice that some integers in the range 1 through N may be absent from the input.
In Sample Case #3, the leftmost and rightmost columns have repeated elements.
### #Analysis
One simple way to check whether the values in a row or column are a permutation of the values from 1 to N is to sort them and then step through them, checking whether the sorted list starts at 1 and increases by 1 each time. Another option, which avoids the sort and takes time linear in N, is to look at the values one by one and store each one in a hash table-based data structure. If we ever find that a value is already in the set, then that row or column contains a repeated value. Because there are N values and the problem guarantees that they are integers between 1 and N, inclusive, the absence of duplicates implies that we have a permutation as desired.
Finding the trace is also straightforward — iterate through the rows taking the i-th value from the i-th row, and add the values together.