Showing posts with label up. Show all posts
Showing posts with label up. Show all posts
Thursday, December 29, 2016
UVa 574 Sum It Up
UVa 574 Sum It Up
Method: Backtracking
Possible optimizations: Used a map to check if a set was generated before, it takes more time than checking if the numbers were used more than they appeared in input
Possible optimizations: Used a map to check if a set was generated before, it takes more time than checking if the numbers were used more than they appeared in input
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
using namespace std;
vector<int> nlist;
vector< vector<int> > finlist;
bool used[20];
map< vector<int>, bool > mp;
int btracking(int t, int sum, vector<int> temp, int k) {
//if (!sum) solve[i].clear();
if (sum == t) {
if (!mp[temp]) {
finlist.push_back(temp);
mp[temp] = true;
}
return 0;
}
for (k ; k<nlist.size() ; k++) {
if (!used[k]) {
if (nlist[k]<=(t-sum)) {
sum+=nlist[k];
temp.push_back(nlist[k]);
used[k] = true;
btracking(t, sum, temp, k);
used[k] = false;
temp.pop_back();
sum-=nlist[k];
}
}
}
return 0;
}
int main( void ) {
int t, n, i, j, x;
//freopen("574_in.txt","r+",stdin);
while ( scanf("%d %d",&t,&n) == 2 ) {
if (!n) break;
printf("Sums of %d: ",t);
nlist.clear();
for (i=0 ; i<n ; i++) {
scanf("%d",&x);
nlist.push_back(x);
used[i] = false;
}
//cout << "-----> " << nlist.size() << endl;
finlist.clear();
vector<int> temp;
temp.clear();
mp.clear();
btracking(t, 0, temp, 0);
if (!finlist.size()) {
printf("NONE ");
}
//printf("--> %d ",finlist.size());
for (i=0 ; i<finlist.size() ; i++) {
for (j=0 ; j<finlist[i].size() ; j++) {
if (!j) printf("%d",finlist[i][j]);
else printf("+%d",finlist[i][j]);
}
printf(" ");
}
}
return 0;
}
Go to link download
Saturday, December 10, 2016
Setting up Android Development environment in Ubuntu
Setting up Android Development environment in Ubuntu
[ How to install ADB for Android in Ubuntu ]
Im setting up my development and firmware modding environment in my Ubuntu desktop, based on the tutorial provided in the link above
Im setting up my development and firmware modding environment in my Ubuntu desktop, based on the tutorial provided in the link above
Go to link download
Labels:
android,
development,
environment,
in,
setting,
ubuntu,
up
Wednesday, December 7, 2016
Linux Mint FIrefox hanging up repeatedly for seconds weird Google search page
Linux Mint FIrefox hanging up repeatedly for seconds weird Google search page
Im using Linux Mint Lisa (12) with GNOME 3 for a couple of months now. Im impressed with the huge user support community and nice interface with the ease of using the same knowledge I had from Ubuntu. Recently the Firefox installation got somehow crapped up. It showed weird search results.

Moreover, the pages would repeatedly hang up. They would get updated (downloaded) but wont change until there was some cursor movement. It was real irritating. Thanks to "remoulder" from Linux Mint Forums, I found a nice method for repairing these things.
Close down Firefox > Press Alt + F2 > type "firefox -profilemanager" without the quotes
Youll see a default profile there. That profile is corrupted. Just create a new one using the options and start with the new one. All fixed.

Moreover, the pages would repeatedly hang up. They would get updated (downloaded) but wont change until there was some cursor movement. It was real irritating. Thanks to "remoulder" from Linux Mint Forums, I found a nice method for repairing these things.
Close down Firefox > Press Alt + F2 > type "firefox -profilemanager" without the quotes
Youll see a default profile there. That profile is corrupted. Just create a new one using the options and start with the new one. All fixed.
Go to link download
Linux Mint 12 GNOME Freeze Hang Up Problem
Linux Mint 12 GNOME Freeze Hang Up Problem
Linux Mint is probably the distro that fixes all the mistakes that Ubuntu makes. Its built on the Ubuntu base while keeping a very light weight taste to it.
Recently the Lisa (12) release of Mint was released with various Desktop Environment including GNOME. Ive installed it and it was pretty good to me until a very annoying error was being caused by GNOME. It hung up at very random time forcing me to reboot the system using a Hard Boot. Later on I found this fix that reportedly solved the problem to some extent but still has some issues with Banshee Media Player. Anyway heres the how.
First download this file: Link 1
Go to the directory where you downloaded this file and run this command
Recently the Lisa (12) release of Mint was released with various Desktop Environment including GNOME. Ive installed it and it was pretty good to me until a very annoying error was being caused by GNOME. It hung up at very random time forcing me to reboot the system using a Hard Boot. Later on I found this fix that reportedly solved the problem to some extent but still has some issues with Banshee Media Player. Anyway heres the how.
First download this file: Link 1
Go to the directory where you downloaded this file and run this command
sudo patch /usr/share/gnome-shell/extensions/mediaplayer@linuxmint.com/extension.js mgse-mediaplayer.diff
Then download this file: Link 2
sudo patch /usr/share/gnome-shell/extensions/mediaplayer@linuxmint.com/extension.js mgse-mediaplayer.diff
NOTE: Both the files have the same name so my commands are also same. But if you dont replace the first file with the second when downloading then you might need to change the command as per your files name.
This should fix the problem.
Source: [ Launchpad, Linux Mint Forums ]
Go to link download
Wednesday, November 30, 2016
Friday, November 11, 2016
Setting up Node with NVM
Setting up Node with NVM
I always keep facing problems with Node. It just keeps pushing me around with its numerous errors. So, lately I found out about NVM and tried it. Still had an issue with it. But finally got it up and running. Here are some important things to keep note of when attempting to install node using NVM.
1. The default installation directory of the NVM installer (provided in the repo readme) is ~/.nvm. I find this a bit problematic so I actually just clone the repo into /opt/nvm since I kind of stick to sudoing things when they need to be global for node and ~/.nvm isnt owned by root, I kind of like to keep it that way.
2. Now setting up the envvars is done using profile.d/nvm.sh. This could also be done using ~/.zshrc or ~/.zprofile but I like it this way. In whatever case the envvar setup script is like this
5. Now we can simply execute
Credits:
http://stackoverflow.com/questions/11542846/nvm-node-js-recommended-install-for-all-users
https://www.digitalocean.com/community/tutorials/how-to-install-node-js-with-nvm-node-version-manager-on-a-vps
Found a nice article here: http://www.liquidweb.com/kb/how-to-install-node-js-via-nvm-node-version-manager-on-ubuntu-14-04-lts/
1. The default installation directory of the NVM installer (provided in the repo readme) is ~/.nvm. I find this a bit problematic so I actually just clone the repo into /opt/nvm since I kind of stick to sudoing things when they need to be global for node and ~/.nvm isnt owned by root, I kind of like to keep it that way.
2. Now setting up the envvars is done using profile.d/nvm.sh. This could also be done using ~/.zshrc or ~/.zprofile but I like it this way. In whatever case the envvar setup script is like this
3. So its basically done (setting up NVM, not node) but since to install anything via nvm Ill need sudo so I must (at least) source the /etc/profile.d/nvm.sh into root. So I just do
export NVM_DIR=/usr/local/nvm
source /opt/nvm/nvm.sh
export NPM_CONFIG_PREFIX=/usr/local/node
export PATH="/usr/local/node/bin:$PATH"
4. Now for the installation of a node version
$ sudo su
# source /etc/profile.d/nvm.sh
The last one should be done from root because it creates a particular directory that $ cant create.
# nvm install 0.12
# nvm ls
5. Now we can simply execute
$ nvm use 0.12
Credits:
http://stackoverflow.com/questions/11542846/nvm-node-js-recommended-install-for-all-users
https://www.digitalocean.com/community/tutorials/how-to-install-node-js-with-nvm-node-version-manager-on-a-vps
Found a nice article here: http://www.liquidweb.com/kb/how-to-install-node-js-via-nvm-node-version-manager-on-ubuntu-14-04-lts/
Go to link download
Saturday, October 29, 2016
Image close up iPad mini 2 Sensors Touch ID support
Image close up iPad mini 2 Sensors Touch ID support
Recently, technology news site DoNews China has uploaded 2 new images fairly complete iPad mini 2 tablet launched yet. This is the yellow version similar to the color of champagne on the new iPhone 5s. However, noteworthy is also a border around your Home button iPad mini 2 is quite similar to what we saw on the 5s. This raises the question that the iPad mini 2 will also support mini fingerprint sensor, although thats just a guess not many bases.


In recent days, a number of sites have reported that the iPad mini 2 and iPad 5 will simultaneously be released in October next. But according to new internal resource leak from Cupertino may iPad mini 2 will not appear before 2014. Besides, the device is equipped A7 processor and 1 GB of RAM, but the screen resolution is still a mystery.
Reference: Phonearena.com
Posts published by Smartphone Blog
Go to link download
Friday, September 30, 2016
Show all combinations of numbers from 1 to 9 that add up to 100 by adding subtracting and concatenating
Show all combinations of numbers from 1 to 9 that add up to 100 by adding subtracting and concatenating
So, this week I saw a blog post somewhere where the poster claimed that if you cant solve the mentioned 5 problems each in under and hour, you aint no programmer, dev or software engineer. So, I went in and read the problems. 1-4 were easy but number 5 got me a worrying a little. And expected, I failed to solve that in under 1 hour yesterday. But today morning I solved that in less than 30 minutes. But whatever, I cant call myself a programmer anymore :(
Heres my approach though, using recursion:
Each i (from 1 through 9) has 2 different ways of connecting to the sequence.
1. Add itself to the closest sum (1 + 23 + 4 + .......)
2. Or concatenate itself (1 + 234 + ......)
So if we either add an i to the sequence that has reached it or we concatenate. Examples: .......8 + 9
.......89
Now the part before 8 has the same behavior with 8
.......7 + 8
.......78
This goes all the way back to 1 and 2
1 + 2
12
So, the program works something like this
Each branch ultimately ends on the leftmost call.
Code:
Heres my approach though, using recursion:
Each i (from 1 through 9) has 2 different ways of connecting to the sequence.
1. Add itself to the closest sum (1 + 23 + 4 + .......)
2. Or concatenate itself (1 + 234 + ......)
So if we either add an i to the sequence that has reached it or we concatenate. Examples: .......8 + 9
.......89
Now the part before 8 has the same behavior with 8
.......7 + 8
.......78
This goes all the way back to 1 and 2
1 + 2
12
So, the program works something like this

Code:
#include <cstdio>
#include <iostream>
#include <sstream>
using namespace std;
string i2s(int i) {
stringstream op;
op << i;
return op.str();
}
int solveS(int i, int sum, string p) {
if (i >= 10) {
if (sum == 100) {
cout << p + " = " << sum << endl;
}
return 0;
}
int iSum = 0;
for (int j = i ; j<=9 ; j++) {
iSum = iSum * 10 + j;
if (i == 1) {
solveS(j+1, iSum, i2s(iSum));
} else {
solveS(j+1, sum+iSum, p + " + " + i2s(iSum));
solveS(j+1, sum-iSum, p + " - " + i2s(iSum));
}
}
return 0;
}
int main() {
//freopen("output.txt", "w+", stdout);
solveS(1, 0, "");
return 0;
}
Go to link download
Tuesday, September 27, 2016
HACKATH0N 2 5 Meet up of the Backbenchers
HACKATH0N 2 5 Meet up of the Backbenchers
Mark this day, an example of destiny. Only the backbenchers of the BD-LFS group met up today. Somehow the good boys didnt show up. Robin Bhai had leg pain due to dancing rehearsals. Kabir Bhai had set foot for the meet up only to find himself hurt in the leg and returning home. We almost thought today should be announced "Leg Injury Day" but didnt do so because Tapan bhai didnt show up without reporting any leg injury. All in all we just had one mentor #R!NE to lead us to the same level as the regular good guys.

We ended up doing the things that #Hackathon-2 had left us with. Me and RINE were not present in that due to personal issues. So, I just made the best use of this day to improve my knowledge and sync up with the rest of the group.
Initially we had problems regarding VM setup which was almost dragging us towards failure. But somehow, by the hand of God we recovered from that state after me, Rahid Bhai and Mamun Bhai managed to build the systems up. We ended up creating the LFS systems base camp for compilation and tool sets. It was fun and in between Rine was helping us understand the concepts that were in play with what we were doing.
We shared a lot about our experiences with different OS setups. I liked the way we shared knowledge about shells. Came to know about some of those from Mamun bhai.
Particularly, the venue this time was Sphinx Corporations. Shihan Bhais new software company. We had a great venue indeed since the sitting arrangements allowed us to really enjoy the mash up. The lunch was fun too since there was great gossip and knowledge sharing. All in all it was awesome, for the Backbenchers ;p
Participants:
Topics covered:
Issues:
Target of the next Hackathon (3): Start [B/C]LFS

We ended up doing the things that #Hackathon-2 had left us with. Me and RINE were not present in that due to personal issues. So, I just made the best use of this day to improve my knowledge and sync up with the rest of the group.
Initially we had problems regarding VM setup which was almost dragging us towards failure. But somehow, by the hand of God we recovered from that state after me, Rahid Bhai and Mamun Bhai managed to build the systems up. We ended up creating the LFS systems base camp for compilation and tool sets. It was fun and in between Rine was helping us understand the concepts that were in play with what we were doing.
We shared a lot about our experiences with different OS setups. I liked the way we shared knowledge about shells. Came to know about some of those from Mamun bhai.
Particularly, the venue this time was Sphinx Corporations. Shihan Bhais new software company. We had a great venue indeed since the sitting arrangements allowed us to really enjoy the mash up. The lunch was fun too since there was great gossip and knowledge sharing. All in all it was awesome, for the Backbenchers ;p
Participants:
1. Tafhim (Me)
2. Rine (Rine Toufique Anam)
3. Mamun bhai (Abdullah al Mamun)
4. Rahid bhai (Rahid Hasan)
5. Aman bhai (Md. Aman Ullah)
Topics covered:
1. Preparing LFS Partition
2. Setting up LFS usergroup and account
3. Compiled BinUtils (First phase)
4. Compiled GCC (First phase)
Issues:
1. VBox machine setup [20 GB Partition, 2 GB swap, 8 GB Host OS, 10 GB LFS Partition
2. Dependency resolving issue during G++, GAWK, BISON installation. Fixed by choosing an Australia based server. Even though using "Choose the best server" solved the slow download issue but it doesnt always choose a repo that can resolve all dependencies. We tried different repos and had zero dependency issues of packages using Australian servers.
3. In case of slow download speed of packages you should change your repo and choose a good one using Synaptic
4. We primarily came to a unified decision to arrange the next Hackathon atleast 1 and 1/2 months from today so that all of us can complete the LFS book before that.
Target of the next Hackathon (3): Start [B/C]LFS
Go to link download
Sunday, September 25, 2016
Bring features press 2 times to open up the Nexus 7 machine with kernel
Bring features press 2 times to open up the Nexus 7 machine with kernel
Click 2 times to open the machine is a pretty new feature and convenient, especially for a large tablet screen as Nexus 7. However, the Nexus 7 2013 by default does not have this feature, to get it, you have several ways, such as installing additional software support, or rather would have built another kernel. Myself kernel support rather than because of stability, as well as better performance is due to software support. As shown in this article I will talk to the kernel ElementalX, Nexus 7 version for 2013.

In addition to bringing feature click 2 times to open the screen as they slipped to unlock many features or the other. Details of opening off-screen:
Refer to details ElementalX here: xda-developers.
2 times more features click on the screen to open the screen
Slide from right to left hand side of the screen (virtual keyboard area) to turn off the screen
Slide from left to right hand side of the screen (virtual keyboard area) to open the screen
More: Bring features press 2 times to open up the Nexus 7 machine with kernel ElementalX
More: Bring features press 2 times to open up the Nexus 7 machine with kernel ElementalX
Posts published by Smartphone Blog
Go to link download
Thursday, September 22, 2016
Fix fans running at full in Arch Linux vanilla Kernel 3 18 and up
Fix fans running at full in Arch Linux vanilla Kernel 3 18 and up
So, the other day I was tinkering with a fresh Arch installation and the very first issue that I ran into was my fan was rotating at full blast even though there was now processor load at all. While looking for a solution I was surprised to find that there were no actual solutions on the internet to these. I followed the path of "Fan speed control" in Arch Linux wiki and but no luck. Then I installed powertop
UPDATE: Apparently this did not bring the crazy fan speeds down. After some browsing around, I hit a thread in the ArchBang forums where it became pretty apparent that recent Kernel changes in 3.18 have triggered the issue and still has not been resolved. So, I had to downgrade to 3.17.6 which I did by following a well written guide here. What I basically did was
a. Went to the Arch official package database
b. Located the Linux package
c. On the upper right Package Section of the page, click on View Changes. There I located an earlier version, in this case upgpkg: linux 3.17.6-1
d. Located the revision number from the line that is like "file:///srv/svn-packages@177020". Thats the revision number after the @, it might be anything. e. Then to compile 3.17.6, did the following in the terminal. CAUTION: This process might take several hours, took me around 4 hours to compile the kernel
Credits: https://ask.fedoraproject.org/en/question/31514/how-to-change-cpu-temperature-thresholds-and-control-fan-speed/
https://nims11.wordpress.com/2013/02/17/downgrading-packages-in-arch-linux-the-worst-case-scenario/
Then I ran
pacman -S powertop
Used Tab to navigate to the "Turntables" area. Then changed the states of all "Bad" to "Good" as many as possible. Saved using "Esc" and then reboot. It worked :)
powertop
UPDATE: Apparently this did not bring the crazy fan speeds down. After some browsing around, I hit a thread in the ArchBang forums where it became pretty apparent that recent Kernel changes in 3.18 have triggered the issue and still has not been resolved. So, I had to downgrade to 3.17.6 which I did by following a well written guide here. What I basically did was
a. Went to the Arch official package database
b. Located the Linux package
c. On the upper right Package Section of the page, click on View Changes. There I located an earlier version, in this case upgpkg: linux 3.17.6-1
d. Located the revision number from the line that is like "file:///srv/svn-packages@177020". Thats the revision number after the @, it might be anything. e. Then to compile 3.17.6, did the following in the terminal. CAUTION: This process might take several hours, took me around 4 hours to compile the kernel
This will install the new kernel. You might face some dependency issues where it might ask for 3.18. I removed those packages. Rebooted the PC and it was fixed.
cd ~/Downloads
mkdir linux-kernel && cd linux-kernel
svn checkout --depth=empty svn://svn.archlinux.org/packages
cd packages
svn update -rlinux
cd linux/trunk/
makepkg -g >> PKGBUILD
makepkg -s
sudo pacman -U *.pkg.tar.xz
Credits: https://ask.fedoraproject.org/en/question/31514/how-to-change-cpu-temperature-thresholds-and-control-fan-speed/
https://nims11.wordpress.com/2013/02/17/downgrading-packages-in-arch-linux-the-worst-case-scenario/
Go to link download
Subscribe to:
Posts (Atom)