- Can we solve the problem using print("\n") rather println()?
- Yes, they produce the same exact output.
- Is there an easier way to produce powers of 10 without using loops?
- We can use Math.pow from the java.lang.Math library, but that returns a double. We have to convert it to an integer.
- Why does the loop run till the number is not equal to zero?
- Because we want the program to execute till we print all digits.
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
<script> | |
import { browser } from '$app/environment'; | |
if (browser) { | |
const progressBar = document.getElementById('progress'); | |
const content = document.getElementById('content'); | |
function updateProgressBar() { | |
const scrollTop = window.scrollY; | |
const contentHeight = content.offsetHeight; | |
const windowHeight = window.innerHeight; | |
const progress = (scrollTop / (contentHeight - windowHeight)) * 100; |
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
import psycopg | |
import requests | |
import glob | |
from tqdm import tqdm | |
import subprocess | |
API = "http://127.0.0.1:7000" | |
usfms = glob.glob("usfm1910/*") | |
abbreviations = requests.get(f"{API}/abbreviations").json() |
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
import tensorflow as tf | |
import tensorflow_datasets as tfds | |
(ds_train, ds_test), ds_info = tfds.load( | |
'mnist', | |
split=['train', 'test'], | |
shuffle_files=True, | |
as_supervised=True, | |
with_info=True, | |
data_dir="./tensorflow_datasets" |
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
# Copyright 2023 Gentoo Authors | |
# Distributed under the terms of the GNU General Public License v2 | |
from portage.tests import TestCase | |
from portage.tests.resolver.ResolverPlayground import ( | |
ResolverPlayground, | |
ResolverPlaygroundTestCase, | |
) | |
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
Profiling results. |
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
Contains the cProfile result as an image |
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
running './script' | |
0.8035502433776855 | |
skip | |
Error during set creation: Could not import 'portage._sets.dbapi.SubslotChangedSet' for section 'changed-subslot' | |
Exception in callback AsyncScheduler._task_coroutine_done(<_emerge.Ebui...x7fec345ea200>)(<Future finis...te 'ebuild'")>) | |
handle: <Handle AsyncScheduler._task_coroutine_done(<_emerge.Ebui...x7fec345ea200>)(<Future finis...te 'ebuild'")>)> | |
Traceback (most recent call last): | |
File "/usr/lib/python3.10/asyncio/events.py", line 80, in _run | |
self._context.run(self._callback, *self._args) |
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
Computer Information: | |
Manufacturer: ASUSTeK COMPUTER INC. | |
Model: ROG Strix G513QY_G513QY | |
Form Factor: Laptop | |
No Touch Input Detected | |
Processor Information: | |
CPU Vendor: AuthenticAMD | |
CPU Brand: AMD Ryzen 9 5900HX with Radeon Graphics | |
CPU Family: 0x19 |
-
The algorithm seems to be using a lot of space to sort a few dates. Is this the optimal solution?
- One thing we have to keep in mind is that count sort sorts any number of dates in constant space, that is O(1). Even if the number seems big, when we scale up the number of inputs, the algorithm will be much faster and more efficient than most other implementations.
-
What happens if we sort by year first?
- We need the output to be sorted by year, month and date with respective order of precedence. So, when we first sort by year, then by date, the later sort reorders the years which leads to wrong answer. So, it is not possible to sort by year first.
-
Is this still the optimal solution if we know the number of inputs beforehand?
- Probably not because, if we know the number of inputs, we need not create an array of size 2501. We can sort the dates in a more space optimal way without much implication on the time complexity.
NewerOlder