CodeChef | A collection of my solutions and their explanations | Learning library
kandi X-RAY | CodeChef Summary
kandi X-RAY | CodeChef Summary
A collection of my solutions and their explanations to CodeChef questions. For ease of reading, I have tried to ensure no folder has more than 25 files.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of CodeChef
CodeChef Key Features
CodeChef Examples and Code Snippets
Community Discussions
Trending Discussions on CodeChef
QUESTION
The following code I wrote in JAVA takes more than 2 seconds to execute in some absurd test cases:
...ANSWER
Answered 2021-Jun-14 at 07:40There is a difference in java and python implementations:
In java you wrote some kind of a bubble sort with complexity O(n^2)
, here it is:
QUESTION
What sites help me to increase my hacking skills, I'm a newbie, for coding there are hackerrank, hackerearth, codeforces, codechef etc, like those what are there to learn hacking?
...ANSWER
Answered 2021-Jun-11 at 09:01I would say CTF challenges are a good way to learn. https://tryhackme.com/ is a good place to start. Most of the rooms are aimed at beginners and it will give you a good understanding, of some of the programs you will use like nmap, burpsuite and wireshark. https://www.hackthebox.eu/ is a good place, when you are a bit more experienced.
I am also gonna share some GitHub links, you might find interesting:
QUESTION
I am new to the Codechef platform registered using a Github account. For some reason, I wanted to log out. So I clicked on the Github symbol on Codechef page. My chrome browser asked 'are you sure you want to disconnect Github account?' and I have clicked 'OK'.
Now Codechef is asking for new registration. What to do? Please help I don't want to lose all my work on Codechef.
Thank you.
...ANSWER
Answered 2021-May-16 at 13:36I have got the answer. Open the login page of CodeChef. Enter the username of your account and use Github password. You will get your account back. This account will not be linked with Github.
Note: If you forgot your username you can possibly find it in your registered(Github) email id's mail inbox.
QUESTION
I am trying to solve a problem from CodeChef. The problem statement is as follows.
Pooja would like to withdraw X $US from an ATM. The cash machine will only accept the transaction if X is a multiple of 5, and Pooja's account balance has enough cash to perform the withdrawal transaction (including bank charges). For each successful withdrawal, the bank charges 0.50 $US. Calculate Pooja's account balance after an attempted transaction.
Input: 42 120.00
Output: 120.00
For this input, I am getting an output of 120.000.00.
...ANSWER
Answered 2021-May-14 at 17:04You are printing 120.00
via printf("%.2f", initial_balance);
and after that printing uninitialized indeterminate value via printf("%.2f", final_balance);
.
Instead of the printing printf("%.2f", initial_balance);
in the if
statement, you should set the answer to final_balance
like final_balance = initial_balance;
.
QUESTION
This is the problem statement
https://www.codechef.com/status/TLG I have written this code, but it is failing some test case.... and I cant figure out which one,It is working fine on the test cases I tried but when I submitted it on codechef it didnt pass a test case it seems,can someone please help.... Thank you !
The game of billiards involves two players knocking 3 balls around on a green baize table. Well, there is more to it, but for our purposes this is sufficient.
The game consists of several rounds and in each round both players obtain a score, based on how well they played. Once all the rounds have been played, the total score of each player is determined by adding up the scores in all the rounds and the player with the higher total score is declared the winner.
The Siruseri Sports Club organises an annual billiards game where the top two players of Siruseri play against each other. The Manager of Siruseri Sports Club decided to add his own twist to the game by changing the rules for determining the winner. In his version, at the end of each round, the cumulative score for each player is calculated, and the leader and her current lead are found. Once all the rounds are over the player who had the maximum lead at the end of any round in the game is declared the winner.
...ANSWER
Answered 2021-Apr-22 at 18:14Unless I'm missing something, you don't need to store the scores for each round in an array at all.
You only need a two element array, indexed by player number, to hold the total/accumulated scores
Just remember the "best" round (largest lead) and the player that had it as you read in the data.
Here's what I came up with [it passes the submission for all data]:
QUESTION
This is the question:
I've written my code solution in JavaScript and as it's on CODECHEF, I gotta run it on NodeJs environment. But on submission, it shows the time limit exceeded, and on custom input, it outputs the Greater than sign(>).I strongly believe that the problem is with my input, I think its not right, please help. The following is my code:
...ANSWER
Answered 2021-Apr-20 at 06:35QUESTION
I am getting runtime error(NZEC) on Codechef. Can anyone tell me why?
...ANSWER
Answered 2021-Apr-02 at 17:43Most probably you're trying to read input when there is no more input left to read and python raises an exception, the online judge in return gives the (NZEC) error. Try using raw_input() instead of input(). Comment back to let me know if it worked.
QUESTION
Hello am newbie here am getting segmentation fault when running the program but unable to find reason behind it . I have googled and know that it occurs due to memory violation but unable to find what is causing seg fault in my code.
Code below
...ANSWER
Answered 2021-Mar-30 at 05:04The problem is very likely these two lines:
QUESTION
This is a codechef beginner problem. I know it can be done in much easier ways, but I thought to try recursion here. My program is giving correct answer when I give only one input at a time, but when I run given testcases it only shows output for first two.
...ANSWER
Answered 2021-Mar-09 at 14:50There are few logical errors in your code, I'll try to point them one by one-
1.) Remove line 47 because when something like this happens your main function will be stopped(return 0 stops the main function and thus program) and your program will not run for rest of the test cases. You can use boolean flag for that purpose.
2.) You don't need the for loop inside main function, below code will consider all the cases.
3.) If you understand the problem then first you always try to pick the dish with the maximum price and you want to pick it as many times as you can, so I'm writing your code in a better recursive manner(since you want to solve it recursively)-
QUESTION
Link : https://www.codechef.com/LRNDSA01/problems/LAPIN
Program description : Lapindrome is defined as a string which when split in the middle, gives two halves having the same characters and same frequency of each character. If there are odd number of characters in the string, we ignore the middle character and check for lapindrome. For example gaga is a lapindrome, since the two halves ga and ga have the same characters with same frequency. Also, abccab, rotor and xyzxy are a few examples of lapindromes. Note that abbaab is NOT a lapindrome. The two halves contain the same characters but their frequencies do not match. Your task is simple. Given a string, you need to tell if it is a lapindrome.
My code :
...ANSWER
Answered 2021-Mar-01 at 15:00The algorithm you implemented is both incorrect and very slow (even if it was correct). Since the input characters are limited to a..z, you could implement a fast algorithm by comparing the frequencies of letters in the left and right portions of the input text. An example implementation is below. The code assumes that the character codes of a..z are contiguous, which isn't guaranteed by the C standard.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install CodeChef
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page